How to install a package using stack?

33,781

Solution 1

add hakyll in stack.yaml generated by stack init or stack new

yaml file should look like:

flags: {}
packages:
  - '.'
extra-deps:
  - hakyll-4.7.1.0
resolver: lts-2.15

after that, run stack solver installs it

https://github.com/commercialhaskell/stack/wiki/stack.yaml

Solution 2

This documentation worked for me

On package.yaml add the library under dependencies, for example:

dependencies:
- base >= 4.7 && < 5
- hakyll # added here
Share:
33,781
Ben
Author by

Ben

Updated on July 05, 2022

Comments

  • Ben
    Ben almost 2 years

    Using cabal, I could install hakyll with the command:

    cabal install hakyll
    

    How can I do the same thing using stack?

  • Michael Snoyman
    Michael Snoyman almost 9 years
    Probably worth adding that stack install hakyll all by itself is probably sufficient to get the desired result.
  • JoL
    JoL about 7 years
    I think it's worth mentioning that this method is typically only done when the desired version of the package is not present in the selected snapshot. I believe the preferred method of package installation for a project is adding it to the *.cabal file's build-depends, or running stack install hakyll to test it out first.
  • Shawn Eary
    Shawn Eary over 2 years
    For some reason I feel recent versions of GHC have gotten unnecessarily complicated. I used to be able to use cabal. Now I have to go through all of this mess (and more) to get my old programs to compile.