在 Windows (7 x64) 上处理 Ruby on Rails 项目,我现在想更进一步,将 vagrant 与 VirtualBox 一起用于类似开发环境的产品。
基于专用RailsCast tutorial ,然后发现现在 Vagrant 将使用他们的安装程序而不是 gem install vagrant
进行安装,我终于得到了(Ubuntu)精确32 vagrant provided box启动并运行\o/
我的问题是,如果我执行 vagrant halt
在主机上,下次我会做一个vagrant up
(即使没有改变任何东西),加载的系统不再了解 Ruby 了!
这是我在安装所需的 apt-get 后所做的:
cd ~
git clone git://github.com/sstephenson/rbenv.git ~/.rbenv
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.profile
echo 'eval "$(rbenv init -)"' >> ~/.profile
source .profile
git clone git://github.com/sstephenson/ruby-build.git
cd ruby-build/
sudo ./install.sh
rbenv install 1.9.3-p327
rbenv rehash
rbenv global 1.9.3-p327
ruby -v
我究竟做错了什么 ?
最佳答案
When bash is invoked as an interactive login shell, or as a non- interactive shell with the --login option, it first reads and executes commands from the file /etc/profile, if that file exists. After reading that file, it looks for ~/.bash_profile, ~/.bash_login, and ~/.profile, in that order, and reads and executes commands from the first one that exists and is readable. The --noprofile option may be used when the shell is started to inhibit this behavior.
如果 你有
~/.bash_profile
或 ~/.bash_login
到位,防止您的~/.profile
从被阅读。 rbenv 永远不会被初始化,所以 ruby 似乎丢失了。将它们放在
~/.bash_profile
应该在后续登录时保持 ruby 可见。
关于Ruby 在 Vagrant box 上停止后消失了,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16718049/