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

喜欢而已 提交于 2019-12-22 05:34:14

问题


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?


回答1:


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



来源:https://stackoverflow.com/questions/31393189/why-doesnt-stack-add-packages-to-the-ghc-package-database

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!