41

The situation is, I am trying to install Netwire using Stack. However, there is a problem in the latest netwire 5.0.1, as reported by dhobbs: http://hub.darcs.net/ertes/netwire/issue/13

Since I don't know when the problem will ever be fixed, I downloaded the repo and made the change myself. However, I don't understand how to install such a locally patched version. stack install does not install that into ~/.stack. Does anyone have an idea?

Update

Now I am developing some other libraries using Stack. How do I make another project use that libraries? Hard coding a relative path looks incredibly ugly.

Carl Dong
  • 1,299
  • 15
  • 26

1 Answers1

27

So you have a project where you want to use your locally patched Netwire version and in your project you have a stack.yml, as an example:

flags: {}
packages:
- '.'
extra-deps: {}
resolver: lts-3.7

You also have an dependency on netwire declared in your cabal file.

To use you patched Netwire in this project of yours you simply put the patched Netwire package in a subdirectory of your project, perhaps called netwire, and update your stack.yml as such:

flags: {}
packages:
- '.'
- netwire
extra-deps: {}
resolver: lts-3.7

Now stack build will build your project with the patched Netwire version.

You can also put the modified source online (if the license permits) and refer to the source using either a tarball URL

- https://example.com/netwire.tar.gz

or a git repository and commit reference:

- location:
    git: git@example.com/netwire
    commit: 6a86ee32e5b869a877151f74064572225e1a0398

(Check out the documentation for more info: https://docs.haskellstack.org/en/stable/yaml_configuration/#packages-and-extra-deps)

Nikos Baxevanis
  • 10,868
  • 2
  • 46
  • 80
ase
  • 13,231
  • 4
  • 34
  • 46
  • 4
    I know this method. However, I would like to put the netwire library at a more convenient place, isolated from the source. Doing what you said makes me feel like compiling a bunch of softwares under /usr and keep the sources right there. – Carl Dong Sep 29 '15 at 21:08
  • Or say, I'd like it if I use `stack ghci` anywhere, I can just import `Control.Wire` – Carl Dong Sep 29 '15 at 21:08
  • I'm not 100% but I don't think that is a supported use case. – ase Sep 29 '15 at 21:10
  • 1
    Does that mean I have to keep the source then? I think it is better to just take the libraries – Carl Dong Sep 29 '15 at 21:35
  • 4
    You can specify a git location as a package. See the docs on stack.yaml. That way you don't need to put the source in your project's directory. Sorry for no links, I'm on my phone. – Christopher Armstrong Sep 29 '15 at 21:43
  • AFAIK stack is a tool for building collections of packages from _source_, with the ability to cache some of the build artifiacts (the ones that are part of the Stackage nightlies/lts-s). Since Netwire is not part of Stackage I don't think you have any hope of it ending up in the cache. – ase Sep 29 '15 at 21:46
  • OK, I guess for now I will just find a nice place to put the sources. – Carl Dong Sep 29 '15 at 21:47
  • 3
    You can get around needing to have netwire as a subdirectory with a symlink. Just put it wherever you want and drop a symlink to it into your package. It's kind of a hack, but it will get the job done. – triplepoint217 Jan 25 '18 at 16:07
  • "You can also put the modified source online (if the license permits) and refer to the source using either a tarball URL" It seems that "packages" does not support this syntax in "stack.yaml"? it prompt InvalidAbsDir. – chansey Apr 21 '20 at 09:52