haskell / cabal

Official upstream development repository for Cabal and cabal-install
https://haskell.org/cabal
Other
1.61k stars 691 forks source link

Installing library in specific location on Mac and using it later #10362

Open ivanperez-keera opened 1 week ago

ivanperez-keera commented 1 week ago

I'm interested in being able to call runhaskell exposing specific libraries, from any directory, and without having a cabal.project or package.env in the current directory. I can pass any arguments or environment variables I want to runhaskell, and I should place all files in a specific location (call it /myLibraryDir), not in the user's home.

What is the way of installing a library with Cabal so that all files and libraries are installed in under specific path, and can later be found?

I'm looking for the arguments to:

cabal <some_installation_command> <arguments> myLibrary

such that later I can run from any directory:

runhaskell <arguments> <<< 'import MyModule; main = putStrLn "Success"'

geekosaur commented 1 week ago

I believe the supported way to do this is not to use cabal at all, but the Setup.hs interface. However, what you're asking for will still be made difficult by ghc, which in the absence of cabal or stack will look in its global package db and an old-style user package db only; you would have to point ghc/ghci/runghc/etc. to any additional package db you used. (You must use a package db.)