# Surprising difference between \`cabal --with-ghc\` and \`--with-compiler\`

**URL:** <https://discourse.haskell.org/t/surprising-difference-between-cabal-with-ghc-and-with-compiler/7984>\
**Category:** Learn\
**Created:** [November 2, 2023, 11:16am UTC](https://discourse.haskell.org/t/surprising-difference-between-cabal-with-ghc-and-with-compiler/7984 "2023-11-02T11:16:18Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![tomjaguarpaw](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.haskell.org/tomjaguarpaw/32/1230_2.png) [@tomjaguarpaw](https://discourse.haskell.org/u/tomjaguarpaw)\
**Post date:** [November 2, 2023, 11:16am UTC](https://discourse.haskell.org/t/surprising-difference-between-cabal-with-ghc-and-with-compiler/7984/1 "2023-11-02T11:16:18Z")

</div>

Can anyone explain the difference between these two `cabal` invocations? I don’t understand it.

```nohighlight
% cabal install --with-ghc ghc-9.6 pandoc
The path to the compiler program (or programs used by the
compiler) cannot be specified on a per-package basis in the
cabal.project file (i.e. setting the 'ghc-location' for package 'pandoc').
All packages have to use the same compiler, so specify the path in a
global 'program-locations' section.
% cabal install --with-compiler ghc-9.6 pandoc
Resolving dependencies...
<proceeds to compile as expected>

```

---

<div class="post-metadata">

**Author:** ![jaror](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.haskell.org/jaror/32/3271_2.png) [@jaror](https://discourse.haskell.org/u/jaror)\
**Post date:** [November 2, 2023, 11:35am UTC](https://discourse.haskell.org/t/surprising-difference-between-cabal-with-ghc-and-with-compiler/7984/2 "2023-11-02T11:35:51Z")

</div>

I had never heard of the `--with-ghc` option. I see it is only mentioned in the documentation about `Setup.hs`: [8. Setup.hs Commands — Cabal 3.11.0.0 User's Guide](https://cabal.readthedocs.io/en/latest/setup-commands.html#cmdoption-runhaskell-Setup.hs-configure-with-PROG). Perhaps it should be deprecated.

---

<div class="post-metadata">

**Author:** ![jaror](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.haskell.org/jaror/32/3271_2.png) [@jaror](https://discourse.haskell.org/u/jaror)\
**Post date:** [November 2, 2023, 11:43am UTC](https://discourse.haskell.org/t/surprising-difference-between-cabal-with-ghc-and-with-compiler/7984/3 "2023-11-02T11:43:53Z")

</div>

2 posts were split to a new topic: [How to disable syntax highlighting on Discourse?](https://discourse.haskell.org/t/how-to-disable-syntax-highlighting-on-discourse/7985)

---

<div class="post-metadata">

**Author:** ![jackdk](https://avatars.discourse-cdn.com/v4/letter/j/9f8e36/32.png) [@jackdk](https://discourse.haskell.org/u/jackdk)\
**Post date:** [November 2, 2023, 12:32pm UTC](https://discourse.haskell.org/t/surprising-difference-between-cabal-with-ghc-and-with-compiler/7984/4 "2023-11-02T12:32:36Z")

</div>

If I had to guess, I would expect that `--with-ghc` is setting the name of the _GHC executable only_ while `--with-compiler` is being spliced into the name used to invoke GHC, but also other supporting tools like its corresponding `ghc-pkg` command, etc.

---

<div class="post-metadata">

**Author:** ![Mikolaj](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.haskell.org/mikolaj/32/1041_2.png) [@Mikolaj](https://discourse.haskell.org/u/Mikolaj)\
**Post date:** [November 2, 2023, 2:42pm UTC](https://discourse.haskell.org/t/surprising-difference-between-cabal-with-ghc-and-with-compiler/7984/5 "2023-11-02T14:42:37Z")

</div>

The error message, which is likely misguided anyway (and wrongly assumes the options comes from a project file, not commandline), suggests that `--with-ghc` is per-package, while `--with-compiler ` is per-project. Probably `--with-prog` is generally per-package and, by histerical accident, `ghc` is accepted for `prog` in this context, though it doesn’t make sense.

---

<div class="post-metadata">

**Author:** ![tomjaguarpaw](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.haskell.org/tomjaguarpaw/32/1230_2.png) [@tomjaguarpaw](https://discourse.haskell.org/u/tomjaguarpaw)\
**Post date:** [November 2, 2023, 2:51pm UTC](https://discourse.haskell.org/t/surprising-difference-between-cabal-with-ghc-and-with-compiler/7984/6 "2023-11-02T14:51:08Z")

</div>

Ah, OK, so then would you say @jaror is correct that `--with-ghc` should be considered deprecated? (I’m not sure why I started using it in the first place, but I have done so for many years.)

---

<div class="post-metadata">

**Author:** ![Mikolaj](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.haskell.org/mikolaj/32/1041_2.png) [@Mikolaj](https://discourse.haskell.org/u/Mikolaj)\
**Post date:** [November 2, 2023, 3:06pm UTC](https://discourse.haskell.org/t/surprising-difference-between-cabal-with-ghc-and-with-compiler/7984/7 "2023-11-02T15:06:05Z")

</div>

I’m just guessing in the dark. Somebody needs to dig into the codebase, understand this, fix the documentation, fix error messages and, eventually, propose a functionality fix, e.g., the deprecation (of only `--with-ghc` or more of the `--with-prog`? only on commandline or also in the project file (if the message is not lying that it can appear in the project file)?). Feel free to open a ticket (I doubt there’s one already).

---

<div class="post-metadata">

**Author:** ![Mikolaj](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.haskell.org/mikolaj/32/1041_2.png) [@Mikolaj](https://discourse.haskell.org/u/Mikolaj)\
**Post date:** [November 2, 2023, 6:52pm UTC](https://discourse.haskell.org/t/surprising-difference-between-cabal-with-ghc-and-with-compiler/7984/8 "2023-11-02T18:52:54Z")

</div>

BTW, apparently `cabal repl --with-ghc=doctest` is an important use case: [GitHub - sol/doctest: An implementation of Python's doctest for Haskell](https://github.com/sol/doctest#readme), but `repl` is very different from `build` or `install` and doctests are a very delicate and special beast.

---

<div class="post-metadata">

**Author:** ![tomjaguarpaw](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.haskell.org/tomjaguarpaw/32/1230_2.png) [@tomjaguarpaw](https://discourse.haskell.org/u/tomjaguarpaw)\
**Post date:** [November 3, 2023, 1:52pm UTC](https://discourse.haskell.org/t/surprising-difference-between-cabal-with-ghc-and-with-compiler/7984/9 "2023-11-03T13:52:13Z")

</div>

OK, ticket opened: [Improve behavior around `--with-ghc` · Issue #9394 · haskell/cabal · GitHub](https://github.com/haskell/cabal/issues/9394)

---

<div class="post-metadata">

**Author:** ![Mikolaj](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.haskell.org/mikolaj/32/1041_2.png) [@Mikolaj](https://discourse.haskell.org/u/Mikolaj)\
**Post date:** [November 3, 2023, 4:15pm UTC](https://discourse.haskell.org/t/surprising-difference-between-cabal-with-ghc-and-with-compiler/7984/10 "2023-11-03T16:15:08Z")

</div>

Thank you Tom!

Now a volunteer is very much welcome. 🙂
