Skip to content

cmd/go: cannot find module providing package #26353

Closed
@sneko

Description

@sneko

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 😃

Activity

added this to the vgo milestone on Jul 12, 2018
modified the milestones: vgo, Go1.11 on Jul 12, 2018
changed the title [-]x/vgo: cannot find module providing package[/-] [+]cmd/go: cannot find module providing package[/+] on Jul 12, 2018
tobiaskohlbau

tobiaskohlbau commented on Jul 13, 2018

@tobiaskohlbau

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

rsc commented on Jul 17, 2018

@rsc
Contributor

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.)

sneko

sneko commented on Jul 18, 2018

@sneko
Author

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

Thanks for your work 😃

lancerushing

lancerushing commented on Jul 26, 2018

@lancerushing

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

agnivade commented on Jul 26, 2018

@agnivade
Contributor

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

lancerushing commented on Jul 26, 2018

@lancerushing

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

alwindoss commented on Nov 22, 2018

@alwindoss
Contributor

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

agnivade commented on Nov 22, 2018

@agnivade
Contributor

is the fix available in 1.11.2?

Yes.

7 remaining items

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @rsc@tobiaskohlbau@lancerushing@alwindoss@agnivade

        Issue actions

          cmd/go: cannot find module providing package · Issue #26353 · golang/go