haskell / actions

Github actions for Haskell CI
147 stars 54 forks source link

Output `cabal-store`: Use XDG directory structure for cabal 3.10? #210

Closed andreasabel closed 1 year ago

andreasabel commented 1 year ago

Newly released cabal 3.10.1.0 uses the XDG directory structure unless a ~/.cabal is already present. From https://github.com/haskell/cabal/blob/master/release-notes/cabal-install-3.10.1.0.md#significant-changes:

Cabal/cabal-install now uses the XDG Base Directory Specification to store configuration, caches, and the store. Specifically,$XDG_CONFIG_HOME/cabal stores the configuration file,$XDG_CACHE_HOME/cabal stores downloaded packages and similar, and $XDG_STATE_HOME/cabal mainly contains the store of compiled packages. Further, cabal install will put executables in ~/.local/bin by default.

The dist/dist-newstyle directories are not affected.

On Windows, these XDG paths are mapped to other (hopefully) appropriate locations. See the Cabal User Guide for information.

If the CABAL_DIR environment variable is set, the indicated directory will be used to store all Cabal-related files, as in previous versions.

Backwards compatibility: If ~/.cabal already exists, this will be interpreted as CABAL_DIR=~/.cabal. This means that upgrading on an existing system already using cabal-install should not cause any change in behaviour. An existing system can be migrated by deleting ~/.cabal (possibly copying ~/.cabal/config to ~/.config/cabal/config first).

We likely need to adapt the cabal-store output to respect this change or make sure stuff lands in ./~cabal as it used to be: https://github.com/haskell/actions/blob/86bd3eda129ecad970079574dd4001961be531f8/setup/src/setup-haskell.ts#L61-L67

Upstream issue:

andreasabel commented 1 year ago

Caching failure due to this problem in the wild:

andreasabel commented 1 year ago

Workaround: mkdir -p ~/.cabal before running the setup action. See e.g.: https://github.com/agda/agda/commit/c5f700c5dc009363820f99851cec8aff86ea943a :

    steps:
    - uses: actions/checkout@v3

    - name: Switch off XDG directories for cabal (Linux)
      if: ${{ runner.os == 'Linux' }}
      run: |
        mkdir -p ~/.cabal
      # The presence of ~/.cabal switches cabal 3.10 to not use the XDG layout.

    - uses: haskell/actions/setup@v2
athas commented 1 year ago

I believe setting CABAL_DIR=$HOME/.cabal is the cleanest solution. CI tools don't benefit from the XDG split anyway, and perhaps ten years from now the backwards compatibility based on ~/.cabal existing may be removed.

andreasabel commented 1 year ago

@athas wrote:

I believe setting CABAL_DIR=$HOME/.cabal is the cleanest solution.

Thanks!

@Mikolaj @ulysses4ever If I integrate CABAL_DIR=$HOME/.cabal into the setup action, then we won't be able to CI the XDG feature for cabal. Opinions?

Mikolaj commented 1 year ago

@Mikolaj @ulysses4ever If I integrate CABAL_DIR=$HOME/.cabal into the setup action, then we won't be able to CI the XDG feature for cabal. Opinions?

Please go ahead. When we want to switch to XDG, we'll find a way around, e.g., we'd empty the env variable.

ulysses4ever commented 1 year ago

This option was meant to be disruptive. (In the hindsight, https://github.com/haskell/cabal/issues/8577 perhaps had a good idea for managing some of the disruption.) In the interest of damage management, I'd say, forcing the old way in the CI sounds fine. Maybe a more principled solution would be to make another action parameter for whether or not to do what you suggest (and by default indeed do that). Although, not many users would be interested in such partner, perhaps, and it's a code that you need to maintain... All in all, it's your call. Erroring on the safe side is perhaps preferable.

ulysses4ever commented 1 year ago

e.g., we'd empty the env variable

Well, I'm afraid if the action explicitly set it, we won't be able to do anything. Except, as I do in haskell/cabal#8840, opt out of cabal update in the action altogether.

andreasabel commented 1 year ago

For now, I settled for the workaround that creates ~/.cabal, because this fits more smoothly into the current code of the action.
If we need some parametrization, we can add it later. For now, I just worry to extinguish the wildfires.

Released as latest and v2 (not yet as v2.3 or v2.3.6).