New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmd/go: go1.11 failed to derive $GOPATH in container environment #27468

Open
rockmenjack opened this Issue Sep 3, 2018 · 4 comments

Comments

Projects
None yet
4 participants
@rockmenjack

rockmenjack commented Sep 3, 2018

What version of Go are you using (go version)?

go 1.11

Does this issue reproduce with the latest release?

yes

What operating system and processor architecture are you using (go env)?

linux amd64

What did you do?

go test/build a module in a container

What did you expect to see?

command shall run without any issue

What did you see instead?

go complains "missing $GOPATH"

I have checked go env output in the container:

GOARCH="amd64"
GOBIN=""
GOCACHE="/root/.cache/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH=""             <--  empty here!!!
GOPROXY=""
GORACE=""
GOROOT="/root/go"
GOTMPDIR=""
GOTOOLDIR="/root/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build579993932=/tmp/go-build -gno-record-gcc-switches"

go env looks ok in the host:

GOARCH="amd64"
GOBIN=""
GOCACHE="/home/rockmen1/.cache/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/rockmen1/go"    <--   however this dir does not exist
GOPROXY=""
GORACE=""
GOROOT="/tmp/go"
GOTMPDIR=""
GOTOOLDIR="/tmp/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build691156100=/tmp/go-build -gno-record-gcc-switches"

Can be easily reproduce with below Dockerfile:

#FROM centos:7
FROM debian:9

ADD go1.11.linux-amd64.tar.gz /root

CMD GOROOT=/root/go /root/go/bin/go env

older go version runs fine.

@mfrw

This comment has been minimized.

Contributor

mfrw commented Sep 3, 2018

The issue #17262 might help you in understanding why host shows $GOPATH as a non-existent directory.

@andybons andybons changed the title from go1.11 failed to derive $GOPATH in container environment to cmd/go: go1.11 failed to derive $GOPATH in container environment Sep 5, 2018

@andybons

This comment has been minimized.

Member

andybons commented Sep 5, 2018

@andybons andybons added this to the Unplanned milestone Sep 5, 2018

@bcmills

This comment has been minimized.

Member

bcmills commented Sep 5, 2018

go test/build a module in a container

older go version runs fine.

These can't both hold, can they? Older go versions don't support modules.

@rockmenjack

This comment has been minimized.

rockmenjack commented Sep 6, 2018

These can't both hold, can they? Older go versions don't support modules.

True. That's why go 1.11 shall not complain missing $GOPATH when modules is used, but it did in the container case where GOPATH is empty.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment