Skip to content

cmd/go/internal/modcmd: go.work local module fetching from remote by mistake #71055

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

Closed
ViolaPioggia opened this issue Dec 29, 2024 · 3 comments
Closed
Labels
GoCommand cmd/go NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.
Milestone

Comments

@ViolaPioggia
Copy link

ViolaPioggia commented Dec 29, 2024

Go version

go version go1.21.1 darwin/arm64

Output of go env in your module/workspace:

GO111MODULE='on'
GOARCH='arm64'
GOBIN=''
GOCACHE='/Users/violapioggia/Library/Caches/go-build'
GOENV='/Users/violapioggia/Library/Application Support/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='arm64'
GOHOSTOS='darwin'
GOINSECURE=''
GOMODCACHE='/Users/violapioggia/go/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='darwin'
GOPATH='/Users/violapioggia/go'
GOPRIVATE=''
GOPROXY='https://goproxy.cn,direct'
GOROOT='/usr/local/go'
GOSUMDB='off'
GOTMPDIR=''
GOTOOLCHAIN=''
GOTOOLDIR='/usr/local/go/pkg/tool/darwin_arm64'
GOVCS=''
GOVERSION='go1.21.1'
GCCGO='gccgo'
AR='ar'
CC='clang'
CXX='clang++'
CGO_ENABLED='1'
GOMOD='/Users/violapioggia/GolandProjects/rgo/go.mod'
GOWORK=''
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
PKG_CONFIG='pkg-config'
GOGCCFLAGS='-fPIC -arch arm64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -ffile-prefix-map=/var/folders/2y/q5hfz55n7yx__bgtrj0pwgpw0000gn/T/go-build2698698558=/tmp/go-build -gno-record-gcc-switches -fno-common'

What did you do?

I have a repo which module name is github.com/violapioggia/fake_module and it is used by my main repo by go.work, it can import and work successfully but when I use command go mod tidy, it tried to get the module from remote and return error even if I had already have this module locally by go.work.

What did you see happen?

go mod tidy

go: finding module for package github.com/violapioggia/fake_module/test
go: rgo_test imports
github.com/violapioggia/fake_module/test: cannot find module providing package github.com/violapioggia/fake_module/test: module github.com/violapioggia/fake_module/test: git ls-remote -q origin in /Users/violapioggia/go/pkg/mod/cache/vcs/1947ab1c5f53e39b9356cdc44ed18f4f16ffcc10b0bedf604238c177732107de: exit status 128:
remote: Repository not found.
fatal: repository 'https://github.com/violapioggia/fake_module/' not found

What did you expect to see?

I want to use go mod tidy to not to get remote module when I already have this module in go.work.

@dmitshur
Copy link
Contributor

dmitshur commented Dec 30, 2024

Thanks for the report. Are you able to share a go.work and other files needed to trigger the behavior you're seeing, preferably reduced to a minimal set? Also, Go 1.21.1 is a bit old, does this still happen with a newer version of Go?

Does the github.com/violapioggia/fake_module/test package exist in the repo you have locally? As go mod tidy works to add missing modules to go.mod, it's expected it will need to look up modules that might provide packages. Quoting from https://go.dev/ref/mod#go-mod-tidy:

Once go mod tidy has loaded this set of packages, it ensures that each module that provides one or more packages has a require directive in the main module’s go.mod file [...]. go mod tidy will add a requirement on the latest version of each missing module (see Version queries for the definition of the latest version).

So this might be working as intended, or there may be a bug in go mod tidy, and I don't think it's possible to tell which without more information about the go.mod file content and other files involved in reproducing this behavior.

CC @matloob, @samthanawalla.

@dmitshur dmitshur added WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. GoCommand cmd/go labels Dec 30, 2024
@dmitshur dmitshur added this to the Backlog milestone Dec 30, 2024
@seankhliao
Copy link
Member

see #50750

@seankhliao seankhliao closed this as not planned Won't fix, can't repro, duplicate, stale Dec 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
GoCommand cmd/go NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.
Projects
None yet
Development

No branches or pull requests

4 participants