-
Notifications
You must be signed in to change notification settings - Fork 132
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
Simplify getGlobalCacheDir, change Windows default #384
Conversation
Ok CI has failed; I will look into it... |
Thanks @stkb! Some context and a few comments on this:
|
Simplifies the getGlobalCacheDir function by using `Directory.getXdgDirectory`, which does most of the work for us. On Linux/MacOS, behavior isn't changed: will search for `$XDG_CACHE_HOME`, then `$HOME`. Falls back to a `.spago-global-cache` folder within the project folder if neither exist. On Windows, the default (if no `XDG_CACHE_HOME` exists) is changed to `%LOCALAPPDATA%`, which really is the "correct" place (in line with Windows conventions) rather than `~/.cache`. This also fixes the bug with using `%HomePath% (purescript#380). Also removed the error message that wan't being used any more.
Addendum: it's also interesting to see how Pulp does this: they search for |
Thanks @f-f for all the explanation. Have:
Linux & Windows is now passing, but MacOS still failing on the build plan. BTW, I'm not sure if the Re: how Pulp does it: yeah |
@stkb I'll try your branch on my Mac, one sec |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I left a suggestion that should fix CI, but otherwise looks great, thanks! 🙂
Co-Authored-By: Fabrizio Ferrai <fabrizio.ferrai@gmail.com>
@f-f The build succeeded with that change so I have merged 😃. I still don't know about |
@stkb thanks! And no worries, if CI says it's good then it's good 😄 (I'll update the lockfile in the next commits) Stack started creating/updating the lockfiles from version 2 on, so I suspect you're using a pre-2.0 version |
Simplifies greatly the getGlobalCacheDir function by using
Directory.getXdgDirectory
, which does most of the work for us.On Linux/MacOS, behavior isn't changed: will search for
$XDG_CACHE_HOME
, then$HOME
, and will error if neither are found.*On Windows, the default (if no
xdg_cache_home
exists) is changed to%LOCALAPPDATA%
. This is really the "correct" place for it on Windows (rather than~/.cache
) to be a good citizen.It no longer checks for/uses
$HOME
on Windows, but I'd argue that isn't necessary: if you want it the *nixy way, you can just set$xdg_cache_home
instead (as I do). Should also fix #380.*Now something I didn't quite understand was the alternative3 case in the original code.
https://github.com/spacchetti/spago/blob/13cf90cddb1e3e2b7338169d98799b6bc6a54ffe/src/Spago/GlobalCache.hs#L149-L178
At the end of the first line you have
alternative₃ <|> err
, but alternative3 can't fail, so the error message will never be shown?So I don't know which outcome is intended if neither
$xdg_cache_home
nor$home
are found: use a.spago-global-cache
folder (in the project folder?), or show an error message; so I just went with the error message for now, which I've also modified, since it no longer applies to Windows.Will have to see if this works on the CI...
Checklist:
(Will do after review)