~/.bash_profile not being loaded?
See original GitHub issueHey there, not sure if this is the best place to ask but I thought I’d try.
I just setup a basic micro instance on EC2 on ubuntu 12.04, and then installed node like this (modified from here):
sudo apt-get update
sudo apt-get install build-essential -y
sudo apt-get install g++ make libssl-dev git-core pkg-config
mkdir ~/local
echo 'export PATH=$HOME/local/bin:$PATH' >> ~/.bash_profile
. ~/.bash_profile
# Download Source for Node
mkdir ~/src
cd ~/src
git clone git://github.com/joyent/node.git
# Install Node:
cd ~/src/node
git checkout v0.10.17
./configure --prefix=~/local
make install
When I ssh into the instance and run node -v
, it prints v0.10.17
as expected. I ssh like this:
ssh -i path/to/key.pem ubuntu@ec2-123-123-123-123.compute-1.amazonaws.com
But when I try to do the same thing using this ssh2 module, it prints:
bash: node: command not found
The main difference between the two is this: when I ssh -i ...
, it takes me to an interactive shell, whereas with node’s ssh2 module I am executing the command (rather than running an interactive shell, I think, (exec vs. shell methods)). The strange thing is, using either method, if I cat ~/.bashrc
, they both are exactly the same. The last thing is, I can successfully execute the node -v
command on ssh2 if I add source ~/.bash_profile
before, so:
source ~/.bash_profile ; node -v
The original install script echoed the PATH
to ~/.bashrc
, but I modified it to ~/.bash_profile
because that was the only thing that seemed to work (along with adding the source ~/.bash_profile
to the command).
Any ideas why this is happening? Is this something to do with ssh2 and ubuntu, or is this an issue with the node module?
Issue Analytics
- State:
- Created 10 years ago
- Comments:11 (2 by maintainers)
@pkyeck You may have to check your
.bashrc
. At least on Ubuntu,.bashrc
will exit early if it detects that it’s not being run in interactive mode:You could try just setting PS1 before
source
ing.bashrc
:@mscdex Didn’t work for me even with
pty
enabled, this was my case:This is the begging of my
.bashrc
file:Setting the interactive flag before
source
-ing the.bashrc
file was the only way to do it.