Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

cabal install an executable from Hackage via a sandbox?

Tags:

haskell

cabal

When I run cabal install [pkg] and pkg is a command line executable program instead of a library, it often warns me with this message: "Warning: The following packages are likely to be broken by the reinstalls"

I always use the --force-reinstalls option to proceed.

But since I'm installing an executable and NOT a library, is there a way to run cabal install to isolate the build process in a cabal sandbox, and then install the executable in ~/.cabal/bin? Or is this something I need to write a custom bash script for?

like image 335
dan Avatar asked Dec 03 '14 14:12

dan


1 Answers

I always create a sandbox for my tools, such as hoogle, pointfree, haddock, ghc-mod, hlint, shake, and stylish-haskell among others. Simply follow these steps:

  • Create a cabal sandbox with cabal sandbox init in the location of your choice
  • Run cabal install [pkg1 [pkg2 ...]]
  • Once completed, copy the desired executables from the .cabal-sandbox/bin folder to your ~/.cabal/bin/ folder.
  • Run cabal sandbox delete to remove the likely very large sandbox that you no longer need.

These executables are usually completely standalone, so you can build them against the dependencies they request in a sandbox and then move them to where ever you want. This definitely helps keep your system-wide installation clean and free from conflicts.

like image 136
bheklilr Avatar answered Sep 24 '22 11:09

bheklilr