Skip to content

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

Closed as not planned

Description

@sol

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

Activity

  1. changed the title [-]*Magic* behavior when `cabal exec` is used with `with-compiler:`[/-] [+]"Magic" behavior when `cabal exec` is used with `with-compiler:`[/+] on Jul 12, 2024
  2. hasufell commented on Jul 19, 2024

    @hasufell
    Member

    Yes, it's documented:

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

  3. hasufell commented on Jul 19, 2024

    @hasufell
    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

  4. geekosaur commented on Jul 19, 2024

    @geekosaur
    Collaborator

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

  5. sol commented on Jul 27, 2024

    @sol
    MemberAuthor

    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.

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions