-
Notifications
You must be signed in to change notification settings - Fork 42
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
cooperate with stack and cabal to find the package-db #129
Comments
@gelisam, ghc-pkg looks at GHC_PACKAGE_PATH and --package-db argument, but unsafeRunInterpreterWithArgs (ghc 8.10.2) ignores both. being in nix-shell cabal builds my app and ghc-pkg list prints path to the package database, but |
What makes you say that? If I install e.g. the import Data.Foldable (for_)
import Language.Haskell.Interpreter as Hint
import Language.Haskell.Interpreter.Unsafe as Hint
-- |
-- >>> main
-- with args:
-- result:
-- <no location info>: error:
-- Could not find module ‘Data.Colour’
-- Use -v (or `:set -v` in ghci) to see a list of the files searched for.
-- with args:
-- -package-db
-- /Users/gelisam/.stack/snapshots/.../8.10.4/pkgdb
-- result:
-- Data.Colour.SRGB.Linear.rgb 0.0 0.0 0.0
main :: IO ()
main = do
let packageDbConfigs = [ []
, ["-package-db", "/Users/gelisam/.stack/snapshots/.../8.10.4/pkgdb"]
]
for_ packageDbConfigs $ \packageDbConfig -> do
putStrLn "with args:"
for_ packageDbConfig $ \arg -> do
putStrLn $ " " ++ arg
putStrLn "result:"
r <- Hint.unsafeRunInterpreterWithArgs packageDbConfig $ do
Hint.setImports ["Prelude", "Data.Colour"]
Hint.eval "mempty :: Colour Double"
case r of
Left (WontCompile [GhcError errMsg]) -> do
putStrLn errMsg
Right s -> do
putStrLn s |
In my case -package-db and GHC_PACKAGE_PATH don't help anyhow. GHC_PACKAGE_PATH="/nix/store/h1bikz8x8v5g88b0vk78xdncckivan4j-ghc-8.10.4-with-packages/lib/ghc-8.10.4/package.conf.d:" my-elf-file
But replacing package.cache in user conf ref solves problem:
Interpreter is working.
Still working! So I conclude that unsafeRunInterpreterWithArgs understands -package arguments. |
I can only repeat once again that I do not recommend having code from package X interpret code which imports a module from package X :) |
currently, hint's package database is configured in the same way ghc is, via environment variables and
-package-db
arguments. This is super old-school, nowadays people use a.cabal
file to specify which packages they want their programs to see. It would be great if that just worked out of the box without having to jump through hoops in order to set the right settings. At the very least, how to specify package databases should be documented somewhere.The text was updated successfully, but these errors were encountered: