Describe the bug
Inside nix-shell -p go, I see GOPATH=/nix/store/1r61f7iwqfb6dm1krqpj9cjfifjnfmjx-go-1.14.2/share/go in the environment. Then when I try to use go mod to grab some dependencies, I get Permission denied because that path is not writable. Unsetting GOPATH makes things work again.
To Reproduce
Steps to reproduce the behavior:
go mod (in my case, I ran test.sh from https://github.com/PowerDNS/go-dnsdist-client)Expected behavior
Go manages to download and use dependencies.
Screenshots
go: writing go.mod cache: mkdir /nix/store/1r61f7iwqfb6dm1krqpj9cjfifjnfmjx-go-1.14.2/share/go/pkg/mod: permission denied
Additional context
go says warning: GOPATH set to GOROOT (/nix/store/1r61f7iwqfb6dm1krqpj9cjfifjnfmjx-go-1.14.2/share/go) has no effect which evidently is a lie, as unsetting GOPATH makes a difference
Notify maintainers
cc @adisbladis (requested via IRC)
Metadata
Please run nix-shell -p nix-info --run "nix-info -m" and paste the result.
- system: `"x86_64-linux"`
- host os: `Linux 5.5.0-0.bpo.2-amd64, Debian GNU/Linux, 10 (buster)`
- multi-user?: `no`
- sandbox: `no`
- version: `nix-env (Nix) 2.3.6`
- channels(peter): `"nixpkgs-20.09pre226586.571212eb839"`
- nixpkgs: `/home/peter/.nix-defexpr/channels/nixpkgs`
Maintainer information:
# a list of nixpkgs attributes affected by the problem
attribute:
# a list of nixos modules affected by the problem
module:
I think this was fixed by a1e13f6140a568b73c1c36bb9ef79d7876ccaae3, it should be available via channels soon.
cc @Mic92
Should backport it as well?
Note generally speaking this is a problem with nix-shell that it executes hooks that are needed during build-time, while they're typically not needed during run-time.
Note generally speaking this is a problem with
nix-shellthat it executes hooks that are needed during build-time, while they're typically not needed during run-time.
We don't need GOPATH for building. It was introduced historically for nix-shell usage. buildGoModule and buildGoPackage have their own mechanism for bringing packages into scope.
This is fixed in unstable and 20.03.