Hello all,
Let’s say I have a project with an executable and a library. The repository looks like:
app/
app/Main.hs
lib/
lib/MyLib.hs
scripts/
scripts/MyScript.hs
my-lib.cabal
I’d like to run a script (scripts/MyScript
) which looks like this:
import qualified MyLib
main = pure () -- Imagine doing something with the Foo library
The documentation for cabal run
shows how to include dependencies in the script file:
#!/usr/bin/env cabal
{- cabal:
build-depends: base
, my-lib
-}
import qualified MyLib
main = pure () -- Imagine doing something with the Foo library
However, when I run cabal run scripts/MyScript.hs
, I get an error like this:
Error: cabal: Could not resolve dependencies:
[__0] trying: fake-package-0 (user goal)
[__1] unknown package: my-lib (dependency of fake-package)
[__1] fail (backjumping, conflict set: fake-package, my-lib)
After searching the rest of the dependency tree exhaustively, these were the
goals I've had most trouble fulfilling: fake-package, my-lib
Any ideas on how to make cabal
see foo
? I understand I could do something like cabal install --lib
. Would I not need to re-install whenever I update the foo
package?