Skip to content

Conversation

@snoyberg
Copy link
Contributor

@snoyberg snoyberg commented Apr 9, 2019

CC @phadej @tfausak

This fixes #4706. Since GHC 8.0, GHC will now implicitly read in from a
.ghc.environment.* file, which can cause commands like stack exec ghci
to fail. Due to the use case of stack exec, it doesn't make sense to
try to create our own environment file, but instead tell GHC to ignore
it. Unfortunately, the ability to ignore environment files was only
added in GHC 8.4.4. This patch:

  • Unsets any GHC_ENVIRONMENT variable already set outside of Stack
  • When using GHC 8.4.4 or later, sets the variable to -

This will help work around situations where cabal new-build creates an
environment file without the user's awareness. This may be somewhat
superfluous in the future depending on changes to either GHC or
cabal-install, but shouldn't present any harm for the foreseeable future
(unless GHC changes its understanding of GHC_ENVIRONMENT).

Note: Documentation fixes for https://docs.haskellstack.org/en/stable/ should target the "stable" branch, not master.

Please include the following checklist in your PR:

  • Any changes that could be relevant to users have been recorded in the ChangeLog.md
  • The documentation has been updated, if necessary.

Please also shortly describe how you tested your change. Bonus points for added tests!

This fixes #4706. Since GHC 8.0, GHC will now implicitly read in from a
.ghc.environment.* file, which can cause commands like `stack exec ghci`
to fail. Due to the use case of `stack exec`, it doesn't make sense to
try to create our own environment file, but instead tell GHC to ignore
it. Unfortunately, the ability to ignore environment files was only
added in GHC 8.4.4. This patch:

* Unsets any `GHC_ENVIRONMENT` variable already set outside of Stack
* When using GHC 8.4.4 or later, sets the variable to `-`

This will help work around situations where `cabal new-build` creates an
environment file without the user's awareness. This may be somewhat
superfluous in the future depending on changes to either GHC or
cabal-install, but shouldn't present any harm for the foreseeable future
(unless GHC changes its understanding of `GHC_ENVIRONMENT`).
Copy link
Contributor

@mihaimaruseac mihaimaruseac left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks

@snoyberg snoyberg merged commit 09b1a51 into master Apr 9, 2019
@mihaimaruseac mihaimaruseac deleted the 4706-ignore-ghc-env-files branch April 9, 2019 18:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fix potential bug in Stack failing to properly isolate pkg-db environment

3 participants