Closed gelisam closed 11 years ago
I don't know enough of cabal-dev to fix this. I know it creates a directory cabal-dev in which it install everything, but I don't know why it doesn't add to the path the library directory that is essential to run the tool. There must be a way to tell it to load the libraries that it installs!
I think the hawk
binary generated by cabal-dev does have access to the libraries cabal-dev has installed, but they are only available as imports. I think the problem we see above occurs when we try to compile the user's expression (wait, are we compiling or interpreting the user's expression?), and it references a library which isn't installed in a standard location.
Since cabal-dev installs the hawk
binary in the same subfolder in which it installs the library, it should be quite easy to compute the path of the libraries from the path of the executable.
I found a fix, but you won't like it.
hint
doesn't have an option for adding more package lists to its search path, but it does have a "searchPath" option for loading modules from source files. Thus, when I detect that hawk has been installed using the cabal-dev, I construct a path to hawk's source folder, and I interpret System.Console.Hawk.Representable
.
It works, but it's really hacky. For one thing, this won't work for people installing hawk
from hackage using cabal-dev, because they won't have any source on which the hack could work.
> cabal-dev install
> ./cabal-dev/bin/hawk -e [1..3]
1
2
3
I know which option I need to pass to ghc:
> cat Foo.hs
import System.Console.Hawk.Representable
main = putStrLn "hello"
> ghc Foo.hs
Foo.hs:1:8:
Could not find module `System.Console.Hawk.Representable'
Use -v to see a list of the files searched for.
> ghc -package-db cabal-dev/packages-7.6.3.conf Foo.hs
[1 of 1] Compiling Main ( Foo.hs, Foo.o )
Linking Foo ...
But when I use unsafeSetGhcOption
to pass those arguments to hint
, there is no effect.
Aha! I need to use unsafeRunInterpreterWithArgs
, not unsafeSetGhcOption
.
A .cabal file is sufficient to compile, but not to run.