Closed nleush closed 9 years ago
So i've just come across this same issue and for some reason the pm2 deploy command is ignoring both .bashrc files and .profile files for the user that it is connecting with. I assume this is because it's not creating a full bash session (or something)
To get this to work i edited the /etc/environment
file to include the bin folder from my node install which in my case is: /usr/local/lib/iojs-v1.6.2-linux-x64/bin/
The ssh connection from pm2 is not interactive. See: https://github.com/Unitech/pm2-deploy/issues/33
Same here.
Btw... the easiest way to resolve this is to open your .bashrc
and comment out these lines:
# If not running interactively, don't do anything
case $- in
*i*) ;;
*) return;;
esac
Pm2 is not using interactive ssh.
Yes or just load nvm at the very beginning of your .bashrc
Thanks for this @xpepermint! I've updated this in my guide here too, under the section "Set up SSH for SemaphoreCI": http://niftylettuce.com/posts/automated-node-app-ci-graceful-zerodowntime-github-pm2/
@Unitech Did you want to link to this comprehensive guide somewhere in the PM2 docs? I think it'd be helpful.
Move the following lines to the top of .bashrc
export NVM_DIR="/root/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" # This loads nvm
@oney indeed moving the "nvm" or "n" EXPORT path to the top of .bashrc sorted out this issue, but that's very inconvenient :S
I tried doing everything above but it didn't work. Probably because of my lack of understanding of concepts related to sym links. I fixed the issue by not using nvm. I just created a new ec2 instance and didn't install nvm. Instead I installed node and npm like so:
sudo apt update
sudo apt install nodejs npm
And this did it for me. For my appspec.yml, pm2 ecosystem file and other scripts, check out my answer: https://stackoverflow.com/a/68135733/14537951
There any methods for Zsh?I've tried add the nvm export to the top of both ~/.bashrc and ~/.zshrc, it both doesn't work, really confused about the non-interactive mode.
'npm', 'node' and 'pm2' works well from user 'ubuntu' on remote host. But when deploy, post-deploy hook can't see that commands using same user.
Also important thing: NVM is used to manage node, so all commands are behind /home/ubuntu/.nvm/v0.10.21/bin
Also tried:
and restarted server.
Log:
Any suggestions? Thanks.