I'm trying to get su
to source /home/ghost/.bashrc
, but it doesn't seem to load the contents:
$ su -l -c 'source /home/ghost/.bashrc; nvm' ghost
-su: nvm: command not found
I use nvm to manage Node versions. Nvm is normally sourced by the ghost
user in /home/ghost/.bashrc
:
# in /home/ghost/.bashrc
export NVM_DIR="/home/ghost/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" # This loads nvm
I found from these questsions that putting the nvm
init code in /home/ghost/.profile
makes nvm
available to su -l
since it starts a login shell.
I still can't figure out why I can't source
the file explicitly. Can anybody tell me why?
nvm.sh
, notnvm
. Also you don't need-l
:su -c 'source /home/ghost/.bashrc; nvm.sh' ghost
nvm
. At least, that's what they suggest in their README. EIther way, that command doesn't work either unless I put thenvm
init stuff in~/.profile
. For some reason I can't source anything explicitly fromsu -c
.nvm
means that the file is not being sourced? Where isnvm
, and does /home/ghost/.bashrc add that location to thePATH
? if so, how?"$NVM_DIR/nvm.sh"
was used to start it automatically.ls -ld /home/ghost/.nvm/nvm.sh