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: 1.11beta2 cannot find module providing package #26695

Closed
udhos opened this issue Jul 30, 2018 · 11 comments
Closed

cmd/go: 1.11beta2 cannot find module providing package #26695

udhos opened this issue Jul 30, 2018 · 11 comments
Labels
FrozenDueToAge modules NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@udhos
Copy link

udhos commented Jul 30, 2018

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

go version go1.11beta2 linux/amd64

Does this issue reproduce with the latest release?

Yes, it affects go1.11beta2.

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

$ go env
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/lab/.cache/go-build"
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/lab/go"
GOPROXY=""
GORACE=""
GOROOT="/usr/local/go"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
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-build934050422=/tmp/go-build -gno-record-gcc-switches"

What did you do?

Tried to build a trivial application 'modapp' which depends on specific package 'lib' from trivial module 'modlib'. The repository is tagged as 'modlib/v1.0.0'.

I have posted full description of the issue on Stackoverflow: https://stackoverflow.com/questions/51560387/how-to-import-specific-package-from-go-module

A quick way to reproduce is:

# 1) install go1.11beta2
# 2) run:
git clone https://github.com/udhos/modhello
cd modhello/modlib
go list -m all
cd ../modapp
go install

I have been told the git version may be important:

$ git --version
git version 2.18.0

What did you expect to see?

modapp should have been compiled and installed as ~/go/bin/modapp without errors.

However I may well be doing something wrong.

What did you see instead?

go install
go: finding github.com/udhos/modhello/modlib/lib latest
go: finding github.com/udhos/modhello latest
go: import "github.com/udhos/modhello/modapp" ->
        import "github.com/udhos/modhello/modlib/lib": cannot find module providing package github.com/udhos/modhello/modlib/lib
@ALTree ALTree added NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. modules labels Jul 30, 2018
@ALTree ALTree added this to the Go1.11 milestone Jul 30, 2018
@marwan-at-work
Copy link
Contributor

@udhos Did you run these steps before pushing your repo to github? Right now, your repo works fine and it does not reproduce the error when following the steps above.

This is likely because modapp requires modlib as an "independent dependency" because you have multiple go.mod files in the same repo. Therefore, when you first try to run go install inside modapp, Go tries to fetch modlib from upstream (which you may not have pushed to github at that point) and therefore it cannot find it.

Having one go.mod per repo would solve this.

@udhos
Copy link
Author

udhos commented Jul 30, 2018

Yes, I tested the steps to reproduce it before opening the issue.
I wonder if there could be anything cached somewhere persistently causing the issue for me.

lab@ubu1:~/eraseme$ rm -rf modhello/
lab@ubu1:~/eraseme$ git clone https://github.com/udhos/modhello
Cloning into 'modhello'...
remote: Counting objects: 70, done.
remote: Compressing objects: 100% (45/45), done.
remote: Total 70 (delta 23), reused 59 (delta 16), pack-reused 0
Unpacking objects: 100% (70/70), done.
lab@ubu1:~/eraseme$ cd modhello/modapp
lab@ubu1:~/eraseme/modhello/modapp$ go install
go: finding github.com/udhos/modhello/modlib/lib latest
go: finding github.com/udhos/modhello latest
go: import "github.com/udhos/modhello/modapp" ->
        import "github.com/udhos/modhello/modlib/lib": cannot find module providing package github.com/udhos/modhello/modlib/lib
lab@ubu1:~/eraseme/modhello/modapp$

@udhos
Copy link
Author

udhos commented Jul 30, 2018

Having one go.mod per repo would solve this.

When I hit this issue, I was actually trying to figure out how to host two distinct modules at the same git repository while also importing a specific package from a module.

I mean:

  1. Multiple modules hosted at single repo.
  2. Multiple packages hosted at single module.

As far as I can tell, such a layout is supported, right?

@udhos
Copy link
Author

udhos commented Jul 30, 2018

@marwan-at-work I have just tested the steps with a new user and it indeed worked as expected... So I guess there is something cached in the homedir of the old user...

@patricksuo
Copy link

patricksuo commented Jul 31, 2018

I can reproduce with @rsc 's A Tour of Versioned Go

[supei@localhost hello]$ cat go.mod
module github.com/you/hello
[supei@localhost hello]$ cat hello.go
package main // import "github.com/you/hello"

import (
        "fmt"

        "rsc.io/quote"
)

func main() {
        fmt.Println(quote.Hello())
}
[supei@localhost hello]$ go1.11beta2 build
go: finding rsc.io/quote v1.5.2
go: import "github.com/you/hello" ->
        import "rsc.io/quote": cannot find module providing package rsc.io/quote
[supei@localhost hello]$ go ^C
[supei@localhost hello]$ go1.11beta2  env
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/supei/.cache/go-build"
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/supei/gohome"
GOPROXY=""
GORACE=""
GOROOT="/home/supei/sdk/go1.11beta2"
GOTMPDIR=""
GOTOOLDIR="/home/supei/sdk/go1.11beta2/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/home/supei/hello/go.mod"
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-build093482810=/tmp/go-build -gno-record-gcc-switches"

[supei@localhost hello]$ echo $GO111MODULE
on

@patricksuo
Copy link

I believe this bug is fixed in 90066bf

@bcmills
Copy link
Contributor

bcmills commented Aug 2, 2018

This seems to work for me (with git 2.18.0, which suggests that @sillyousu's theory is correct).

modapp$ go list -m all
go: finding github.com/udhos/modhello/modlib v1.0.0
github.com/udhos/modhello/modapp
github.com/udhos/modhello/modlib v1.0.0

modapp$ go build .
go: downloading github.com/udhos/modhello/modlib v1.0.0

modapp$

@bcmills bcmills closed this as completed Aug 2, 2018
@bcmills
Copy link
Contributor

bcmills commented Aug 2, 2018

(But please do let us know if it's still broken at head, or at go1.11beta3 whenever that comes out.)

@udhos
Copy link
Author

udhos commented Aug 2, 2018

I don't think it's a git issue, because I am running git 2.18.0 as well.
I think it is some Go caching issue, because it affects one user but not other newer user, both on the same system. Both users share system-wide go 1.11beta2 and git 2.18.0.

@bcmills
Copy link
Contributor

bcmills commented Aug 2, 2018

You may need to run go clean -modcache to clear out cached data from before the fix.

@udhos
Copy link
Author

udhos commented Aug 2, 2018

go clean -modcache did fix it! Thanks!

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.
Projects
None yet
Development

No branches or pull requests

6 participants