2

I have a Haskell library I wrote that I compile with stack. I now need to use it in another Haskell stack project. In order to do that, I have added its current version to the extra_deps of my new project's stack.yaml and listed it among the build_depends of one its executables. When I run stack build, however, it obviously tries to download the library from the internet. How do I specify that the library is local and where to find it?

Thanks in advance!

harisont
  • 143
  • 1
  • 9
  • 2
    Does this answer your question? [How to install/use a local version of package using Stack?](https://stackoverflow.com/questions/32849269/how-to-install-use-a-local-version-of-package-using-stack) – DDub Mar 04 '21 at 19:20
  • @DDub, that answer is very old. With my version of Stack I'm getting an error: "Ignoring unrecognized field $.packages" – michid Mar 04 '21 at 21:15
  • have you runned `stack install` or just `stack build`?. I think (not sure) that `stack install` command will add the compiled library to local dependencies. Once you've done that you can import from other package. – lsmor Mar 05 '21 at 08:18
  • @DDub it's exactly the kind of answer I was looking for, but as michid says it no longer works. – harisont Mar 05 '21 at 08:45
  • @Ismor: I tried and it didn't work, I believe that's because stack only installs executables (and not libraries) – harisont Mar 05 '21 at 08:45

1 Answers1

3

You can use github coordinates in the extra-deps section of your stack.yaml.

extra-deps:
- github: snoyberg/http-client
  commit: a5f4f30f01366738f913968163d856366d7e0342

Then add the dependency in your package.yaml:

dependencies:
- http-client >= 0.1.0.0
michid
  • 10,536
  • 3
  • 32
  • 59
  • I was asking about how to use a _local_ library, but this with github did solve my problem. Thank you for your help! – harisont Mar 05 '21 at 09:53