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: cannot find module providing package #26353

Closed
sneko opened this issue Jul 12, 2018 · 12 comments

Comments

Projects
None yet
7 participants
@sneko
Copy link

commented Jul 12, 2018

Please answer these questions before submitting your issue. Thanks!

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

go version go1.10 windows/amd64 go:2018-02-20.1
(Downloaded today)

Does this issue reproduce with the latest release?

Yes

What did you do?

vgo mod -sync after initializing the go.mod

With a simple HelloWorld program:

package main

import (
	"fmt"

	"github.com/graph-gophers/graphql-go/gqltesting"
)

func main() {
    fmt.Println("hello world")
}

What did you expect to see?

Successfully downloading dependencies

What did you see instead?

go: finding github.com/graph-gophers/graphql-go/gqltesting latest
go: finding github.com/graph-gophers/graphql-go latest
go: extracting github.com/graph-gophers/graphql-go v0.0.0-20180609140535-bb9738501bd4
-> unzip C:\Users\Sneko\go\src\mod\cache\download\github.com\graph-gophers\graphql-go\@v\v0.0.0-20180609140535-bb9738501bd4.zip: invalid file name github.com/graph-gophers/graphql-go@v0.0.0-20180609140535-bb9738501bd4/.gitignore
go: import "a/b/c" ->
        import "github.com/graph-gophers/graphql-go/gqltesting": cannot find module providing package github.com/graph-gophers/graphql-go/gqltesting

Moreover I simplified the issue with a HelloWorld program with just 1 import, but that's the same in my real project with more dependencies (the ones not described below are working well):

go: import "github.com/graph-gophers/graphql-go": cannot find module providing package github.com/graph-gophers/graphql-go                                      ge github.com/dgrijalva/jwt-go
go: import "golang.org/x/net/context": cannot find module providing package golang.org/x/net/context
go: import "XXXXX/YYYYYYYY/api/context" ->
        import "github.com/spf13/viper": cannot find module providing package github.com/spf13/viper
go: import "XXXXX/YYYYYYYY/api/handler" ->        import "github.com/dgrijalva/jwt-go": cannot find module providing package github.com/dgrijalva/jwt-go
go: import "XXXXX/YYYYYYYY/api/handler" ->
        import "github.com/op/go-logging": cannot find module providing package github.com/op/go-logging
go: import "XXXXX/YYYYYYYY/api/loader" ->
        import "gopkg.in/nicksrandall/dataloader.v5": cannot find module providing package gopkg.in/nicksrandall/dataloader.v5
go: import "XXXXX/YYYYYYYY/api/service" ->        import "github.com/jmoiron/sqlx": cannot find module providing package github.com/jmoiron/sqlx
go: import "XXXXX/YYYYYYYY/api/service" ->
        import "github.com/rs/xid": cannot find module providing package github.com/rs/xid
go: import "XXXXX/YYYYYYYY/api/handler" ->
        import "XXXXX/YYYYYYYY/api/model" ->
        import "golang.org/x/crypto/bcrypt": cannot find module providing package golang.org/x/crypto/bcrypt

Thank you 😃

@gopherbot gopherbot added this to the vgo milestone Jul 12, 2018

@rsc rsc modified the milestones: vgo, Go1.11 Jul 12, 2018

@rsc rsc added the modules label Jul 12, 2018

@rsc rsc changed the title x/vgo: cannot find module providing package cmd/go: cannot find module providing package Jul 12, 2018

@tobiaskohlbau

This comment has been minimized.

Copy link

commented Jul 13, 2018

I tracked down the issue with for e.g. invalid file name. It's related to windows and zip file handling.

https://github.com/golang/vgo/blob/cc75ec08d5ecfc4072bcefc2c696d1c30af692b9/vendor/cmd/go/internal/modfetch/unzip.go#L57-L66

On systems with PathSeperator equals to / everything works. But on windows the call filepath.Clean replaces slashes with backslashes. This results in filepath.Clean(zf.Name) != zf.Name as the zip package returns the path with forward slashes.

I've build a quick workaround, but I'm not sure if this is a good solution. Maybe @rsc who introduced this lines within a4111b184cac70ec5478914d3b98168dd34bcf4a could tell us more.

name := strings.Replace(zf.Name, "/", string(os.PathSeparator), -1)
if filepath.Clean(zf.Name) != name || strings.HasPrefix(zf.Name[len(prefix)+1:], "/") {
	return fmt.Errorf("unzip %v: invalid file name %s", zipfile, zf.Name)
}
@rsc

This comment has been minimized.

Copy link
Contributor

commented Jul 17, 2018

Fixed in golang.org/cl/123580, sorry about the trouble.
(Note that this has not come back into the vgo repo yet but it will around the time we issue beta2.)

@rsc rsc closed this Jul 17, 2018

@sneko

This comment has been minimized.

Copy link
Author

commented Jul 18, 2018

@rsc just to be curious, any approximate release date for this beta2?

Thanks for your work 😃

@lancerushing

This comment has been minimized.

Copy link

commented Jul 26, 2018

I'm still seeing this in go1.11beta2.

Steps to reproduce (using docker container to isolate..)

docker run --rm -it ubuntu:16.04 bash

Then inside the container:

## Install Deps
apt update; apt install -y curl git

## Install go
cd /tmp
curl -O https://dl.google.com/go/go1.11beta2.linux-amd64.tar.gz
tar xf go1.11beta2.linux-amd64.tar.gz -C /opt/

## Setup go
export GO_ROOT=/opt/go
export GO_PATH=$HOME/go
export PATH=${GO_ROOT}/bin:${PATH}
go version
### go version go1.11beta2 linux/amd64

## Create new fake project
cd
mkdir my-project
cd my-project

# Initialize
go mod -module github.com/example/my-project -init

# Add some code
echo 'package main
import "golang.org/x/text/message"
func main() {
    p := message.NewPrinter(message.MatchLanguage("en"))
    p.Println(123456.78) 
}
' > hello.go

# sync
go mod -sync 

Output:

go: finding golang.org/x/text/message latest
go: finding golang.org/x/text v0.3.0
go: import "github.com/example/my-project" ->
	import "golang.org/x/text/message": cannot find module providing package golang.org/x/text/message

Thanks,
Lance

@agnivade

This comment has been minimized.

Copy link
Member

commented Jul 26, 2018

I am guessing due to git version 2.7 which is there in 16.04. The fix for that is in latest master. Either try with master or wait for an RC to get out.

@lancerushing

This comment has been minimized.

Copy link

commented Jul 26, 2018

Didn't get a chance to try master, but I was able to fix it by upgrading git from 2.7.4 to 2.18.0

On the same container:

apt-get install software-properties-common
add-apt-repository ppa:git-core/ppa
apt update
apt upgrade git

Thank you again.
Lance

@alwindoss

This comment has been minimized.

Copy link

commented Nov 22, 2018

is the fix available in 1.11.2? if not in which release would this be available?
Until it is released, what is the workaround for this issue?

@agnivade

This comment has been minimized.

Copy link
Member

commented Nov 22, 2018

is the fix available in 1.11.2?

Yes.

@alwindoss

This comment has been minimized.

Copy link

commented Nov 23, 2018

I installed go 1.11.2 however, I still get the following error

> go build
go: finding github.com/aws/aws-sdk-go/service/sqs latest
go: finding github.com/aws/aws-sdk-go/service/sqs/sqsiface latest
go: finding github.com/aws/aws-sdk-go/internal/ini latest
go: finding github.com/aws/aws-sdk-go/internal/shareddefaults latest
go: finding github.com/aws/aws-sdk-go/internal/sdkio latest
go: finding github.com/aws/aws-sdk-go/internal/sdkuri latest
go: finding github.com/aws/aws-sdk-go/internal/sdkrand latest
go: finding github.com/aws/aws-sdk-go/service/sts latest
go: finding github.com/aws/aws-sdk-go/service latest
go: finding github.com/aws/aws-sdk-go/internal latest
..\..\go\pkg\mod\github.com\aws\aws-sdk-go@v1.15.81\aws\credentials\shared_credentials_provider.go:8:2: unknown import path "github.com/aws/aws-sdk-go/internal/ini": cannot find module providing package github.com/aws/aws-sdk-go/internal/ini
..\..\go\pkg\mod\github.com\aws\aws-sdk-go@v1.15.81\aws\types.go:7:2: unknown import path "github.com/aws/aws-sdk-go/internal/sdkio": cannot find module providing package github.com/aws/aws-sdk-go/internal/sdkio
..\..\go\pkg\mod\github.com\aws\aws-sdk-go@v1.15.81\aws\client\default_retryer.go:8:2: unknown import path "github.com/aws/aws-sdk-go/internal/sdkrand": cannot find module providing package github.com/aws/aws-sdk-go/internal/sdkrand
..\..\go\pkg\mod\github.com\aws\aws-sdk-go@v1.15.81\aws\ec2metadata\api.go:12:2: unknown import path "github.com/aws/aws-sdk-go/internal/sdkuri": cannot find module providing package github.com/aws/aws-sdk-go/internal/sdkuri
..\..\go\pkg\mod\github.com\aws\aws-sdk-go@v1.15.81\aws\credentials\shared_credentials_provider.go:9:2: unknown import path "github.com/aws/aws-sdk-go/internal/shareddefaults": cannot find module providing package github.com/aws/aws-sdk-go/internal/shareddefaults
main.go:4:2: unknown import path "github.com/aws/aws-sdk-go/service/sqs": cannot find module providing package github.com/aws/aws-sdk-go/service/sqs
pkg\messaging\messaging.go:4:2: unknown import path "github.com/aws/aws-sdk-go/service/sqs/sqsiface": cannot find module providing package github.com/aws/aws-sdk-go/service/sqs/sqsiface
..\..\go\pkg\mod\github.com\aws\aws-sdk-go@v1.15.81\aws\credentials\stscreds\assume_role_provider.go:89:2: unknown import path "github.com/aws/aws-sdk-go/service/sts": cannot find module providing package github.com/aws/aws-sdk-go/service/sts
@agnivade

This comment has been minimized.

Copy link
Member

commented Nov 23, 2018

Note that your git version still needs to be greater than 1.7.2. If it is, then this is most probably a different issue. Please open a new bug with the exact steps to reproduce your issue. Thank you.

@alwindoss

This comment has been minimized.

Copy link

commented Nov 23, 2018

@agnivade yes the git version is 2.16.1.windows.4.
I can open a new defect for this. But, the error still is the same, do we want to open a new defect or reopen this issue and track it here?

@agnivade

This comment has been minimized.

Copy link
Member

commented Nov 23, 2018

Please open a new issue. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.