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

Go modules bug #35

Open
solher opened this issue Mar 5, 2019 · 13 comments
Open

Go modules bug #35

solher opened this issue Mar 5, 2019 · 13 comments

Comments

@solher
Copy link

solher commented Mar 5, 2019

When trying to go get go-colorable from gopkg, I'm currently getting this message (using Go 1.12):

go get -u gopkg.in/mattn/go-colorable.v0
go: gopkg.in/mattn/[email protected]: go.mod has non-....v0 module path "github.com/mattn/go-colorable" at revision v0.1.1
go get: error loading module requirements

It seems to me like there is some kind of conflict between the gopkg.in/mattn/go-colorable.v0 actual package path and the name of the module declared in the go.mod file github.com/mattn/go-colorable.

For now, forcing the use of the lib without the go.mod file in it solves the issue:

go get -u gopkg.in/mattn/[email protected]
go: finding gopkg.in/mattn/go-colorable.v0 v0.1.0
go: downloading gopkg.in/mattn/go-colorable.v0 v0.1.0
go: extracting gopkg.in/mattn/go-colorable.v0 v0.1.0
@tych0
Copy link

tych0 commented Mar 6, 2019

FWIW, I've hit this too. For me it's an indirect dep (i.e. the line go is complaining about in go.mod doesn't exist at all; it just exists in go.sum), and it seems your trick doesn't work:

go get -u gopkg.in/mattn/[email protected]
go: gopkg.in/mattn/[email protected]: go.mod has non-....v0 module path "github.com/mattn/go-colorable" at revision v0.1.1
go get: error loading module requirements

@tych0
Copy link

tych0 commented Mar 6, 2019

I filed golang/go#30636, let's see what they say.

@jeanlucmongrain
Copy link

same thing with gopkg.in/mattn/go-isatty.v0 not a coincidence...

@directionless
Copy link

FWIW the go bugs suggest it's an issue in the go.mod file or versions here, and that you can use a version that predates this issue. Adding an override to go.mod helped.

replace gopkg.in/mattn/go-colorable.v0 => github.com/mattn/go-colorable v0.1.0

replace gopkg.in/mattn/go-isatty.v0 => github.com/mattn/go-isatty v0.0.6

@cmaglie
Copy link

cmaglie commented May 30, 2019

Looks like the problem is in the go.mod file that has the wrong import path:

module github.com/mattn/go-colorable

it should be:

 module gopkg.in/mattn/go-colorable.v0 

the same import should be fixed on go-isatty too I think.

@mattn
Copy link
Owner

mattn commented May 30, 2019

I don't use gopkg. So this is not a bug.

@cmaglie
Copy link

cmaglie commented May 30, 2019

The problem is with go mod not gopkg.

Here the steps to reproduce:

~/Workspace/test$ go mod init test
go: creating new go.mod: module test

~/Workspace/test$ cat > main.go
package main

import "gopkg.in/mattn/go-colorable.v0"

func main() {
}

~/Workspace/test$ go build
go: downloading gopkg.in/mattn/go-colorable.v0 v0.1.2
build test: cannot load gopkg.in/mattn/go-colorable.v0: cannot find module providing package gopkg.in/mattn/go-colorable.v0

@cmaglie
Copy link

cmaglie commented May 30, 2019

ah, now I see what you mean, I must import:

import "github.com/mattn/go-colorable"

instead of:

import "gopkg.in/mattn/go-colorable.v0"

that solved the issue for me.
Thanks!

@azilber
Copy link

azilber commented Jun 23, 2019

Having the same issue using with go and vgo.

$ go fmt
go: downloading gopkg.in/mattn/go-colorable.v0 v0.1.2
go: downloading gopkg.in/mattn/go-isatty.v0 v0.0.8
build consultent/noodle-node: cannot find module for path gopkg.in/mattn/go-colorable.v0

I'm not sure why it's trying to get it from gopkg.in. I have
require "github.com/mattn/go-colorable" in both the go file, and go.mod

I'd rather not move my code under $GOPATH/src

EDIT/UPDATE:

The issue is just mod related, setting GO111MODULE=on will create this issue.
I've tried wiping out the cache (using go clean -cache -modcache )
and when doing go fmt I get this:

$ go fmt

go: creating new go.mod: module consultent/noodle-node
go: finding github.com/rburmorrison/go-argue latest
go: finding github.com/mattn/go-isatty v0.0.8
go: finding github.com/keimoon/gore latest
go: finding github.com/mattn/go-runewidth v0.0.4
go: finding github.com/mattn/go-colorable v0.1.2
go: finding github.com/mattn/go-sqlite3 v1.10.0
go: finding github.com/cheggaaa/pb v2.0.6+incompatible
go: downloading github.com/cheggaaa/pb v2.0.6+incompatible
go: extracting github.com/cheggaaa/pb v2.0.6+incompatible
go: downloading github.com/mattn/go-colorable v0.1.2
go: downloading github.com/mattn/go-isatty v0.0.8
go: extracting github.com/mattn/go-colorable v0.1.2
go: extracting github.com/mattn/go-isatty v0.0.8
go: downloading github.com/mattn/go-runewidth v0.0.4
go: downloading github.com/rburmorrison/go-argue v0.0.0-20190107184430-e164876050e3
go: extracting github.com/mattn/go-runewidth v0.0.4
go: extracting github.com/rburmorrison/go-argue v0.0.0-20190107184430-e164876050e3
go: downloading github.com/keimoon/gore v0.0.0-20160317032603-1ac8b93b5fdb
go: extracting github.com/keimoon/gore v0.0.0-20160317032603-1ac8b93b5fdb
go: downloading github.com/mattn/go-sqlite3 v1.10.0
go: extracting github.com/mattn/go-sqlite3 v1.10.0
go: finding golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223
go: finding gopkg.in/fatih/color.v1 v1.7.0
go: finding gopkg.in/mattn/go-runewidth.v0 v0.0.4
go: finding gopkg.in/VividCortex/ewma.v1 v1.1.1
go: finding gopkg.in/mattn/go-colorable.v0 v0.1.2
go: finding gopkg.in/mattn/go-isatty.v0 v0.0.8
go: finding gopkg.in/cheggaaa/pb.v2 v2.0.6
go: downloading gopkg.in/VividCortex/ewma.v1 v1.1.1
go: extracting gopkg.in/VividCortex/ewma.v1 v1.1.1
go: downloading gopkg.in/mattn/go-colorable.v0 v0.1.2
go: downloading gopkg.in/mattn/go-runewidth.v0 v0.0.4
go: extracting gopkg.in/mattn/go-runewidth.v0 v0.0.4
go: downloading gopkg.in/mattn/go-isatty.v0 v0.0.8
go: downloading gopkg.in/cheggaaa/pb.v2 v2.0.6
go: extracting gopkg.in/cheggaaa/pb.v2 v2.0.6
go: downloading gopkg.in/fatih/color.v1 v1.7.0
go: extracting gopkg.in/fatih/color.v1 v1.7.0
build consultent/noodle-node: cannot load gopkg.in/mattn/go-colorable.v0: cannot find module providing package gopkg.in/mattn/go-colorable.v0

It seems go grabs it from github, but then decides to use gopkg.in

I would like to add that a few months ago, I didn't have this issue (and I tested just now using an earlier version):

These versions have no isssue when used together:
go: finding github.com/mattn/go-isatty v0.0.4
go: finding gopkg.in/mattn/go-isatty.v0 v0.0.4
go: finding gopkg.in/mattn/go-colorable.v0 v0.1.0
go: downloading github.com/mattn/go-isatty v0.0.4
go: downloading gopkg.in/mattn/go-isatty.v0 v0.0.4
go: downloading gopkg.in/mattn/go-colorable.v0 v0.1.0
go: extracting github.com/mattn/go-isatty v0.0.4
go: extracting gopkg.in/mattn/go-isatty.v0 v0.0.4
go: extracting gopkg.in/mattn/go-colorable.v0 v0.1.0

@azilber
Copy link

azilber commented Jun 23, 2019

I just noticed that this was in fact referenced here: #35 (comment)

@sergeyklay
Copy link

@mattn

$ go get gopkg.in/mattn/go-colorable.v0
go: gopkg.in/mattn/[email protected]: parsing go.mod: missing module line
go: error loading module requirements
$ go get gopkg.in/mattn/go-colorable
go: finding gopkg.in latest
go get gopkg.in/mattn/go-colorable: malformed module path "gopkg.in/mattn/go-colorable": invalid version
$ env | grep -e "^GO"
GOBIN=/home/klay/go/bin
GOPROXY=https://goproxy.io
GO111MODULE=on
GOPATH=/home/klay/go
$ go version
go version go1.12.7 linux/amd64

@dolmen
Copy link
Contributor

dolmen commented Mar 22, 2023

Here is a list of modules which incorrectly import this module via gopkg.in:
https://pkg.go.dev/gopkg.in/mattn/go-colorable.v0?tab=importedby

All of them are old forks of github.com/cheegaaa/pb.

The issue in pb has been fixed by cheggaaa/pb#146

@dolmen
Copy link
Contributor

dolmen commented Mar 22, 2023

@mattn Nobody reported on this issue for 3 years. It can be closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants