4

Is it possible to use stack with an already installed ghc without stack installing a local copy of ghc or cabal?

sjakobi
  • 3,546
  • 1
  • 25
  • 43
vivian
  • 1,434
  • 1
  • 10
  • 13

1 Answers1

4

Yes. If the ghc in PATH is of right version for the selected snapshot, stack will happily use it.

% ghc --version
The Glorious Glasgow Haskell Compilation System, version 7.8.4

% stack --resolver=lts-2.22 install packdeps
Run from outside a project, using implicit global project config
Using resolver: lts-2.22 specified on command line
packdeps-0.4.1: unregistering
packdeps-0.4.2: download
...

% stack --resolver=nightly-2015-12-25 install packdeps
Run from outside a project, using implicit global project config
Using resolver: nightly-2015-12-25 specified on command line
Compiler version mismatched, found ghc-7.8.4 (x86_64), but expected minor version match with ghc-7.10.3 (x86_64) (based on resolver setting in /Users/phadej/.stack/global/stack.yaml).
Try running "stack setup" to install the correct GHC into /Users/phadej/.stack/programs/x86_64-osx/

You can also skip ghc check --skip-ghc-check:

% stack --resolver=nightly-2015-12-25 --skip-ghc-check install packdeps
Run from outside a project, using implicit global project config
Using resolver: nightly-2015-12-25 specified on command line
split-0.2.2: configure
...

but that might be a bad idea

phadej
  • 11,947
  • 41
  • 78
  • I believe that by default `stack` WILL NOT use the global GHC installation, even if its version matches the project's `resolver` setting. But it is possible - [Shaun the Sheep's comment](https://stackoverflow.com/questions/34469955/haskell-stack-with-global-ghc#comment56695023_34469955) points to the documentation that explains the available options. – GreenhouseVeg Jun 14 '20 at 09:34