Is it possible to install a version of a package from github using Haskell stack?
e.g. in a .cabal or a stack.yaml file, how can I point a depe
New syntax for Stack >1.7.1
As @Flip commented, the docs at docs.haskellstack.org
clarify the new syntax for your stack.yaml is: (note the full commit hash needs to be used)
extra-deps:
- github: apolishch/prime_table
commit: a510622a824af999a809191e8c959b8ea5fa8bdb
- github: apolishch/reactive-banana
commit: 74bac0f86ed172f95bb6f6a31041992fc161cf79
subdirs: reactive-banana
To be clear: dependencies in your stack.yaml make sure that the packages (which are not in Stackage) are available would some .cabal file in your project want them, just in case.
You still have to specify the name of the package in build-depends in your .cabal file to say you actually depend on the package.
Note it doesn't matter what branch the commit is on, and repos can be forks. When a package is in a subdirectory, you can specify it, otherwise it will default to top-level.
Syntax for Stack >1.6.0
extra-deps:
- github: git@github.com:apolishch/prime_table.git
commit: a510622a824af999a809191e8c959b8ea5fa8bdb
[Edit] I have found that sometimes the syntax from 1.7.1 fails with error message
C:\Users\username\AppData\Local\Programs\stack\x86_64-windows\ghc-8.4.3\lib/../mingw/bin\ar.exe: .stack-work\dist\7d103d30\build\objs-10648\libHSpackagename-0.1.0.0-DlGXqyeqb9MDn2z8KhgjVb.a: No such file or directory
and I solved that by using the 1.6.0 syntax, even though I was using Stack 1.7.1. When using Travis, that will fail because Travis can't clone via SSH without your SSH keys of course. But you can still use the https link as
extra-deps:
- github: https://github.com/apolishch/prime_table.git
commit: a510622a824af999a809191e8c959b8ea5fa8bdb