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

Win32 support #130

Merged
merged 1 commit into from
Sep 8, 2020
Merged

Win32 support #130

merged 1 commit into from
Sep 8, 2020

Conversation

newhoggy
Copy link
Member

@newhoggy newhoggy commented Sep 2, 2020

Add support for Windows. See #129

@newhoggy newhoggy mentioned this pull request Sep 2, 2020
)
<*> strOption
( long "store-path"
<> help "Path to cabal store"
<> metavar "DIRECTORY"
<> value (homeDirectory </> ".cabal" </> "store")
<> value (dotCabalDirectory </> "store")
Copy link
Contributor

Choose a reason for hiding this comment

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

The store is not always in .cabal/store. Specifically, on windows, it's often been seen as a good idea to relocate the store to the root of the C drive to help prevent and work around long path issues (as well as APPDATA generally not being the best default for that). The haskell setup github action does this by setting the store path to C:\sr (a convention adapted previously by others, such as Stack).

This raises a few difficulties, because cabal doesn't have a sane way to query its configuration by calling the binary. The location of the store is given inside cabal's configuration file or the default. The default is .cabal/store but the cabal directory itself can have its location modified by an environment variable. The gory details are here

Cabal, the library, contains functions that will do the heavy lifting for you, but it's also quite heavyweight. Looking for the configuration file, reading it, and then determining the store from there (falling back to the default location otherwise) seems like the safest course of action if you don't want to use the cabal library.

A hacky one might be to check for the existence of cabal's store in a few hardcoded locations (eg ~/.cabal/store for linux and macos, and $env:AppData\cabal\store and C:\sr for windows.). Can't imagine the hacky solution being robust enough to be relied on, though.

Copy link
Member Author

Choose a reason for hiding this comment

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

dotCabalDirectory is actually missed named. It should actually just be cabalDirectory.

The value will be $HOME/.cabal on Posix and $APPDATA/cabal on Windows.

For cases where it is neither of these, the CI system can pass it in as a command line argument using --store-path.

@newhoggy newhoggy force-pushed the win32-support branch 2 times, most recently from bc7992f to 8fe2d5e Compare September 3, 2020 11:19
@newhoggy
Copy link
Member Author

newhoggy commented Sep 3, 2020

I've verified this can sync to and from a local directory. I've not tested remote yet, but I don't see a reason why that shouldn't just work. If you like you can give this a spin and let me know if you encounter any issues.

@newhoggy
Copy link
Member Author

newhoggy commented Sep 8, 2020

Confirmed that remote sync on Windows works.

@newhoggy newhoggy merged commit ff8a594 into master Sep 8, 2020
@newhoggy newhoggy deleted the win32-support branch September 8, 2020 10:01
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