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

cabal-install-parsers: support XDG #655

Open
fgaz opened this issue Apr 3, 2023 · 16 comments
Open

cabal-install-parsers: support XDG #655

fgaz opened this issue Apr 3, 2023 · 16 comments

Comments

@fgaz
Copy link

fgaz commented Apr 3, 2023

(From haskell-hvr/cabal-plan#92)

cabal-install 3.10 uses XDG paths. For example in my system the config file is ~/.config/cabal/config and the store is ~/.local/state/cabal/store. Cabal.Config:readConfig does not return the correct paths.

To know whether to enable XDG support, cabal-install first looks at $CABAL_DIR. If that variable is set, everything will be in there, as before. Otherwise, it checks whether $XDG_CONFIG_HOME/cabal and ~/.cabal exist, and enables or disables XDG support. If both are present, ~/.cabal takes priority, but that's considered a mistake and likely to change: haskell/cabal#8577

You can find a list of paths here and here. See also the relevant functions from the directory package.

In the future, something like this could be used: haskell/cabal#8879

@phadej
Copy link
Collaborator

phadej commented Aug 23, 2023

TBH, this situations just sucks, so I'd suggest to define CABAL_CONFIG environment variable and have your cabal config files specify the pathes, then you won't rely on any implicit, which change between cabal-install versions.

but that's considered a mistake and likely to change:

That remark is specifically makes me don't want to do anything with this issue,. In fact, I'm even considering making cabal-install-parsers fail if CABAL_CONFIG environment variable is not set.

@hasufell
Copy link
Contributor

TBH, this situations just sucks, so I'd suggest to define CABAL_CONFIG environment variable and have your cabal config files specify the pathes, then you won't rely on any implicit, which change between cabal-install versions.

but that's considered a mistake and likely to change:

That remark is specifically makes me don't want to do anything with this issue,. In fact, I'm even considering making cabal-install-parsers fail if CABAL_CONFIG environment variable is not set.

This response makes no sense.

cabal-install-parsers is broken. Whether you like the cabal config discovery logic or not.

So either fix it or stop providing this API so that you don't break other downstream tools like ghcup, which assume that dependencies are reasonably maintained.

@phadej
Copy link
Collaborator

phadej commented Jun 29, 2024

stop providing this API

Am I forcing you to use it?

@hasufell
Copy link
Contributor

hasufell commented Jul 1, 2024

stop providing this API

Am I forcing you to use it?

Are you deliberately providing broken API?

@phadej
Copy link
Collaborator

phadej commented Jul 1, 2024

Are you deliberately providing broken API?

No. Just outdated, there is a known limitation.

The OP wrote

but that's considered a mistake and likely to change

are there still plans to change it? The 3.10 and 3.12 documentation seems to be the same.


@hasufell your tone is not motivating me to look into this issue any time soon.

@hasufell
Copy link
Contributor

hasufell commented Jul 1, 2024

@hasufell your tone is not motivating me to look into this issue any time soon.

No one asked you to work on this. People can provide PRs.

Your response suggests:

  • you don't care whether your packages are buggy
  • you don't care whether your packages break Haskell core tooling
  • you're not interested in collaboration

In that case that's a good reason to avoid any of your packages in the future.

@tchoutri
Copy link

tchoutri commented Jul 1, 2024

@phadej If you proceed with it, how will you warn Haskell-CI users?

@phadej
Copy link
Collaborator

phadej commented Jul 1, 2024

How will you warn Haskell-CI users?

About what? haskell-ci doesn't use cabal configuration file discovery.

@tchoutri
Copy link

tchoutri commented Jul 1, 2024

Ok, so that would entirely be confined to direct users of cabal-install-parsers. Thank you for clarifying.

@Bodigrim
Copy link

are there still plans to change it? The 3.10 and 3.12 documentation seems to be the same.

It seems the change has landed before 3.12, in 3.10.2.0:

@phadej does it help you to make your mind one way or another?

@phadej
Copy link
Collaborator

phadej commented Jan 5, 2025

@Bodigrim no. It actually makes the issue worse.

The * Configuration file discovery* section says

otherwise use config in $XDG_CONFIG_HOME/cabal, which defaults to ~/.config/cabal on Unix.

However the next section talks about "Unless the CABAL_DIR environment variable is set or a ~/.cabal directory exists, "

So it's completely unclear whether ~/.cabal/config is read if it exists or not.


With my quick tests it does

% cabal update   
Warning: /home/phadej/.cabal/config: Unrecognized stanza on line 1

EDIT: based on documentation the ~/.cabal/config should never be read. This is clearly an issue.

So the documentation (or maybe still the implementation) is wrong. I will hold up on this issue until I see an agreement in behavior.

@phadej
Copy link
Collaborator

phadej commented Jan 5, 2025

Amendment: until then (and afterwards) I will use explicit CABAL_CONFIG environment variable, and suggest that you set one for yourself too.

@hseg
Copy link

hseg commented Jan 8, 2025

Even with CABAL_CONFIG properly set, the logic still isn't adapted for
cabal's XDG support. Note 3.1.3 states, for example:

Unless the CABAL_DIR environment variable is set or a ~/.cabal directory
exists, Cabal will by default store data in directories according to the XDG
Base Directory specification.
...

  • $XDG_STATE_HOME/cabal for compiler libraries and other stateful artifacts,
    including the Cabal store.

In particular, the assumption that all these data directories are subdirectories
of ~/.cabal is incorrect, making eg findCabalDir semantically incorrect.

This in particular breaks cabal-plan's attempt to look up the Cabal store.

The one workaround I found for this is to explicitly configure the fields from
cabal path (though caveat -- compiler-path and cache-home don't seem to
have corresponding settings?). This is annoying, masks the defaults (meaning if
I want to follow cabal's default hierarchy, I need to recheck the paths every
so often), and pollutes my configs (I need to keep CABAL_CONFIG around, I need
to keep this manual restatements around).

Please reconsider.

@phadej
Copy link
Collaborator

phadej commented Jan 8, 2025

Please reconsider.

See the linked issue.

As I said, the documentation and behavior of cabal-install don't correspond:

So the documentation (or maybe still the implementation) is wrong. I will hold up on this issue until I see an agreement in behavior.


Hmm, so the paths are not written in default config file. it's surprising, as I'm quite sure they used to be. But I can only test cabal-3.6, and that one only writes the location of few directories, but not e.g. store-dir. That's weird.

@phadej
Copy link
Collaborator

phadej commented Jan 8, 2025

haskell/cabal#10727 slightly related.

@phadej
Copy link
Collaborator

phadej commented Jan 8, 2025

I realised that this will also require a bit of changes in cabal-install-parsers, as findCabalDir is not gonna work anymore: there are different root directories for different stuff, i.e. in the XDG-configuration there isn't really a notion of the cabal dir.

Luckily findCabalDir is not exported, so the update won't require breaking API changes.

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

No branches or pull requests

6 participants