-
Notifications
You must be signed in to change notification settings - Fork 18k
x/vuln: Does not use the correct GOPATH: Index(): mkdir /pkg: permission denied #57406
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
Comments
@golang/vulndb |
What does the Go standard tooling tell you? Does it produce a warning? I am asking as I have a problem reproducing this. |
Change https://go.dev/cl/459036 mentions this issue: |
The Here is a complete reproduction script on a clean Ubuntu 20.04 LTS container: Start the container with: Script to run in the container: # install curl
apt update
apt install --yes curl
# create a normal user account and run the rest of the commands as that user
useradd --create-home normaluser --shell /bin/bash
su --login normaluser
# install Go 1.19.4
curl --location https://go.dev/dl/go1.19.4.linux-amd64.tar.gz | tar xz
export PATH=$PATH:$HOME/go/bin
# get latest govulncheck
go install golang.org/x/vuln/cmd/govulncheck@latest
# create a program with a third-party dependency
mkdir exampleprogram
cd exampleprogram
go mod init example.com/exampleprogram
cat > main.go <<END_PROGRAM
package main
import (
"fmt"
"golang.org/x/text/unicode/runenames"
)
func main() {
fmt.Printf("name for a: %s\n", runenames.Name('r'))
}
END_PROGRAM
go get golang.org/x/text/unicode/runenames
# run the program with Go tools (works)
go test ./...
go run .
# run govulncheck (does not work)
govulncheck ./...
# run govulncheck with explicit GOPATH (works)
echo "GOPATH?" $(go env GOPATH)
GOPATH=/home/normaluser/go govulncheck ./...
Example output I get when I run this (with a lot of output removed)
|
What are the contents of the |
On my personal Linux desktop it contains:
In the clean Ubuntu container reproduction example the file |
Thanks for the very detailed reproduction instructions! The fix should now be in. At the very least, I was able to follow reproduction steps without them resulting in an error/panic:
|
Confirmed that this fixes my issue! Thanks for the rapid response! |
Before, an approach with build.Default.GOPATH was used, which is incorrect. Fixes golang/go#57406 Change-Id: I821e9b1a762f2b7eca5b6006e00c7929d115e6cf Reviewed-on: https://go-review.googlesource.com/c/vuln/+/459036 TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Jonathan Amsterdam <jba@google.com> Run-TryBot: Zvonimir Pavlinovic <zpavlinovic@google.com>
Before, an approach with build.Default.GOPATH was used, which is incorrect. Fixes golang/go#57406 Change-Id: I821e9b1a762f2b7eca5b6006e00c7929d115e6cf Reviewed-on: https://go-review.googlesource.com/c/vuln/+/459036 TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Jonathan Amsterdam <jba@google.com> Run-TryBot: Zvonimir Pavlinovic <zpavlinovic@google.com>
Before, an approach with build.Default.GOPATH was used, which is incorrect. Fixes golang/go#57406 Change-Id: I821e9b1a762f2b7eca5b6006e00c7929d115e6cf Reviewed-on: https://go-review.googlesource.com/c/vuln/+/459036 TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Jonathan Amsterdam <jba@google.com> Run-TryBot: Zvonimir Pavlinovic <zpavlinovic@google.com>
Summary: I have no Go-related environment variables set, other than putting the Go tools in
PATH
. Go tools work, butgovulncheck
seems to try to cache files in the wrong place, and reports:govulncheck: vulncheck.Source: GetByModule("google.golang.org/protobuf"): httpSource.GetByModule("google.golang.org/protobuf"): Index(): mkdir /pkg: permission denied
. The workaround is to explicitly setting theGOPATH
environment variable:GOPATH=$(go env GOPATH) govulncheck ./...
.What version of Go are you using (
go version
)?Does this issue reproduce at the latest version of golang.org/x/vuln?
Yes. Specifically I ran:
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
I ran:
govulncheck ./...
in this repository: https://github.com/evanj/hacksWhat did you expect to see?
I expected to see some valid output.
What did you see instead?
The problem is I have no Go related environment variables set, other than PATH:
To fix this error, I can explicitly set GOPATH, and run this tool with:
GOPATH=$(go env GOPATH) govulncheck ./...
. This works as expected.My understanding is that Go tools should no longer require setting GOPATH.
The text was updated successfully, but these errors were encountered: