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: packages in different GOPATH are not rebuilt when modified #3749

Closed
gopherbot opened this issue Jun 18, 2012 · 14 comments
Closed

cmd/go: packages in different GOPATH are not rebuilt when modified #3749

gopherbot opened this issue Jun 18, 2012 · 14 comments
Milestone

Comments

@gopherbot
Copy link

by diogin:

What steps will reproduce the problem?


1. Set GOPATH to two different paths:

D:\>echo %GOPATH%
D:\code;D:\devel\trunk

2. Create a folder "dddd" under "D:\devel\trunk\src", and create a
file "dddd.go" in it with the following content:

package dddd

func F() {
    println("ccc")
}

3. Create a folder "demo" under "D:\code\src", whose code imports
"dddd":

package main

import (
    "dddd"
)

func main() {
    dddd.F()
}

4. Step 3 prints a "ccc". Then change the string in "dddd\dddd.go"
to "eee", and "go install demo" again, the string printed is still
"ccc".


What is the expected output?

Shoud print "eee".

What do you see instead?

Print "ccc".

Which compiler are you using (5g, 6g, 8g, gccgo)?

8g

Which operating system are you using?

Windows/386

Which version are you using?  (run 'go version')

1.0.2
@alexbrainman
Copy link
Member

Comment 1:

Cannot reproduce. But your description is bit vague. Here everything is important:
working directory, file / directory name case and such. Please, provide list of exact
commands to reproduce. Thank you.
Alex

Status changed to WaitingForReply.

@gopherbot
Copy link
Author

Comment 2 by diogin:

Hello, you can reproduce exactly following these steps:
D:\>echo %GOPATH%
D:\code;D:\devel\trunk
D:\>type D:\code\src\demo\main.go
package main
import "dddd"
func main() {
    dddd.F()
}
D:\>type D:\devel\trunk\src\dddd\dddd.go
package dddd
func F() {
    println("ccc")
}
D:\>go install demo
D:\>demo
ccc
// here, edit the content to "eee"
D:\>type D:\devel\trunk\src\dddd\dddd.go
package dddd
func F() {
    println("eee")
}
D:\>go install demo
D:\>demo
ccc
D:\>

@gopherbot
Copy link
Author

Comment 3 by diogin:

I add "D:\code\bin" to my PATH.

@peterGo
Copy link
Contributor

peterGo commented Jun 18, 2012

Comment 4:

It's easy to reproduce this issue.
The build flags are shared by the build, install, run, and test commands:
    -a    force rebuilding of packages that are already up-to-date.
Command go
Compile packages and dependencies
http://golang.org/cmd/go/#Compile_packages_and_dependencies
For example,
    D:\>go install -a demo

@peterGo
Copy link
Contributor

peterGo commented Jun 18, 2012

Comment 5:

It's easy to reproduce this issue.
The build flags are shared by the build, install, run, and test commands:
    -a    force rebuilding of packages that are already up-to-date.
Command go
Compile packages and dependencies
http://golang.org/cmd/go/#Compile_packages_and_dependencies
For example, to solve the problem, run,
    D:\>go install -a demo

@peterGo
Copy link
Contributor

peterGo commented Jun 18, 2012

Comment 6:

I'm able to reproduce this issue on Windows 7. I'm unable to reproduce this issue on
Linux Mint 13. Therefore, it's most likely to be a Windows issue.

@alexbrainman
Copy link
Member

Comment 7:

I can reproduce your problem now, thank you. And I can reproduce it on both windows and
linux.
Trying to understand why it is happening. Here is the code:
http://code.google.com/p/go/source/browse/src/cmd/go/pkg.go#515
If you look at the comment just above:
// ... If a package p is not in the same tree as any
// package named on the command-line, assume it is up-to-date
// no matter what the modification times on the source files indicate.
// This avoids rebuilding $GOROOT packages when people are
// working outside the Go root, and it effectively makes each tree
// listed in $GOPATH a separate compilation world.
// See issue #3149.
Given that comment, in addition to extract from
http://code.google.com/p/go/source/detail?r=a461bcce05f6
commit message:
* Do not recompile packages across roots (Fixes  issue #3149 .)
I surmise it is working as intended. So I should be closing this issue as such. But, as
a fellow programer, I can see this behavior confusing in your scenario. Perhaps this
needs to be documented somewhere at the very least.
Leaving it for others to decide what to do.
Alex

Status changed to Accepted.

@rsc
Copy link
Contributor

rsc commented Sep 12, 2012

Comment 8:

We should make sure the docs are clear.

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

@rsc
Copy link
Contributor

rsc commented Sep 12, 2012

Comment 9:

Labels changed: added go1.1.

@rsc
Copy link
Contributor

rsc commented Dec 10, 2012

Comment 10:

Labels changed: added size-l.

@rsc
Copy link
Contributor

rsc commented Mar 12, 2013

Comment 11:

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

@robpike
Copy link
Contributor

robpike commented May 18, 2013

Comment 12:

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

@rsc
Copy link
Contributor

rsc commented Jul 30, 2013

Comment 13:

Labels changed: added feature.

@robpike
Copy link
Contributor

robpike commented Aug 16, 2013

Comment 14:

Status changed to WorkingAsIntended.

@rsc rsc added this to the Go1.2 milestone Apr 14, 2015
@rsc rsc removed the go1.2maybe label Apr 14, 2015
@golang golang locked and limited conversation to collaborators Jun 24, 2016
This issue was closed.
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