Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to build a sandboxed cabal project with a custom version of a dependency that is not on hackage (e.g. a checkout from github)

If a have a library checked out locally that builds with cabal that is used by an application. I would like to build my application against the the local library rather than something from hackage but I'm not sure how to do this. This seems like something I should be able to do, I'm just don't seem to be able to work out how.

Sandboxing

In case it matters or complicates things, the application is in a cabal sandbox with the cabal-sandbox-config file in the route directory of the application.

What I'm Trying to accomplish

I'm building Yesod application and I want to tweak the behaviour of one of the dependencies (shakespeare). I would like to build my application against my tweaked version.

like image 732
Gareth Charnock Avatar asked Dec 20 '22 10:12

Gareth Charnock


1 Answers

Use cabal sandbox add-source, which is designed specifically for this use case.

Example:

$ git clone https://github.com/SomeUser/SomeDependency
$ cd /path/to/my-project
$ cabal sandbox add-source /path/to/SomeDependency
$ cabal build

As a bonus, if you later update SomeDependency and try to rebuild my-project, cabal will notice that and reinstall SomeDependency.

like image 150
Mikhail Glushenkov Avatar answered Mar 08 '23 23:03

Mikhail Glushenkov