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: go.mod with replace local folder does not pull latest files present on the disk #38206

Closed
jlory opened this issue Apr 1, 2020 · 2 comments
Labels
FrozenDueToAge WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.
Milestone

Comments

@jlory
Copy link

jlory commented Apr 1, 2020

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

$ go version go1.13.9 linux/amd64

Does this issue reproduce with the latest release?

This is the latest 1.13 release, did not test on 1.14.

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

go env Output
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/jlory/.cache/go-build"
GOENV="/home/jlory/.config/go/env"
GOEXE=""
GOFLAGS="-mod=vendor"
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/jlory/go"
GOPRIVATE=""
GOPROXY="direct"
GOROOT="/usr/local/go"
GOSUMDB="off"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
AR="ar"
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-build754290189=/tmp/go-build -gno-record-gcc-switches"

What did you do?

I'm working locally on a fork of a library to test some changes, I added a replace block inside go.mod such as follow:

module gitlab.local/jlory/auth-test

go 1.13

require gitlab.local/harbour/libs/ubiservices-go v1.1.0

replace gitlab.local/harbour/libs/ubiservices-go => /home/jlory/git/gitlab.local/jlory/ubiservices-go

When I build the project with go build I don't get the latest "replaced" files, by latest I mean I changed/saved the files inside /home/jlory/git/gitlab.local/jlory/ubiservices-go and when I run the binary that I just built it's not what it should be running, it's a previous version that is no longer on the disk.

It's worth mentionning that I work inside VirtualBox ( might be some FS caching shenanigans).

What did you expect to see?

When I run go build . with a replace block targetting a local library I expect go build to pull the latest files on the filesystem.

What did you see instead?

I see old code running that is no longer on the disk.

@gopherbot gopherbot added this to the Unreleased milestone Apr 1, 2020
@gopherbot gopherbot added the Builders x/build issues (builders, bots, dashboards) label Apr 1, 2020
@jayconrod jayconrod changed the title x/build/cmd: go.mod with replace local folder does not pull latest files present on the disk cmd/go: go.mod with replace local folder does not pull latest files present on the disk Apr 2, 2020
@jayconrod jayconrod added WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. and removed Builders x/build issues (builders, bots, dashboards) labels Apr 2, 2020
@jayconrod
Copy link
Contributor

Your go.mod file looks correct. A few things to try:

  • It looks like you have -mod=vendor in your GOFLAGS variable. Did you run go mod vendor after adding the replace directive?
  • What happens if you remove -mod=vendor?
  • What does go list -json show when given a package in that module? There is a Dir field that indicates where each package is loaded from.

@jlory
Copy link
Author

jlory commented Apr 2, 2020

Actually I think it's my mistake, I was confused because the vendored files have the right content with the path from require and not replace from go.mod file.

@jlory jlory closed this as completed Apr 2, 2020
@golang golang locked and limited conversation to collaborators Apr 2, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.
Projects
None yet
Development

No branches or pull requests

3 participants