I am attempting to write a bash script that will install rbenv from beginning to end. I am on a Mac for interest sake.
But there are some things that are not working mainly i am changing the directory but only in the subshell.
#!/bin/bash
echo "installing rbenv ruby manager manager"
cd ~
git clone git://github.com/sstephenson/rbenv.git .rbenv
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bash_profile
echo 'eval "$(rbenv init -)"' >> ~/.bash_profile
source .bash_profile
echo "installing ruby build for rbenv"
git clone https://github.com/sstephenson/ruby-build.git
cd ruby-build
sudo ./install.sh
echo "rbenv and ruby-build have been installed, installing ruby now.."
sleep 2
read -p "would you like chronospere to install ruby 1.9.3 [y/n]" RESP
if [ "$RESP" = "y" ]; then
rbenv install 1.9.3-p327
rbenv rehash
rbenv global 1.9.3-p327
ruby -v
else
echo "alrigt skipping.. vagrant has rbenv installed you can install ruby it at your leisure "
echo "hold cmd, and double clck https://github.com/sstephenson/rbenv for more info"
fi
cd ~
So it seems as if installing it works. But most of my code does not get run, or doesn't get run in the place I'd like it to.
vagrant@precise64:/vagrant$ ruby -v
ruby 1.8.7 (2012-02-08 patchlevel 358) [x86_64-linux]
vagrant@precise64:/vagrant$ rbenv
The program 'rbenv' is currently not installed. You can install it by typing:
sudo apt-get install rbenv
As you can see its as if nothing was installed. The source .bash_profile
never happened
vagrant@precise64:/vagrant$ cd
vagrant@precise64:~$ cd ~
vagrant@precise64:~$ source .bash_profile
After I manually source the bash_profile,
vagrant@precise64:~$ rbenv
rbenv 0.4.0-45-g060f141
vagrant@precise64:~$ rbenv versions
* system (set by /home/vagrant/.rbenv/version)
1.9.3-p327
vagrant@precise64:~$ rbenv global 1.9.3-p327
vagrant@precise64:~$ ruby -v
ruby 1.9.3p327 (2012-11-10 revision 37606) [x86_64-linux]
So as you can see its as if the code is running just not moving from one directory to the next. I don't even know if this is possible with in a bash script. I move from ~ / (HOME)
to /ruby-build
back to ~
then to /vagrant
. Is this possible in a single bash script. this is weird because if I open the terminal and run that code line by line it works 100%.
source
your install script, the thingssource
d in there will not be propagated to the parent shell. – l0b0 May 30 '13 at 09:28