-
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
restore support for -package-db
#147
Conversation
such as @unsafeRunInterpreterWithArgs [...]@
'unsafeRunInterpreterWithArgs' is often used to specify the path to a non-default package database, using the @-package-db@ flag. Unfortunately, a previous refactoring accidentally broke this workflow. The refactoring seems innocent on the surface, so it's worth explaining how that refactoring managed to break anything. The refactoring defined a 'modifyLogger' shim corresponding to the ghc-9.2 function of the same name. In older versions of ghc, 'modifyLogger' is implemented using 'setSessionDynFlags'. As a result, it now matters whether the logger is configured before other calls to 'setSessionDynFlags'. In particular, the logger was configured too early, before the @-package-db@ flags were given to ghc using a second call to 'setSessionDynFlags'. As a result, the first call to 'setSessionDynFlags', the one hidden inside 'modifyLogger', was reading the default package databases and setting internal flag indicating that the package databases have been read. Then, the second call to 'setSessionDynFlags' which specifies non-default package databases with @-package-db@ flags, saw this internal flag and decided not to read the package databases a second time. fixes #142
An IOTestCase is allowed to run IO before calling 'runInterpreter', and to instead call a variant of 'runInterpreter' such as 'runInterpreterWithArgs', as long as it threads it through the IOTestCase constructor. Unfortunately, this threading API was limiting: only a single variant per test could be used, and IO could not be used to construct the variant. This new API fixes both issues.
The tests pass with cabal, but not with stack. Both use |
it is set by stack and cabal complains about it in the tests
Oh no! In the process of figuring out the difference between cabal and stack, I switched to ghc-8.10.7, and with that version the test is failing with cabal as well! |
The test passes with:
But fails with:
The combination "stack, ghc-8.8.4" does not appear in either list because I can't even get to So I think there are two separate problems:
|
In both λ> unsafeRunInterpreterWithArgs ["-package-db=/home/gelisam/working/haskell/hint/my-package/dist-newstyle/packagedb/ghc-9.2.1"] (setImports ["MyModule"])
Right () So what's different between the running the test suite and running the repl? |
Aha! |
More precisely, that file contains:
There are two reasons why this file is causing problems. First, it clears the list of package databases, so if this file happens to be interpreted after the command-line |
it is set by stack to pin down the list of package databases and the list of packages, which is problematic for a test which tries to configure a package database which is not in that list in order to load a package which is not on that list either.
Finally! |
Fixes #142