1
我試圖寫一個bash腳本,將安裝rbenv從開始到結束bash腳本自動rbenv安裝
但有沒有工作主要是我改變了目錄,但只在子shell出頭。
#!/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 ~
所以它好像安裝它的工作。但我的大部分代碼dosent得到運行,或沒有得到運行的地方id喜歡它。
[email protected]:/vagrant$ ruby -v
ruby 1.8.7 (2012-02-08 patchlevel 358) [x86_64-linux]
[email protected]:/vagrant$ rbenv
The program 'rbenv' is currently not installed. You can install it by typing:
sudo apt-get install rbenv
,你可以看到它,就好像什麼也沒有隻安裝了什麼事是,source .bash_profile
從來沒有發生過
[email protected]:/vagrant$ cd
[email protected]:~$ cd ~
[email protected]:~$ source .bash_profile
後,我手動源的.bash_profile
[email protected]:~$ rbenv
rbenv 0.4.0-45-g060f141
[email protected]:~$ rbenv versions
* system (set by /home/vagrant/.rbenv/version)
1.9.3-p327
[email protected]:~$ rbenv global 1.9.3-p327
[email protected]:~$ ruby -v
ruby 1.9.3p327 (2012-11-10 revision 37606) [x86_64-linux]
所以你可以看到它的代碼正在運行,而不是從一個目錄移動到另一個目錄。我甚至不知道這是否可能。我從〜/(HOME)移動到/ ruby-build回到〜然後到/ vagrant。這是可能的在一個單一的bash腳本。