nvm debug output:
No file found
nvm ls output:
v7.7.1
default -> stable (-> v7.7.1)
node -> stable (-> v7.7.1) (default)
stable -> 7.7 (-> v7.7.1) (default)
iojs -> N/A (default)
lts/* -> lts/boron (-> N/A)
lts/argon -> v4.8.0 (-> N/A)
lts/boron -> v6.10.0 (-> N/A)
nvm? (e.g. install script in readme, homebrew):which node
which npm
adduser nodejs
su nodejs
cd ~
wget -qO- https://raw.githubusercontent.com/creationix/nvm/v0.33.1/install.sh | bash
nvm install stable
nvm alias default stable
su nodejs
Error: EACCES: permission denied, scandir '/root'
Error: EACCES: permission denied, open 'npm-debug.log.4042825254'
nvm is not compatible with the npm config "prefix" option: currently set to ""
Run `nvm use --delete-prefix v7.7.1 --silent` to unset it.
su nodejs
node
nvm install stable
node
reboot
su nodejs
node
Note that no commands I'm running are run as su, as I think that's the whole point of it.
So I've that error on the console every time I log to nodejs user, and node stops working every time (it says that it was already installed (after the first time) but the command was not usable). This leads to other consequences and other issues.
.bashrc, .bash_profile, .zshrc, etc) that modifies the PATH?No, I'm testing this on a clean installation just out of a debian 8 netinstall ISO. I've created this VM specifically to test this.
NOTE:
I tried following the same step that I described above, except creating the new user, with the default user that I created with Debian's Graphic Installation. Said user was not root or su (access to the /root folder was in fact denied), and with that user everything worked fine.
This issue appears only with the user I created with "adduser".
I'm trying to repeat the whole process again to confirm this (but I broke the original VM snapshot that I use to create clones to test, so currently I'm reinstalling again).
So what's the difference between a user created during system installation and one created with adduser? I see the user created during system installation has a whole load of files and directories in his /home/"user"/, like Downloads, Documents… while the one created with adduser doesn't have all those fancy directories.
When you su, I believe that doesn't reset environment variables.
Log in directly as the user instead of using su, or re-source the user's profile files after switching, and I'd expect it to work.
How do I "re-source" the user's profile files after switching?
. ~/.bashrc, for example
cd ~
source ~/.bashrc
This worked.
Thanks ljharb.
For others, when switcing users using su the .bashrc wont be sourced. You need to swith to login shell instead of interactive:
su -l $username
Most helpful comment
For others, when switcing users using
suthe.bashrcwont be sourced. You need to swith to login shell instead of interactive:source: https://unix.stackexchange.com/a/29811/16043