Every now and then, my colleagues run into problems with scripts which invoke ghc directly getting confused because they happen to have a global package environment file at $XDG_DATA_HOME/ghc/arch-os-version/environments/default (whereas most people at my work don’t have one of these). I recently learned that ghc reads this file by default if it exists, which seems to just mess things up if you’re in any kind of cabal project, or just generally if you’re not expecting ghc to use this global configuration. Right now, it seems like you have to remember to pass -hide-all-packages or -package-env=- pretty much whenever you’re invoking ghc directly, which is a bit inconvenient.
The global package environment file is clearly not well-loved by the community either; see, eg:
- Global configuration of default packages - #12 by tomjaguarpaw
- Add a warning when an env file is created (backport #9705) by mergify[bot] · Pull Request #9895 · haskell/cabal · GitHub
Is it feasible to just do away with the global default package environment? I’m imagining changing ghc so that it would stop reading that file by default if it exists, and that you could still opt in to having ghc read that file by passing -package-env default or by setting GHC_ENVIRONMENT=default.
My guess would be that most recent-ish haskell tutorials don’t rely on this behaviour (especially since this behaviour is now opt-in via cabal’s --lib flag) and it wouldn’t be particularly difficult to work around in the places that do?