【问题标题】:how to set rvm ruby as default version for system如何将 rvm ruby​​ 设置为系统的默认版本
【发布时间】:2014-11-13 04:38:21
【问题描述】:

当我执行ruby -v 时,它会显示

The program 'ruby' can be found in the following packages:
* ruby1.8
* ruby1.9.1
Try: sudo apt-get install <selected package>

You need to change your terminal emulator preferences to allow login shell.
Sometimes it is required to use `/bin/bash --login` as the command.
Please visit https://rvm.io/integration/gnome-terminal/ for an example.

当我运行 /bin/bash --login 然后运行 ​​ruby -v 它显示

ruby 2.1.0p0 (2013-12-25 revision 44422) [x86_64-linux]

但我不想每次都运行/bin/bash --login 命令。我希望我的系统将 ruby​​ 2.1.0 设置为 rvm 的默认 ruby​​。

【问题讨论】:

    标签: ruby-on-rails ruby rvm


    【解决方案1】:

    问题可能是您的登录上下文。这是因为 ssh 默认使用与本地 bash shell 不同的启动上下文。见这里:

    .bashrc at ssh login

    您需要将以下内容添加到 .bash_profile:

    if [ -f ~/.bashrc ]; then
      . ~/.bashrc
    fi
    

    如果您使用 sudo su 等来更改上下文,那么您必须添加 -l 标志来建立相同的上下文。

    这个答案只是一个猜测,很难说为什么你的特定环境没有加载,但这是一个常见的原因。

    【讨论】:

    • 感谢您的快速回复。你能告诉我如何编辑 .bash_profile 吗?
    • 但是它在系统中的什么位置?
    猜你喜欢
    • 1970-01-01
    • 2011-12-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-09-25
    • 1970-01-01
    相关资源
    最近更新 更多