nvm
nvm copied to clipboard
installation of nvm with XDG variables sets doesn't seem to use a subdirectory
Hey,
I tried to install nvm according to the README and my environment contains a few XDG variables, like
declare -x XDG_CACHE_HOME="$HOME/.cache"
declare -x XDG_CONFIG_HOME="$HOME/.config"
declare -x XDG_DATA_HOME="$HOME/.local/share"
The installation (using bash) took place inside of the .config
directory - was used as root Git directory. Could it be possible that /nvm
should not be part of the variable scoping - bash parameter substitution?
https://github.com/creationix/nvm/blob/2410215b6a96c5a4376af8a41b6e2942b4b6cc2d/install.sh#L11
$ echo "${XDG_CONFIG_HOME}"
$HOME/.config
$ echo "${XDG_CONFIG_HOME/nvm}"
$HOME/.config
$ bash --version
GNU bash, version 4.4.12(1)-release (x86_64-pc-linux-gnu)
Copyright (C) 2016 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html> This is free software; you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Cheers
That seems like a likely typo indeed :-)
#2035
I stumbled upon this right now, too. On Raspbian Buster XDG_CONFIG_HOME
is set to /home/pi/.config
making NVM install itself to .config and as a consquence breaking a script of mine, that should setup NVM+Node.
Another note:
$XDG_CONFIG_HOME
defines the base directory relative to which user specific configuration files should be stored. If$XDG_CONFIG_HOME
is either not set or empty, a default equal to$HOME/.config
should be used. (spec)
nvm
should not require the variable to be defined in order to act in a XDG-compliant way.
I'm not interested in complying to that level with XDG; nvm's config is stored in $HOME/.nvm
. Overriding $NVM_DIR
, or setting XDG variables, is a niche and power user feature that I'm happy to support - but the defaults won't be changed.
Separately, the spec says "should", not "must", which means it's not mandatory to do so - so nvm isn't in violation of the XDG spec here.
:ok_hand:
Non-power users are the ones that benefit most from defaults, and it seems like an easy step towards a tidier world, but I do appreciate that there's a lot of ~/.nvm
out there already ...
but I do appreciate that there's a lot of
~/.nvm
out there already ...
I don't get it, respecting XDG spec just make your stuff much cleaner, there is already enough programs that are not compliant, which makes you always looking for workarounds.
Cleaner is subjective - i don’t find it cleaner for myself.
@ftang001 that issue was fixed in 3cc9525d and released in v0.35.0, over two years ago. v0.39.0 shouldn't have this issue.
Perhaps you're using an outdated version number in your nvm install command?
Thank you. Yes sorry my bad ... a long night and I failed to note that the script I was using had fixed on v0.34.0; I misread the last comments here as "won''t fix". Apologies.
I think it is better to ignore $XDG_CONFIG_HOME
completely compared to the way it is right now.
I have set $XDG_CONFIG_HOME
because I want all my configuration files to go in there not all files a program needs to run.
Arch wiki suggests $XDG_DATA_HOME
for that.
export NVM_DIR="$XDG_DATA_HOME"/nvm
Btw I think the xdg spec makes a lot of sense and nvm should support it. Backing up your system would be so much easier...
nvm already supports it; anything that’s a “should” and not a “must” is up to the implementer, and I’ve made my choices.
Backing up your system is already trivial: back up all of $HOME, plus whatever you’ve chosen to install outside of $HOME, and you’re done. XDG has no impact on that.