Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to install/use a local version of package using Stack?

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.

like image 310
Carl Dong Avatar asked Sep 29 '15 16:09

Carl Dong


People also ask

Where does stack install packages?

Stack installs the Stackage libraries in ~/. stack and any project libraries or extra dependencies in a . stack-work directory within each project's directory.

What is stack install?

The stack install command and copy-bins option Stack will always build any necessary dependencies for your code. The install command is not necessary to trigger this behavior. If you just want to build a project, run stack build .

What is stack Ghci?

stack ghci allows you to load components and files of your project into ghci . It uses the same TARGET syntax as stack build , and can also take options like --test , --bench , and --flag . Similarly to stack build , the default is to load up ghci with all libraries and executables in the project.

Where does stack install GHC?

In its default configuration, Stack will simply ignore any system GHC installation and use a sandboxed GHC that it has installed itself. You can find these sandboxed GHC installations in the ghc-* directories in the stack path --programs directory.


1 Answers

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: [email protected]/netwire     commit: 6a86ee32e5b869a877151f74064572225e1a0398 

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

like image 190
adamse Avatar answered Sep 25 '22 08:09

adamse