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

Cabal tries to rebuild build-tool-depends in Nix shells where they are already provided #8492

Closed
lf- opened this issue Sep 25, 2022 · 3 comments

Comments

@lf-
Copy link
Collaborator

lf- commented Sep 25, 2022

Describe the bug

When I invoke cabal test, cabal tries to build hspec-discover. This is deeply mysterious to me, since it is listed in ghc-pkg dump | rg -C10 hspec-discover on account of Nix putting it there.

I think a possible cause is that that's just the library and not the executable, but the Nix infrastructure will dump the executable into the PATH if it's in build-tool-depends (cabal2nix will ensure this).

So I'm filing this bug because this means I can either have build-tools and have it do pointless work in a Nix shell (but notably not when Nix invokes the testsuite as part of a build, since it invokes it with ./Setup test), or have the build of tests fail outside a Nix shell.

To Reproduce

Clone https://github.com/lf-/cabal-build-tools-repro

co/cabal-repro - [main] » nix develop --extra-experimental-features "flakes nix-command" -c cabal v2-test  
warning: Using saved setting for 'allow-import-from-derivation = true' from ~/.local/share/nix/trusted-settings.json.
Resolving dependencies...
Build profile: -w ghc-9.2.4 -O1
In order, the following will be built (use -v for more details):
 - hspec-discover-2.10.6 (lib) (requires build)
 - hspec-discover-2.10.6 (exe:hspec-discover) (requires build)
 - sample-0.0.0 (test:test) (first run)
Starting     hspec-discover-2.10.6 (lib)
^C

Expected behavior

Cabal should not bother building hspec-discover since it exists in PATH due to Nix (I think it's possibly reason able to ignore the one on PATH if Nix wasn't what put it there).

System information

  • Operating system: archlinux with nix
    GHC version: 9.2.4
    Cabal version:
[jade@tail-bot cabal-repro]$ cabal --version
cabal-install version 3.6.2.0
compiled using version 3.6.3.0 of the Cabal library 

Additional context
Add any other context about the problem here.

@lf-
Copy link
Collaborator Author

lf- commented Sep 25, 2022

cc @parsonsmatt since you hit this the other day also

@parsonsmatt
Copy link

#8434 is a related issue

@fgaz
Copy link
Member

fgaz commented Sep 27, 2022

This is basically #8434 (cabal-install can't know that the installed package is the required version), let's keep the discussion there

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants