Skip to content
This repository has been archived by the owner on Mar 6, 2020. It is now read-only.

Change go binary file lookup for generate & test tools #520

Closed
wants to merge 1 commit into from
Closed

Change go binary file lookup for generate & test tools #520

wants to merge 1 commit into from

Conversation

mguzelevich
Copy link

filepath.Join(runtime.GOROOT(), "bin", "go") is not always find the correct location of a go binary file

example:

% uname -a
Linux michael 4.3.2 #1-NixOS SMP Thu Jan 1 00:00:01 UTC 1970 x86_64 GNU/Linux

% nixos-version
15.09.784.7b85b8a (Dingo)

% go env | grep GOROOT
GOROOT="/nix/store/c4vlrc0bfl5nv85ph9p0hhz2a5h59lkm-go-1.5.1/share/go"

% whereis go
go: /nix/store/ys47s890vyrf1vghzhf3vsnnl8k1m6gg-system-path/bin/go

% ls -lah /nix/store/ys47s890vyrf1vghzhf3vsnnl8k1m6gg-system-path/bin/go
/nix/store/ys47s890vyrf1vghzhf3vsnnl8k1m6gg-system-path/bin/go -> /nix/store/c4vlrc0bfl5nv85ph9p0hhz2a5h59lkm-go-1.5.1/bin/go

% /nix/store/c4vlrc0bfl5nv85ph9p0hhz2a5h59lkm-go-1.5.1/share/go/bin/go
zsh: no such file or directory: /nix/store/c4vlrc0bfl5nv85ph9p0hhz2a5h59lkm-go-1.5.1/share/go/bin/go

% ls -la /nix/store/c4vlrc0bfl5nv85ph9p0hhz2a5h59lkm-go-1.5.1/share/go/bin
total 8
dr-xr-xr-x  2 root root 4096 Jan  1  1970 .
dr-xr-xr-x 10 root root 4096 Jan  1  1970 ..

@davecheney
Copy link
Contributor

Not LGTM sorry. We cannot use the go.binary in the path as this may not be the same go binary that built this go test binary.

@davecheney
Copy link
Contributor

Please log an issue to discuss the problem with nix and we'll workshop a solution there.

@davecheney davecheney closed this Dec 30, 2015
@mguzelevich
Copy link
Author

ubuntu 15.04 docker image via AWS

FROM ubuntu:15.04
...
RUN apt-get update && apt-get install -y --no-install-recommends software-properties-common
RUN add-apt-repository ppa:evarlast/golang1.5
RUN apt-get update && apt-get install -y --no-install-recommends golang
...
ENV GOPATH $home/gopath
...
RUN go get github.com/constabulary/gb/...
...

same problem.
gb generate - failed with FATAL: command "generate" failed: fork/exec /usr/lib/go/bin/go: no such file or directory

# uname -a
Linux 12d6e321aac2 3.14.44-32.39.amzn1.x86_64 #1 SMP Thu Jun 11 20:33:38 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux

# go env | grep GOROOT
GOROOT="/usr/lib/go"

# ls -la /usr/lib/go
total 16
drwxr-xr-x  4 root root 4096 Dec 28 16:35 .
drwxr-xr-x 35 root root 4096 Dec 28 16:37 ..
lrwxrwxrwx  1 root root   31 Aug 21 18:16 doc -> ../../share/doc/golang-doc/html
lrwxrwxrwx  1 root root   38 Aug 21 18:16 favicon.ico -> ../../share/doc/golang-doc/favicon.ico
drwxr-xr-x  2 root root 4096 Dec 28 16:35 lib
drwxr-xr-x  6 root root 4096 Aug 21 18:07 pkg
lrwxrwxrwx  1 root root   18 Aug 21 18:16 src -> ../../share/go/src

# whereis go
go: /usr/bin/go /usr/lib/go /usr/share/go /usr/share/man/man1/go.1.gz

@mguzelevich
Copy link
Author

gb doc - failed with FATAL: command "generate" failed: fork/exec /usr/lib/go/bin/godoc: no such file or directory

@davecheney
Copy link
Contributor

Thanks for the report. I think this is fixable, it looks like Ubuntu move
the go tool relative to GOROOT, think if we try GOROOT, GOROOT/.. And
GOROOT/../.. That should work.

On Wed, 30 Dec 2015, 14:45 Michael notifications@github.com wrote:

gb doc - failed with FATAL: command "generate" failed: fork/exec
/usr/lib/go/bin/godoc: no such file or directory


Reply to this email directly or view it on GitHub
#520 (comment).

@davecheney
Copy link
Contributor

Go gb generate I think it would be easier to just execute "go" and let the
normal path lookup do its magic

On Wed, 30 Dec 2015, 14:48 Dave Cheney dave@cheney.net wrote:

Thanks for the report. I think this is fixable, it looks like Ubuntu move
the go tool relative to GOROOT, think if we try GOROOT, GOROOT/.. And
GOROOT/../.. That should work.

On Wed, 30 Dec 2015, 14:45 Michael notifications@github.com wrote:

gb doc - failed with FATAL: command "generate" failed: fork/exec
/usr/lib/go/bin/godoc: no such file or directory


Reply to this email directly or view it on GitHub
#520 (comment).

@davecheney
Copy link
Contributor

For the cmd/gb test it is important to call the save version of Go that
built the test binary. If that cannot be derived from GOROOT, we'll have to
skip the whole test.

On Wed, 30 Dec 2015, 14:50 Dave Cheney dave@cheney.net wrote:

Go gb generate I think it would be easier to just execute "go" and let the
normal path lookup do its magic

On Wed, 30 Dec 2015, 14:48 Dave Cheney dave@cheney.net wrote:

Thanks for the report. I think this is fixable, it looks like Ubuntu move
the go tool relative to GOROOT, think if we try GOROOT, GOROOT/.. And
GOROOT/../.. That should work.

On Wed, 30 Dec 2015, 14:45 Michael notifications@github.com wrote:

gb doc - failed with FATAL: command "generate" failed: fork/exec
/usr/lib/go/bin/godoc: no such file or directory


Reply to this email directly or view it on GitHub
#520 (comment).

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants