Skip to content

go build runtime/cgo: open /usr/local/go/pkg/linux_amd64/runtime/cgo.a: permission denied #15

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

Closed
dionysius opened this issue Oct 29, 2018 · 3 comments

Comments

@dionysius
Copy link

dionysius commented Oct 29, 2018

I don't know how this happened, I was using update-golang.sh a while and was always good. Can't remember which golang version I was when this error happened, so I was thinking, give the update a go. The following commands are after installing 1.11.1 already.

Installing:

myuser@nb-myuser:~/Projects/go/src/github.com/udhos/update-golang$ sudo ./update-golang.sh 
[sudo] password for myuser: 
update-golang.sh: version 0.17
update-golang.sh: find_latest: found last release: 1.11.1
update-golang.sh: user: uid=0(root) gid=0(root) groups=0(root)
update-golang.sh: RELEASE_LIST=https://golang.org/doc/devel/release.html
update-golang.sh: SOURCE=https://storage.googleapis.com/golang
update-golang.sh: DESTINATION=/usr/local
update-golang.sh: RELEASE=1.11.1
update-golang.sh: OS=linux
update-golang.sh: ARCH_PROBE=uname -m
update-golang.sh: ARCH=amd64
update-golang.sh: PROFILED=/etc/profile.d/golang_path.sh
update-golang.sh: CACHE=/usr/local
update-golang.sh: GOPATH=
update-golang.sh: DEBUG=
update-golang.sh: will install golang go1.11.1.linux-amd64 as: /usr/local/go
update-golang.sh: https://storage.googleapis.com/golang/go1.11.1.linux-amd64.tar.gz is remote
update-golang.sh: no need to download - file cached: /usr/local/go1.11.1.linux-amd64.tar.gz
update-golang.sh: remove_old_link: found symlink for old install: /usr/local/go1.11.1.linux-amd64
update-golang.sh: untar: rm_dir /usr/local/go1.11.1.linux-amd64
update-golang.sh: untar: tar -x -f /usr/local/go1.11.1.linux-amd64.tar.gz
update-golang.sh: path: removing old settings from: /etc/profile.d/golang_path.sh
update-golang.sh: path: issuing new /usr/local/go/bin to /etc/profile.d/golang_path.sh
update-golang.sh: path: issuing /home/myuser/go/bin to /etc/profile.d/golang_path.sh
update-golang.sh: golang go1.11.1.linux-amd64 installed at: /usr/local/go
update-golang.sh: testing: /usr/local/go/bin/go version
update-golang.sh: go version go1.11.1 linux/amd64
update-golang.sh: /usr/local/go/bin/go version: SUCCESS
update-golang.sh: testing: /usr/local/go/bin/go run /tmp/hello-tmpEMefkQLD.go
update-golang.sh: hello, world
update-golang.sh: /usr/local/go/bin/go run /tmp/hello-tmpEMefkQLD.go: SUCCESS
update-golang.sh: running_as_root: yes
update-golang.sh: recursively forcing build cache [/home/myuser/.cache/go-build] ownership to 1000:1000
update-golang.sh: cleanup: /tmp/tmp.vm4MxFOfkz

Build a project:

myuser@nb-myuser:~/Projects/go/src/github.com/udhos/update-golang$ cd ~/Projects/go/src/example.io/somegroup/somerepo/
myuser@nb-myuser:~/Projects/go/src/example.io/somegroup/somerepo$ go build -i -o bin/srvdef ./cmd/srvdef
go build runtime/cgo: open /usr/local/go/pkg/linux_amd64/runtime/cgo.a: permission denied
make: *** [build] Error 1

go info:

myuser@nb-myuser:~/Projects/go/src/example.io/somegroup/somerepo$ cd
myuser@nb-myuser:~$ go env
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/myuser/.cache/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/myuser/Projects/go"
GOPROXY=""
GORACE=""
GOROOT="/usr/local/go"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD=""
CGO_CFLAGS="-I/home/myuser/Projects/go/deps/sqlite/ -I/home/myuser/Projects/go/deps/dqlite/include/"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-L/home/myuser/Projects/go/deps/sqlite/.libs/ -L/home/myuser/Projects/go/deps/dqlite/.libs/"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build757453316=/tmp/go-build -gno-record-gcc-switches"
myuser@nb-myuser:~$ go version
go version go1.11.1 linux/amd64

Persmissions look good to me:

myuser@nb-myuser:~$ ls -lah /usr/local/go
lrwxrwxrwx 1 root root 31 Okt 29 16:41 /usr/local/go -> /usr/local/go1.11.1.linux-amd64
myuser@nb-myuser:~$ ls -lah /usr/local/go/pkg
...
drwxr-xr-x 29 root root 4.0K Okt  1 23:15 linux_amd64
...
myuser@nb-myuser:~$ ls -lah /usr/local/go/pkg/linux_amd64
...
drwxr-xr-x  4 root root 4.0K Okt  1 23:04 runtime
...
myuser@nb-myuser:~$ ls -lah /usr/local/go/pkg/linux_amd64/runtime
...
-rw-r--r--  1 root root  95K Okt  1 23:04 cgo.a
...
@dionysius
Copy link
Author

I tried different go versions, and I found out the following:

go1.9 ok:

myuser@nb-myuser:~/Projects/go/src/github.com/udhos/update-golang$ sudo RELEASE=1.9 ./update-golang.sh
...
myuser@nb-myuser:~/Projects/go/src/example.io/somegroup/somerepo$ go version
go version go1.9 linux/amd64
myuser@nb-myuser:~/Projects/go/src/example.io/somegroup/somerepo$ go build -i -o bin/srvdef ./cmd/srvdef

go1.10 has the same error:

myuser@nb-myuser:~/Projects/go/src/github.com/udhos/update-golang$ sudo RELEASE=1.10 ./update-golang.sh
...
myuser@nb-myuser:~/Projects/go/src/example.io/somegroup/somerepo$ go version
go version go1.10 linux/amd64
myuser@nb-myuser:~/Projects/go/src/example.io/somegroup/somerepo$ go build -i -o bin/srvdef ./cmd/srvdef
go build runtime/cgo: open /usr/local/go/pkg/linux_amd64/runtime/cgo.a: permission denied
make: *** [build] Error 1

A idea what to look for?

@udhos
Copy link
Owner

udhos commented Oct 29, 2018

Sorry, I have no idea to suggest.

However I found this issue: golang/go#25138

When I try to use the "net/http" package in a file go build -i prints the following error go build runtime/cgo: open /usr/local/go/pkg/linux_amd64/runtime/cgo.a: permission denied. If I just run go build without -i or if I downgrade to Go 1.9.5 and run the command the error does not appear and everything builds without errors.

It seems the build operation is trying to overwrite the original cgo.a file provided by the Go binary install.

Can you try to build without the -i flag ?

@dionysius
Copy link
Author

Wow, good catch! I already looked around but I may have missed that. without -i is indeed working. I think also that -i is obsolete in my case, since the project has vendoring, so no need to download and install anything ("The -i flag installs the packages that are dependencies of the target.")

So then, sorry for bothering. Thank you

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

2 participants