Skip to content
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: multiple GOPATH entries don't work as expected #3652

Closed
adg opened this issue May 22, 2012 · 17 comments
Closed

cmd/go: multiple GOPATH entries don't work as expected #3652

adg opened this issue May 22, 2012 · 17 comments
Milestone

Comments

@adg
Copy link
Contributor

adg commented May 22, 2012

In this example, $HOME/gocode is my usual GOPATH. I created a new workspace in
$HOME/gopath2. "go install" of a test package succeeds, but installs the
'test' binary to the working directory. "go install test" fails, as it seems
to only look inside the first GOPATH when searching for package 'test'.

~/gopath2/src/test% cat main.go
package main
func main() {}
~/gopath2/src/test% GOPATH=$HOME/gocode:$HOME/gopath2 go install
~/gopath2/src/test% ls -l
total 512
-rw-r--r--  1 adg  eng      28 May 22 14:36 main.go
-rwxr-xr-x  1 adg  eng  253968 May 22 14:39 test
~/gopath2/src/test% rm test
~/gopath2/src/test% GOPATH=$HOME/gocode:$HOME/gopath2 go install -x
WORK=/var/folders/00/0sdwh000h01000cxqpysvccm0035qk/T/go-build124998625
mkdir -p $WORK/_/Users/adg/gopath2/src/test/_obj/
cd /Users/adg/gopath2/src/test
/Users/adg/go/pkg/tool/darwin_amd64/6g -o $WORK/_/Users/adg/gopath2/src/test/_obj/_go_.6
-p _/Users/adg/gopath2/src/test -D _/Users/adg/gopath2/src/test -I $WORK ./main.go
/Users/adg/go/pkg/tool/darwin_amd64/pack grc $WORK/_/Users/adg/gopath2/src/test.a
$WORK/_/Users/adg/gopath2/src/test/_obj/_go_.6
cd .
/Users/adg/go/pkg/tool/darwin_amd64/6l -o $WORK/_/Users/adg/gopath2/src/test/_obj/a.out
-L $WORK $WORK/_/Users/adg/gopath2/src/test.a
cp $WORK/_/Users/adg/gopath2/src/test/_obj/a.out test
~/gopath2/src/test% rm test
~/gopath2/src/test% GOPATH=$HOME/gocode:$HOME/gopath2 go install -x test
can't load package: package test: no Go source files in /Users/adg/gocode/src/test
~/gopath2/src/test%
@rsc
Copy link
Contributor

rsc commented May 22, 2012

Comment 1:

Huh?
Why is go install writing to the current directory instead of a bin or
pkg directory?
It looks like it is creating a binary, but why is it not writing to a
bin directory?
Is there a /Users/adg/gocode/pkg/darwin_amd64/test.a?
Russ

@adg
Copy link
Contributor Author

adg commented May 22, 2012

Comment 2:

I found the issue. I had an empty test subdirectory at gocode/src/test.
I infer that "go install" was installing "test" to the current directory because it
found the empty test directory, and decided that the current directory must be outside a
GOPATH. Does that sound reasonable? Removing the "test" subdirectory inside the first
GOPATH fixes the issue.

@rsc
Copy link
Contributor

rsc commented May 22, 2012

Comment 3:

I still don't think install should write to the local directory ever,
but I agree that go thought your current directory was not one with a
standard name.

@adg
Copy link
Contributor Author

adg commented May 22, 2012

Comment 4:

Here's how to reproduce that behavior:
t1=gopath1/src/test
t2=gopath2/src/test
mkdir -p $t1 $t2
echo 'package main; func main() {}' > $t2/main.go
pwd=$(pwd)
cd $pwd/$t2
GOPATH=$pwd/gopath1:$pwd/gopath2 go install -x

@minux
Copy link
Member

minux commented Jun 23, 2012

Comment 5:

Issue #3772 has been merged into this issue.

@rsc
Copy link
Contributor

rsc commented Sep 12, 2012

Comment 6:

Labels changed: added go1.1.

@rsc
Copy link
Contributor

rsc commented Dec 10, 2012

Comment 7:

Labels changed: added size-m.

@rsc
Copy link
Contributor

rsc commented Jan 31, 2013

Comment 8:

Labels changed: added priority-later, removed priority-soon.

@rsc
Copy link
Contributor

rsc commented Mar 12, 2013

Comment 9:

Labels changed: added go1.1maybe, removed go1.1.

@robpike
Copy link
Contributor

robpike commented May 18, 2013

Comment 10:

Labels changed: added go1.2maybe, removed go1.1maybe.

@rsc
Copy link
Contributor

rsc commented Jul 30, 2013

Comment 11:

Labels changed: added feature.

@robpike
Copy link
Contributor

robpike commented Sep 3, 2013

Comment 12:

Not in time for 1.2.

Labels changed: removed go1.2maybe.

@rsc
Copy link
Contributor

rsc commented Nov 27, 2013

Comment 13:

Labels changed: added go1.3maybe.

@rsc
Copy link
Contributor

rsc commented Nov 27, 2013

Comment 14:

Labels changed: removed feature.

@rsc
Copy link
Contributor

rsc commented Dec 4, 2013

Comment 15:

Labels changed: added release-none, removed go1.3maybe.

@rsc
Copy link
Contributor

rsc commented Dec 4, 2013

Comment 16:

Labels changed: added repo-main.

@rsc rsc removed size-m labels Apr 14, 2015
@rsc rsc modified the milestones: Go1.5Maybe, Unplanned Apr 20, 2015
@rsc rsc modified the milestones: Go1.5, Go1.5Maybe Jun 29, 2015
@gopherbot
Copy link

CL https://golang.org/cl/12195 mentions this issue.

@rsc rsc closed this as completed in 238a395 Jul 15, 2015
@golang golang locked and limited conversation to collaborators Jul 18, 2016
@rsc rsc removed their assignment Jun 22, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants