Skip to content
This repository was archived by the owner on Mar 23, 2021. It is now read-only.
This repository was archived by the owner on Mar 23, 2021. It is now read-only.

"cannot load ...: reading file: ...: Not Found" when installing with a fresh module/build cache #86

@zikaeroh

Description

@zikaeroh

I cleared all of my caches when upgrading to 1.13 the other day, then went to use gobin again and started hitting errors like:

build github.com/fatedier/frp/cmd/frps: cannot load golang.org/x/text/secure/bidirule: golang.org/x/[email protected]: reading file:///home/jake/go/pkg/mod/cache/download/golang.org/x/text/@v/v0.3.2.zip: Not Found
build github.com/golang-migrate/migrate/v4/cmd/migrate: cannot load github.com/lib/pq: github.com/lib/[email protected]: reading file:///home/jake/go/pkg/mod/cache/download/github.com/lib/pq/@v/v1.0.0.zip: Not Found
build golang.org/x/tools/cmd/godoc: cannot load golang.org/x/net/context/ctxhttp: golang.org/x/[email protected]: reading file:///home/jake/go/pkg/mod/cache/download/golang.org/x/net/@v/v0.0.0-20190620200207-3b0461eec859.zip: Not Found

It seems like when you use gobin to install something without any of the caches populated, things break. I can do a go mod download to get everything downloaded and move on as a workaround. Here is a test script that runs using a fresh everything and fails:

#!/bin/sh -xe

tempdir=$(mktemp -d)
mkdir -p $tempdir/{gopath,gocache,gobin,project}

export GOPATH=$tempdir/gopath
export GOCACHE=$tempdir/gocache
export GOBIN=$tempdir/gobin

go env

function cleanup {
    cd /tmp
    go clean -cache -testcache -modcache
    rm -rf $tempdir
}
trap cleanup EXIT

cd $tempdir/project
go mod init project

gobin -m -tags 'postgres' github.com/golang-migrate/migrate/v4/cmd/migrate

Output:

++ mktemp -d
+ tempdir=/tmp/tmp.C7aUPZFL5r
+ mkdir -p /tmp/tmp.C7aUPZFL5r/gopath /tmp/tmp.C7aUPZFL5r/gocache /tmp/tmp.C7aUPZFL5r/gobin /tmp/tmp.C7aUPZFL5r/project
+ export GOPATH=/tmp/tmp.C7aUPZFL5r/gopath
+ GOPATH=/tmp/tmp.C7aUPZFL5r/gopath
+ export GOCACHE=/tmp/tmp.C7aUPZFL5r/gocache
+ GOCACHE=/tmp/tmp.C7aUPZFL5r/gocache
+ export GOBIN=/tmp/tmp.C7aUPZFL5r/gobin
+ GOBIN=/tmp/tmp.C7aUPZFL5r/gobin
+ go env
GO111MODULE=""
GOARCH="amd64"
GOBIN="/tmp/tmp.C7aUPZFL5r/gobin"
GOCACHE="/tmp/tmp.C7aUPZFL5r/gocache"
GOENV="/home/jake/.config/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/tmp/tmp.C7aUPZFL5r/gopath"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/lib/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/lib/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
AR="ar"
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-build400069706=/tmp/go-build -gno-record-gcc-switches"
+ trap cleanup EXIT
+ cd /tmp/tmp.C7aUPZFL5r/project
+ go mod init project
go: creating new go.mod: module project
+ gobin -m -tags postgres github.com/golang-migrate/migrate/v4/cmd/migrate
failed to run go install -tags postgres github.com/golang-migrate/migrate/v4/cmd/migrate: exit status 1
go: downloading github.com/lib/pq v1.0.0
go: finding github.com/hashicorp/go-multierror v1.0.0
go: finding github.com/hashicorp/errwrap v1.0.0
build github.com/golang-migrate/migrate/v4/cmd/migrate: cannot load github.com/lib/pq: github.com/lib/[email protected]: reading file:///tmp/tmp.C7aUPZFL5r/gopath/pkg/mod/cache/download/github.com/lib/pq/@v/v1.0.0.zip: Not Found

+ cleanup
+ cd /tmp
+ go clean -cache -testcache -modcache
+ rm -rf /tmp/tmp.C7aUPZFL5r

However, I can replace gobin -m with go install, and that will successfully run.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions