Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why doesn't stack add packages to the ghc package database?

I've decided to try giving stack a shot. I've installed it and used it to install the latest version of ghc. I've used stack to install some packages but the packages are not visible to ghc and when I list packages with ghc-pkg I see that the packages that I've installed through stack are not there. Why is this? Am I misunderstanding the purpose of stack?

like image 987
user467526 Avatar asked Jul 13 '15 20:07

user467526


People also ask

Where does stack install GHC?

In its default configuration, Stack will simply ignore any system GHC installation and use a sandboxed GHC that it has installed itself. You can find these sandboxed GHC installations in the ghc-* directories in the stack path --programs directory.

Where does stack install packages?

Stack installs the Stackage libraries in ~/. stack and any project libraries or extra dependencies in a . stack-work directory within each project's directory.

Where are Haskell packages installed?

If you don't need a fully partitioned GHC environment and are happy with the installed versions on DICE, cabal might be the simplest way to install the Haskell packages you require. By default stack installs packages to ~/. cabal and ~/. ghc in your home directory.

How do I know if stack is installed?

html -> click on system information-> login with admin rights -> you can get all details about the installed server.


1 Answers

Stack never touches global packages database. It uses layered database approach

  1. global database - untouched
  2. packages in the stackage snapshot are installed into snapshot database
  3. other packages are installed locally per project

Thus instead of polluting global database, most packages are installed in snapshot database(s), so most packages can be shared. As packages in stackage snapshots are compatible (i.e. always compile together), we don't run into Cabal hell.

You can use stack ghci or stack ghc to run corresponding commands with package database configured.

The more precise explanation is in the stack wiki

like image 199
phadej Avatar answered Nov 15 '22 08:11

phadej