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

"Magic" behavior when cabal exec is used with with-compiler: #10196

Closed
sol opened this issue Jul 12, 2024 · 4 comments
Closed

"Magic" behavior when cabal exec is used with with-compiler: #10196

sol opened this issue Jul 12, 2024 · 4 comments

Comments

@sol
Copy link
Member

sol commented Jul 12, 2024

Describe the magic behavior

When you set with-compiler: ghc-x.y.z in cabal.project then:

  • cabal exec ghc refers to ghc-x.y.z
  • However, cabal exec which ghc does not return the path to ghc-x.y.z

On the surface this seems like magic behavior.

  1. Is this documented somewhere?
  2. What is the exact mechanism here?
  3. For implementing cabal-doctest, I need to determine which GHC executable is used by cabal. Any other ideas how I could achieve this?

To Reproduce

$ cat cabal.project
with-compiler: ghc-9.10.1

$ cabal exec -v0 -- ghc --numeric-version
9.10.1

$ $(cabal exec -v0 which ghc) --numeric-version
9.2.8

System information

$ cabal --version
cabal-install version 3.12.1.0
compiled using version 3.12.1.0 of the Cabal library
@sol sol changed the title *Magic* behavior when cabal exec is used with with-compiler: "Magic" behavior when cabal exec is used with with-compiler: Jul 12, 2024
@hasufell
Copy link
Member

Yes, it's documented:

++ " v2-exec ghc` will consult the configuration"

@hasufell
Copy link
Member

For implementing cabal-doctest, I need to determine which GHC executable is used by cabal. Any other ideas how I could achieve this?

Yes, see https://github.com/haskell/hie-bios/blob/6a06ed72706a533f20a06823650f165203aeb221/src/HIE/Bios/Cradle.hs#L768

@geekosaur
Copy link
Collaborator

Isn't the principled way to do this a cabal hc command? (Possibly with support for something similar to --repl-multi-file.)

@sol
Copy link
Member Author

sol commented Jul 27, 2024

Thanks @hasufell.

  1. I think from a user perspective it's a disaster that e.g. cabal exec ghc ... and cabal exec env ghc ... don't do the same thing.

  2. I think I agree with @geekosaur that a dedicated sub command would have offered a more principled way to invoke the configured ghc (e.g. cabal exec-compiler). However, changing this now would be a breaking change.

  3. For cabal-doctest I'm using the output of cabal path, which requires cabal-install-3.12.*. However, as sub commands are only supported since 3.12.* that's acceptable for cabal-doctest.

@sol sol closed this as completed Jul 27, 2024
@sol sol closed this as not planned Won't fix, can't repro, duplicate, stale Jul 28, 2024
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

4 participants