yarnpkg / yarn

The 1.x line is frozen - features and bugfixes now happen on https://github.com/yarnpkg/berry
https://classic.yarnpkg.com
Other
41.4k stars 2.73k forks source link

yarn incorrectly uses $XDG_DATA_HOME for `linkFolder` #9029

Open asottile-sentry opened 8 months ago

asottile-sentry commented 8 months ago

yarn's default for linkFolder is in the default for $XDG_CONFIG_HOME:

$ yarn config current | grep linkFolder
  "linkFolder": "/Users/asottile/.config/yarn/link",

the default for XDG_CONFIG_HOME is ~/.config

applying XDG_DATA_HOME changes the value of linkFolder even if XDG_DATA_HOME is set to the default:

$ XDG_DATA_HOME=$HOME/.local/share yarn config current | grep linkFolder
  "linkFolder": "/Users/asottile/.local/share/yarn/link",

this appears to be two bugs -- fixing either would resolve this:

Daniel15 commented 4 months ago

Good point, and in fact there's a comment in the code that alludes to this:

https://github.com/yarnpkg/yarn/blob/158d96dce95313d9a00218302631cd263877d164/src/util/user-dirs.js#L19-L21

I think the old fallback was kept for backwards compatibility.

The XDG spec says:

$XDG_DATA_HOME defines the base directory relative to which user-specific data files should be stored. If $XDG_DATA_HOME is either not set or empty, a default equal to $HOME/.local/share should be used.

So it should be falling back to .local/share/yarn/link.