Go-sqlite3: cannot load github.com/mattn/go-sqlite3: module github.com/mattn/go-sqlite3@latest (v2.0.0+incompatible) found, but does not contain package github.com/mattn/go-sqlite3

Created on 13 Nov 2019  路  29Comments  路  Source: mattn/go-sqlite3

This package doesn't seem to work with go modules. Here's a simple recipe in Docker, to make it easy to reproduce. Please tell me what I'm doing wrong:

$ docker run -it --rm golang:alpine
/go # apk add build-base
...
/go # mkdir /src
/go # cd /src
/src # cat - > main.go
package main
import (
        "fmt"
    _ "github.com/mattn/go-sqlite3"
)
func main() {
    fmt.Println("Hello world!")
}
/src # export CGO_ENABLED=1
/src # go mod init example.com
go: creating new go.mod: module example.com
/src # go get github.com/mattn/go-sqlite3
go: finding github.com/mattn/go-sqlite3 v2.0.0+incompatible
go: downloading github.com/mattn/go-sqlite3 v2.0.0+incompatible
go: extracting github.com/mattn/go-sqlite3 v2.0.0+incompatible
/src # go run .
build example.com: cannot load github.com/mattn/go-sqlite3: module github.com/mattn/go-sqlite3@latest (v2.0.0+incompatible) found, but does not contain package github.com/mattn/go-sqlite3

Most helpful comment

I will keep this issue open until we will find a fundamental solution for this issue.

All 29 comments

Fixed.

I am having the same issue on osx. Here are my go environment variables:

GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/olivertome/Library/Caches/go-build"
GOENV="/Users/olivertome/Library/Application Support/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GONOPROXY=""
GONOSUMDB=""
GOOS="darwin"
GOPATH="/Users/olivertome/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/Cellar/go/1.13.4/libexec"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/Cellar/go/1.13.4/libexec/pkg/tool/darwin_amd64"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
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 -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/n0/h862x6s55wdb9kz1qfsv0__80000gn/T/go-build897009201=/tmp/go-build -gno-record-gcc-switches -fno-common"

Running go install github.com/mattn/go-sqlite3 results in the same error.

Please try -u

What was the issue exactly ?
It still fails for me.
Is there a wrong version published in the official modules proxy ?

https://proxy.golang.org/github.com/mattn/go-sqlite3/@v/list
it reports a version v2.0.0+incompatible

The cause of this issue is that this repository had topic branch v2.0.0. So I removed it. Please remove local cache with -u.

Still happening.

I guess that proxy.golang.org has cached the invalid version.

@pierrre I think so too. But it means new users will always get the error?

I worked it around by appending to go.mod:

replace github.com/mattn/go-sqlite3 => ./vendor/github.com/mattn/go-sqlite3

Then cloning the repository locally and adding a go.mod in there (it can be created with go mod init github.com/mattn/go-sqlite3):

module github.com/mattn/go-sqlite3

go 1.12

I suggest adding the go.mod file here on go-sqlite3 for a longer term solution; on a side node, the proxy should be more explicit about its operations when building, but it's not from what I can see.

@gdm85 or maybe you can just add github.com/mattn/go-sqlite3 to GOPRIVATE

I believe this tag is breaking compatibility when imported by a Go module. I can see an issue trying to go get -u github.com/rubenv/sql-migrate/sql-migrate

build github.com/rubenv/sql-migrate/sql-migrate: cannot load github.com/mattn/go-sqlite3: module github.com/mattn/go-sqlite3@latest found (v2.0.0+incompatible), but does not contain package github.com/mattn/go-sqlite3

Sorry, but I will NOT release v2.0.1 or higher just to fix this issue.

Sorry, but I will NOT release v2.0.1 or higher just to fix this issue.

It's a shame that you won't follow the Go modules convention 馃槥

Because the broken tag was a topic branch (not git tag) created before the go module was supported. We don't have mistake. I don't understand the reason for vote down.

Should we ask maintainers of proxy.golang.org to purge the cache ?

They say adding go.mod should fix this.

I will keep this issue open until we will find a fundamental solution for this issue.

@posener it requires Go 1.14

If you want to solve this issue immediately, please try to do in your repository (Do NOT run it outside of your repository)

go get -u github.com/mattn/[email protected]

@mattn the problem is that I run go get -u all once a week in order to update all my dependencies.
I think it's doing a query to proxy.golang.org, and it will see the invalid version.

IMO the simplest fix is

add github.com/mattn/go-sqlite3 to GOPRIVATE

@pierrre I think so too. But it means new users will always get the error?

I worked it around by appending to go.mod:

replace github.com/mattn/go-sqlite3 => ./vendor/github.com/mattn/go-sqlite3

Then cloning the repository locally and adding a go.mod in there (it can be created with go mod init github.com/mattn/go-sqlite3):

module github.com/mattn/go-sqlite3

go 1.12

I suggest adding the go.mod file here on go-sqlite3 for a longer term solution; on a side node, the proxy should be more explicit about its operations when building, but it's not from what I can see.

I have question here, what is ./vendor directory?? can you give me detailed explanation of how this works?? I am new to go and cfssl. I just used the go get command provided. and it landed me on to this error. would appreciate it if you can help me a little

@velurinavya the vendor directory is just a directory that contains the source code for all the dependencies in your project. The idea is that anyone who wants to use your code no longer has to manage dependencies because they are already included in the project.

The replace command in the go.mod file tells the go package manager to look for the dependency go-sqlite3 on the vendor directory as opposed of the proxy server maintained by Google, which is the default. To solve this problem you just have to clone this GitHub repo inside of your own vendor directory and tell the go package manager to look for this package inside that directory.

Or just do as @pierrre mentioned and add the url of this repo to your GOPRIVATE environment variable, this is quickest solution.

Bypassing the proxy and going direct helped me resolve this issue with a binary install.

eg.

GOPROXY=direct go get -u github.com/volatiletech/sqlboiler-sqlite3

@mattn this high profile package is currently broken:

$ mkdir foobar
$ cd foobar
$ go mod init
go: creating new go.mod: module foobar
$ cat <<EOF > main.go
> package main
> import (
>   "fmt"
>   "github.com/mattn/go-sqlite3"
> )
> 
> func main() {
>   fmt.Println("foobar")
> }
> EOF
$ go build
build foobar: cannot load github.com/mattn/go-sqlite3: module github.com/mattn/go-sqlite3@latest found (v2.0.0+incompatible), but does not contain package github.com/mattn/go-sqlite3
$ 

Could you please release a new version that fixes it?

I asked on Go' issues, But no any replies for about fixing this issue. So I'll add new tag in later.

Now tagged v2.0.1. Your issues will be fixed with go get -u github.com/mattn/go-sqlite3. However I don't close this issue until https://github.com/golang/go/issues/35671 will be fixed.

@mattn just a suggestion: maybe you should point this tag v2.0.x to an empty branch ?
=> people will never use it

PS: you could include a message to the readme pointing to this issue.

I tagged v1.14.0 for latest release. If you are using v2.0.3 already, please use v1.14.0 instead.

See https://github.com/mattn/go-sqlite3/issues/812#issuecomment-644147425

Was this page helpful?
0 / 5 - 0 ratings

Related issues

mhat picture mhat  路  7Comments

hackertron picture hackertron  路  10Comments

dylanlyu picture dylanlyu  路  6Comments

tiaguinho picture tiaguinho  路  3Comments

barnettZQG picture barnettZQG  路  7Comments