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

golangci-lint fails because it cannot find go in $PATH #464

Open
shackra opened this issue Jun 20, 2024 · 3 comments
Open

golangci-lint fails because it cannot find go in $PATH #464

shackra opened this issue Jun 20, 2024 · 3 comments
Labels
flake Related to running in pure environments

Comments

@shackra
Copy link

shackra commented Jun 20, 2024

This happens when running nix flake check.

golangci-lint............................................................Failed
- hook id: golangci-lint
- exit code: 3

WARN Failed to discover go env: failed to run 'go env -json GOCACHE GOROOT': exec: "go": executable file not found in $PATH
ERRO Running error: context loading failed: failed to load packages: failed to load packages: failed to load with go/packages: err: go command required, not found: exec: "go": executable file not found in $PATH: stderr:

This may be related to the fact that flakes do not admit environment variables. It goes well as a pre-commit-hook, thought.

@sandydoo sandydoo added the flake Related to running in pure environments label Jul 9, 2024
@shackra
Copy link
Author

shackra commented Oct 18, 2024

still failing :(

@matdibu
Copy link

matdibu commented Nov 12, 2024

same issue here

using

$ nix develop .#git-hooks --ignore-environment

I get into an env that has go, but I'm fairly certain it's from the previous shell

using

$ nix develop .#git-hooks --unset PATH

I can no longer use go

for reference, the git-hooks dev shell is just an alias for the one from pre-commit:

devShells.git-hooks = config.pre-commit.devShell;

@matdibu
Copy link

matdibu commented Nov 12, 2024

using

golangci-lint = {
  enable = true;
  extraPackages = [ pkgs.go pkgs.which ];
};

I get the go binary which looks correct

$ which go
/nix/store/jyhpd4hgq672bm4m4s1r25zm1bx8vd44-go-1.23.2/bin/go

but nix flake check still fails because it can't find go during golangci-lint

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
flake Related to running in pure environments
Projects
None yet
Development

No branches or pull requests

3 participants