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 get -u fails with local-only replacements #32567

Closed
kenichi-fukushima opened this issue Jun 12, 2019 · 11 comments
Closed

cmd/go: go get -u fails with local-only replacements #32567

kenichi-fukushima opened this issue Jun 12, 2019 · 11 comments
Labels
FrozenDueToAge modules 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

@kenichi-fukushima
Copy link

Please answer these questions before submitting your issue. Thanks!

What did you do?

Run go get -u in a module with replace with a local module.

You can reproduce the problem by checking out this repository and run the command in depending directory.
https://github.com/kenichi-fukushima/go-local-modules

What did you expect to see?

The command finishes successfully.

What did you see instead?

The command failed with this message.

go get: upgrading example.com/depended@v0.0.0: unrecognized import path "example.com/depended" (parse https://example.com/depended?go-get=1: no go-import meta tags ())

System details

I got this error with 12.2/12.5 on Linux too.

go version go1.12.6 darwin/amd64
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/keni/Library/Caches/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/keni/go"
GOPROXY=""
GORACE=""
GOROOT="/usr/local/go"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/darwin_amd64"
GCCGO="gccgo"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/Users/keni/Downloads/go-local-modules-master/depending/go.mod"
GOROOT/bin/go version: go version go1.12.6 darwin/amd64
GOROOT/bin/go tool compile -V: compile version go1.12.6
uname -v: Darwin Kernel Version 18.2.0: Thu Dec 20 20:46:53 PST 2018; root:xnu-4903.241.1~1/RELEASE_X86_64
ProductName:	Mac OS X
ProductVersion:	10.14.3
BuildVersion:	18D109
lldb --version: lldb-1000.0.38.2
  Swift-4.2
@bcmills bcmills changed the title go get -u fails with replace with local modules in go.mod cmd/go: go get -u fails with local-only replacements Jun 13, 2019
@bcmills
Copy link
Contributor

bcmills commented Jun 13, 2019

Coincidentally, @jayconrod and I also noticed that this is broken in the context of https://golang.org/cl/180337.

Any fix is probably too invasive for 1.13, but we're planning to overhaul replacements in general for 1.14.

@bcmills bcmills added modules NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. labels Jun 13, 2019
@bcmills bcmills added this to the Go1.14 milestone Jun 13, 2019
@rsc rsc modified the milestones: Go1.14, Backlog Oct 9, 2019
@pablote
Copy link

pablote commented Mar 28, 2020

Hi, any fix or workaround for this? Testing this out with go 1.14.1 on darwin. I was usually able to update all dependencies with go get -u ./..., but since we moved to a monorepo and using replace in go.mod files this is now failing, it seems to be trying to fetch the replaced dependencies repo online.

On the other hand, updating specific dependencies go get some-dep@someversion works.

@pablote
Copy link

pablote commented Mar 28, 2020

Not the best workaround in the world, but I just found that if replaced dependencies are temporarily removed from go.mod, then go get -u ./... actually updates the rest of the dependencies. It still prints some errors on the console, but it works.

@microo8
Copy link

microo8 commented Jul 17, 2020

All of the private modules I use are just in a fictional mycompany.com/somemodule.

So I tried to add the fictional domain to GOPRIVATE with:
go env -w GOPRIVATE=mycompany.com

and then run go get -u all
But it fails with go get all: unrecognized import path "mycompany.com/common/utils": reading https://mycompany.com/common/utils?go-get=1: 404 Not Found

Is it possible, that go get -u all ignores the environment variables? (GOPRIVATE,GONOPROXY,GONOSUMDB)

@jayconrod
Copy link
Contributor

@microo8 This issue is specifically related to local replacements. It sounds like you're running into a different problem with private modules so please open a new issue instead.

(go get does not ignore those environment variables. Please make sure that there is a server at that URL resolving module paths to repository URLs or make sure module paths end with .git.)

@microo8
Copy link

microo8 commented Jul 20, 2020

I have the private modules replaced with a local module

module mycompany.com/clientname/server

go 1.14

require (
    github.com/lib/pq v1.7.0
    github.com/99designs/gqlgen v0.11.3
    github.com/vektah/gqlparser/v2 v2.0.1
    golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d
    mycompany.com/clientname/models v0.0.0-00010101000000-000000000000
    mycompany.com/common/utils v0.0.0-00010101000000-000000000000
)

replace mycompany.com/common/utils => ../../common/utils

replace mycompany.com/clientname/models => ../models

and that doesn't work. the mycompany.com is just fictional, there isn't a server on the url

go get -u all finds the new versions of the github.com modules and then fails with go get all: unrecognized import path "mycompany.com/common/utils": reading https://mycompany.com/common/utils?go-get=1: 404 Not Found an doesn't update go.mod

@jayconrod
Copy link
Contributor

@microo8 Thanks for that example. It does seem to be the same issue described here.

The error is reported because the go command is attempting to find a VCS repository for a module path (mycompany.com/common/utils). The module path is replaced with a local directory, so it's a bug that it's doing that.

@microo8
Copy link

microo8 commented Jul 21, 2020

So I report the bug in a new issue. Thanks

@gopherbot
Copy link

Change https://golang.org/cl/255046 mentions this issue: cmd/go/internal/modload: avoid a network fetch when querying a valid semantic version

gopherbot pushed a commit that referenced this issue Sep 17, 2020
…semantic version

Test this behavior incidentally in a test for ambiguous import errors.
(I rediscovered the error when writing the new test.)

For #32567
Updates #28806

Change-Id: I323f05145734e5cf99818b9f04d65075f7c0f787
Reviewed-on: https://go-review.googlesource.com/c/go/+/255046
Trust: Bryan C. Mills <bcmills@google.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Michael Matloob <matloob@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
@bcmills bcmills modified the milestones: Backlog, Go1.16 Oct 21, 2020
@bcmills bcmills self-assigned this Oct 21, 2020
@bcmills
Copy link
Contributor

bcmills commented Oct 21, 2020

I believe this is fixed as of https://golang.org/cl/258220.

@kenichi-fukushima, please try a go command built from head (either by following the instructions at https://golang.org/doc/install/source or using golang.org/dl/gotip) and let us know if it still isn't working for you.

@bcmills bcmills added the WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. label Oct 21, 2020
@gopherbot
Copy link

Timed out in state WaitingForInfo. Closing.

(I am just a bot, though. Please speak up if this is a mistake or you have the requested information.)

@golang golang locked and limited conversation to collaborators Nov 21, 2021
@rsc rsc unassigned bcmills Jun 23, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge modules 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

7 participants