Skip to content
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

Update GHC environment location (fixes #6565) #6822

Merged
merged 3 commits into from
Jun 3, 2020
Merged

Update GHC environment location (fixes #6565) #6822

merged 3 commits into from
Jun 3, 2020

Conversation

vituscze
Copy link
Contributor

cabal-install currently assumes that the GHC environment files are always located in $HOME/.ghc/. However, GHC itself doesn't query the home directory directly. Instead, it uses getAppUserDataDirectory "ghc" (GHC code, getAppUserDataDirectory) which happens to coincide with $HOME/.ghc/ on UNIX systems. On Windows, however, GHC ends up looking in %APPDATA%/ghc/.

As a result, cabal install --lib doesn't change the correct environment files on Windows.

This PR changes the environment file locations to match GHC. On UNIX, there is no change since getAppUserDataDirectory "ghc" is defined as (</> ".ghc") <$> getHomeDirectory. On windows, I have confirmed that cabal-install changes the correct GHC environment file with this PR.


Please include the following checklist in your PR:

  • Patches conform to the coding conventions.
  • Any changes that could be relevant to users have been recorded in the changelog (add file to changelog.d directory).
  • The documentation has been updated, if necessary.

Previously, cabal-install assumed that the default GHC environments are
located in $HOME/.ghc/ on all systems. However, on Windows, GHC looks
for environments in %APPDATA%/ghc/
@phadej
Copy link
Collaborator

phadej commented May 19, 2020

FWIW, the GHC documentation is then incorrect, https://downloads.haskell.org/~ghc/latest/docs/html/users_guide/packages.html#package-environments explicitly mentions $(HOME)

cf. the package databases section which says https://downloads.haskell.org/~ghc/latest/docs/html/users_guide/packages.html#package-databases

The user package database private to each user. On Unix systems this will be $HOME/.ghc/arch-os-version/package.conf.d, and on Windows it will be something like C:\Documents And Settings\user\ghc\package.conf.d.

cc @bgamari

I suspect that GHC indeed relies on getAppUserDataDirectory, but that should be somehow be reflected in the manual. (And I have to check what we say about ~/.cabal in our manual).


That said, this PR is good.

We should move the logic of finding GHC environment file directory somewhere in Distribution.Simple.GHC, https://hackage.haskell.org/package/Cabal-3.2.0.0/docs/Distribution-Simple-GHC.html#g:1 has already some logic there. If you could do that, that would be great. Otherwise I'll do that later. (The location can in theory change for different GHCs, hopefully it doesn't, but better to have an API taking that into account - same as we decide between package-db and package-conf flag).

@phadej phadej added this to the 3.4.0.0 milestone May 19, 2020
@vituscze
Copy link
Contributor Author

@phadej
Copy link
Collaborator

phadej commented May 20, 2020

@vituscze I'd rather go for simpler getGhcAppDirectory :: IO FilePath. We already have two getAppUserDataDirectory "ghc" in the code. replace that one with single getGhcAppDirectory (and use it in your patch).

if GHC sometimes decide to change its mind about where to place files, we'd need to change it only in one place.

@phadej phadej merged commit 2f3152c into haskell:master Jun 3, 2020
@phadej phadej mentioned this pull request Jul 10, 2020
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.

2 participants