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: repeated, unhelpful errors when module cache can't be created #45113

Closed
jayconrod opened this issue Mar 18, 2021 · 5 comments
Closed
Labels
FrozenDueToAge GoCommand cmd/go NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@jayconrod
Copy link
Contributor

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

$ go version
go1.16.2

Does this issue reproduce with the latest release?

yes

What operating system and processor architecture are you using (go env)?

go env Output
$ go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/jayconrod/Library/Caches/go-build"
GOENV="/Users/jayconrod/Library/Application Support/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOINSECURE=""
GOMODCACHE="/does/not/exist/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="darwin"
GOPATH="/does/not/exist"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/opt/go/installed"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/opt/go/installed/pkg/tool/darwin_amd64"
GOVCS=""
GOVERSION="go1.16.2"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/dev/null"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -arch x86_64 -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/rq/x0692kqj6ml8cvrhcqh5bswc008xj1/T/go-build3704992266=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

Set environment variables such that the module cache directory can't be created as a directory. In this example below, I've explicitly set GOMODCACHE to a path I don't have access to.

export GOMODCACHE=/does/not/exist
go install golang.org/x/tools/gopls@latest

This came up in this golang-nuts thread. In that example, neither GOPATH nor GOMODCACHE was set, so GOMODCACHE defaulted to $HOME/go/pkg/mod, but $HOME/go is not a directory.

What did you expect to see?

An error message that explains what the problem is and how to fix it, printed once.

What did you see instead?

An unhelpful message, printed multiple times.

$ go install golang.org/x/tools/gopls@latest
go: writing stat cache: mkdir /does: read-only file system
go: writing stat cache: mkdir /does: read-only file system
go: writing go.mod cache: mkdir /does: read-only file system
go: downloading golang.org/x/tools/gopls v0.6.8
go: writing go.mod cache: mkdir /does: read-only file system
go: downloading golang.org/x/tools v0.1.0
go install golang.org/x/tools/gopls@latest: mkdir /does: read-only file system
@jayconrod jayconrod added the NeedsFix The path to resolution is known, but the work has not been done. label Mar 18, 2021
@jayconrod jayconrod added this to the Go1.17 milestone Mar 18, 2021
@oiooj oiooj added the GoCommand cmd/go label Mar 19, 2021
@gopherbot
Copy link

Change https://golang.org/cl/304571 mentions this issue: cmd/go: display helpful error when module cache can't be created

@atilkan
Copy link

atilkan commented Nov 22, 2021

Bad bot.

@wenjoy
Copy link

wenjoy commented Feb 2, 2022

This issue should not be closed. I also encountered this problem and have no idea of solving it.

@mashaole
Copy link

i also have the same problem i cant install go commands on vs code such as gopls

@mashaole
Copy link

mashaole commented Feb 15, 2022

8 packages failed to install on vscode so i found a solution which is add these lines to your bash_profile, .bash_profile, .zshrc ,.zprofile:

export GOPATH=$HOME/go
export PATH=$PATH:$GOPATH/bin

after that only 2 packages failed after this so i just typed in go get -u github.com/ramya-rao-a/go-outline

and it solved the problem

@golang golang locked and limited conversation to collaborators Feb 15, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge GoCommand cmd/go NeedsFix The path to resolution is known, but the work has not been done.
Projects
None yet
Development

No branches or pull requests

6 participants