使用 RVM 安装了 Ruby 1.9.3,但命令行不显示 ruby​​ -v

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/9056008/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-06 04:43:33  来源:igfitidea点击:

Installed Ruby 1.9.3 with RVM but command line doesn't show ruby -v

rubyubunturvm

提问by Only Bolivian Here

Here's the console output:

这是控制台输出:

sergio@sergio-VirtualBox:~$ rvm list

rvm rubies

   ruby-1.9.3 [ i386 ]

sergio@sergio-VirtualBox:~$ rvm use 1.9.3
Using /usr/share/ruby-rvm/gems/ruby-1.9.3

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

So what's going on? Do I need to reboot my machine? Or should it work right off the bat? I'm using Ubuntu 11.10, any help is appreciated.

发生什么了?我需要重新启动我的机器吗?或者它应该立即起作用?我正在使用 Ubuntu 11.10,任何帮助表示赞赏。

回答by mpapis

You have broken version of RVM. Ubuntu does something to RVM that produces lots of errors, the only safe way of fixing for now is to:

您的 RVM 版本已损坏。Ubuntu 对 RVM 做了一些会产生很多错误的事情,目前唯一安全的修复方法是:

sudo apt-get --purge remove ruby-rvm
sudo rm -rf /usr/share/ruby-rvm /etc/rvmrc /etc/profile.d/rvm.sh

open new terminal and validate environment is clean from old RVM settings (should be no output):

打开新终端并验证旧 RVM 设置中的环境是否干净(应该没有输出):

env | grep rvm

if there was output, try to open new terminal, if it does not help then restart your computer.

如果有输出,请尝试打开新终端,如果没有帮助,则重新启动计算机。

install RVM:

安装 RVM

\curl -L https://get.rvm.io | 
  bash -s stable --ruby --autolibs=enable --auto-dotfiles

If you find you need some hand-holding, take a look at Installing Ruby on Ubuntu 12.04, which gives a bit more explanation.

如果您发现需要一些帮助,请查看在Ubuntu 12.04安装 Ruby,它提供了更多解释。

回答by deadbug

  • Open Terminal.
  • Go to Edit -> Profile Preferences.
  • Select the Title & command Tab in the window opened.
  • Mark the checkbox Run command as login shell.
  • close the window and restart the Terminal.
  • 打开终端。
  • 转到编辑 -> 配置文件首选项。
  • 在打开的窗口中选择标题和命令选项卡。
  • 将复选框运行命令标记为登录 shell。
  • 关闭窗口并重新启动终端。

Check this Official Linkenter image description here

检查此官方链接在此处输入图片说明

回答by randallreedjr

I ran into a similar issue today - my ruby version didn't match my rvm installs.

我今天遇到了类似的问题 - 我的 ruby​​ 版本与我的 rvm 安装不匹配。

> ruby -v
ruby 2.0.0p481

> rvm list
rvm rubies
   ruby-2.1.2 [ x86_64 ]
=* ruby-2.2.1 [ x86_64 ]
   ruby-2.2.3 [ x86_64 ]

Also, rvm currentfailed.

还有,rvm current失败了。

> rvm current
Warning! PATH is not properly set up, '/Users/randallreed/.rvm/gems/ruby-2.2.1/bin' is not at first place...

The error message recommended this useful command, which resolved the issue for me:

错误消息推荐了这个有用的命令,它为我解决了这个问题:

> rvm get stable --auto-dotfiles