Ruby 在 Vagrant box 上停止后消失了

标签 ruby ubuntu vagrant rbenv

在 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

我究竟做错了什么 ?

最佳答案

来自 Ubuntu's bash man page :

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/

相关文章:

linux - 无法通过ssh进入用户

java - 如何设置Maven依赖的URL

ruby 运算符重载问题

arrays - 如何在bash中从csv转换为数组

ruby-on-rails - 多少类太多了? rails 科学技术

Rstudio 未在 Ubuntu 22.04 上启动 - 加载共享库 : libcrypto. so.1.1 时出错

python - 为什么python请求默认不使用系统ssl证书?

mysql - 无法使用 HeidiSQL : "Can' t connect to MySQL server on 'localhost' "连接到 Vagrant

ruby - 通过向现有数组插入新元素来创建新数组

ruby-on-rails - Rails/在 View 中使用模型