Can anyone explain the difference between these two cabal invocations? I don’t understand it.
% 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>
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.
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.
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.)
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).