-
Notifications
You must be signed in to change notification settings - Fork 701
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
ignore an externally set $GHC_ENVIRONMENT #7792
Comments
I'm for ignoring the env var, if possible. |
Hmm, in https://ghc.gitlab.haskell.org/ghc/doc/users_guide/packages.html#package-environments
But the Note that I'd say it's simpler for |
Given the positive response I'm going to turn this ticket from "discussion" to "enhancement"+"pr welcome". Some stuff to pay attention to when implementing:
|
Why not treating |
This would break quite a few test suites that rely on Cabal 3.12 caused the check for GHC_PACKAGE_PATH to be executed when running test suites, so it seems you now would need to use Not saying |
This is a years-old discussion, and frankly I don't see it's purpose. If Where's the nail that this discussion/hammer is trying to hit? What's the actual problem? |
Previously, we would set GHC_PACKAGE_PATH after configure, the reasons being that 1. Setup.hs configure forbids this from being set since it can make a build fail that would otherwise succeed (since it influences how GHC behaves when invoked by Cabal). 2. Setting GHC_PACKAGE_PATH being set is sound in our case, since we set it precisely to the packages available to Cabal at configure time, so there should be no room for a mismatch. 3. Some test suites require GHC_PACKAGE_PATH or GHC_ENVIRONMENT to be set, so they can invoke GHC(i) with build dependencies available. Cabal >= 3.12 forbids GHC_PACKAGE_PATH from being set after <haskell/cabal@d6e38041a7c778fadf8f416>. Setting GHC_ENVIRONMENT would be possible, but is cumbersome without cabal-install (which has the handy cabal exec command which takes care of that). Additionally, it is not clear if it'll remain possible to do that: <haskell/cabal#7792>. Our solution to Cabal 3.12's change is to be more targeted about setting GHC_PACKAGE_PATH: We _just_ set it for the actual test suite executable. This can be achieved by using --test-wrapper which when given is invoked by Cabal to run the test suite. Here we can set any environment variables after Cabal has already done its environment checks. As long as we don't do anything stupid, this should be unproblematic. Users can also arbitrarily influence what GHC_PACKAGE_PATH will contain using the NIX_GHC_PACKAGE_PATH_FOR_TEST environment variable. This is un(der)documented for now, since I want to keep some wiggle room for changing stuff in the coming weeks. Also it's rarely necessary to actually touch this variable.
Previously, we would set GHC_PACKAGE_PATH after configure, the reasons being that 1. Setup.hs configure forbids this from being set since it can make a build fail that would otherwise succeed (since it influences how GHC behaves when invoked by Cabal). 2. Setting GHC_PACKAGE_PATH being set is sound in our case, since we set it precisely to the packages available to Cabal at configure time, so there should be no room for a mismatch. 3. Some test suites require GHC_PACKAGE_PATH or GHC_ENVIRONMENT to be set, so they can invoke GHC(i) with build dependencies available. Cabal >= 3.12 forbids GHC_PACKAGE_PATH from being set after <haskell/cabal@d6e38041a7c778fadf8f416>. Setting GHC_ENVIRONMENT would be possible, but is cumbersome without cabal-install (which has the handy cabal exec command which takes care of that). Additionally, it is not clear if it'll remain possible to do that: <haskell/cabal#7792>. Our solution to Cabal 3.12's change is to be more targeted about setting GHC_PACKAGE_PATH: We _just_ set it for the actual test suite executable. This can be achieved by using --test-wrapper which when given is invoked by Cabal to run the test suite. Here we can set any environment variables after Cabal has already done its environment checks. As long as we don't do anything stupid, this should be unproblematic. Users can also arbitrarily influence what GHC_PACKAGE_PATH will contain using the NIX_GHC_PACKAGE_PATH_FOR_TEST environment variable. This is un(der)documented for now, since I want to keep some wiggle room for changing stuff in the coming weeks. Also it's rarely necessary to actually touch this variable. (cherry picked from commit 120f242)
Previously, we would set GHC_PACKAGE_PATH after configure, the reasons being that 1. Setup.hs configure forbids this from being set since it can make a build fail that would otherwise succeed (since it influences how GHC behaves when invoked by Cabal). 2. Setting GHC_PACKAGE_PATH being set is sound in our case, since we set it precisely to the packages available to Cabal at configure time, so there should be no room for a mismatch. 3. Some test suites require GHC_PACKAGE_PATH or GHC_ENVIRONMENT to be set, so they can invoke GHC(i) with build dependencies available. Cabal >= 3.12 forbids GHC_PACKAGE_PATH from being set after <haskell/cabal@d6e38041a7c778fadf8f416>. Setting GHC_ENVIRONMENT would be possible, but is cumbersome without cabal-install (which has the handy cabal exec command which takes care of that). Additionally, it is not clear if it'll remain possible to do that: <haskell/cabal#7792>. Our solution to Cabal 3.12's change is to be more targeted about setting GHC_PACKAGE_PATH: We _just_ set it for the actual test suite executable. This can be achieved by using --test-wrapper which when given is invoked by Cabal to run the test suite. Here we can set any environment variables after Cabal has already done its environment checks. As long as we don't do anything stupid, this should be unproblematic. Users can also arbitrarily influence what GHC_PACKAGE_PATH will contain using the NIX_GHC_PACKAGE_PATH_FOR_TEST environment variable. This is un(der)documented for now, since I want to keep some wiggle room for changing stuff in the coming weeks. Also it's rarely necessary to actually touch this variable. (cherry picked from commit 120f242)
Currently a bogus
$GHC_ENVIRONMENT
can make cabal fail. Cabal itself could trigger this issue if it's called inside acabal exec
(though this is probably a terrible idea in the first place). Local and default environments instead do not cause any interference.Should we always pass
-package-env=-
to ghc, or set$GHC_ENVIRONMENT
to-
?I think yes:
on the other hand:
The text was updated successfully, but these errors were encountered: