Linux 在 Ubuntu 12.04 上使用 RVM 来使用 Rails。当前未安装程序“rails”

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/11164765/
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-08-06 07:01:00  来源:igfitidea点击:

Using RVM on Ubuntu 12.04 to use Rails. The program 'rails' is currently not installed

ruby-on-railsrubylinuxubunturvm

提问by Only Bolivian Here

I installed RVM from scratch following the installation guide on the official website. I installed Rails, created a dummy app and everything worked fine.

我按照官方网站上的安装指南从头开始安装了 RVM。我安装了 Rails,创建了一个虚拟应用程序,一切正常。

I shut off my machine.

我关了我的机器。

The next morning, I turned on the machine again (cold boot) and the tried running "rails -v" from the console, but I get the following error message:

第二天早上,我再次打开机器(冷启动)并尝试rails -v从控制台运行“ ”,但收到以下错误消息:

sergio@Sergio-work ~ $ rails -v

The program 'rails' is currently not installed. You can install it by typing: sudo apt-get install rails

sergio@Sergio-work ~ $ rails -v

当前未安装程序“rails”。您可以通过键入来安装它:sudo apt-get install rails

I can run ruby -vjust fine, and get the following message:

我可以正常运行ruby -v,并收到以下消息:

sergio@Sergio-work ~ $ ruby -v

ruby 1.9.3p194 (2012-04-20 revision 35410) [x86_64-linux]

sergio@Sergio-work ~ $ ruby​​ -v

红宝石 1.9.3p194(2012-04-20 修订版 35410)[x86_64-linux]

I can also run gem listjust fine, output:

我也可以正常运行gem list,输出:

sergio@Sergio-work ~ $ gem list

*** LOCAL GEMS ***

actionmailer (3.2.3)
actionpack (3.2.3)
activemodel (3.2.3)
activerecord (3.2.3)
activeresource (3.2.3)
activesupport (3.2.3)
arel (3.0.2)
builder (3.0.0)
bundler (1.1.4)
coffee-rails (3.2.2)
coffee-script (2.2.0)
coffee-script-source (1.3.3)
erubis (2.7.0)
execjs (1.4.0)
faraday (0.8.0)
google_drive (0.3.0)
hike (1.2.1)
httpauth (0.1)
i18n (0.6.0)
journey (1.0.3)
jquery-rails (2.0.2)
json (1.7.3)
libv8 (3.3.10.4 x86_64-linux)
mail (2.4.4)
mime-types (1.18)
multi_json (1.3.6, 1.3.5)
multipart-post (1.1.5)
mysql2 (0.3.11)
nokogiri (1.5.0)
oauth (0.4.6)
oauth2 (0.7.1)
polyglot (0.3.3)
rack (1.4.1)
rack-cache (1.2)
rack-ssl (1.3.2)
rack-test (0.6.1)
rails (3.2.3)
railties (3.2.3)
rake (0.9.2.2)
rdoc (3.12)
rubygems-bundler (1.0.2)
rvm (1.11.3.3)
sass (3.1.19, 3.1.18)
sass-rails (3.2.5)
sprockets (2.1.3)
sqlite3 (1.3.6)
therubyracer (0.10.1)
thor (0.14.6)
tilt (1.3.3)
treetop (1.4.10)
tzinfo (0.3.33)
uglifier (1.2.4)

Why doesn't my rails -vcommand work anymore? I used to have this "hack" where I would need to run a command in terminal, "source something something" once, before rails would be "recognized" as an actual command. I had to this once per terminal, meaning if I closed a terminal I had to re-run this after opening a new window terminal.

为什么我的rails -v命令不再起作用?我曾经有过这个“hack”,我需要在终端中运行一个命令,“ source something something”一次,在 rails 被“识别”为实际命令之前。每个终端我都必须这样做一次,这意味着如果我关闭了一个终端,我必须在打开一个新的窗口终端后重新运行它。

I can't seem to find this command anymore on the Help section for RVM (where I originally found it) and since I'm kind of new to Linux, these advanced configurations are complex to me.

我似乎无法在 RVM 的帮助部分(我最初找到它的地方)找到这个命令,而且由于我对 Linux 有点陌生,这些高级配置对我来说很复杂。

Any ideas?

有任何想法吗?

采纳答案by Justin ??????

You need to type source ~/.rvm/scripts/rvmbefore attempting to use Rails.

您需要source ~/.rvm/scripts/rvm在尝试使用 Rails 之前键入。

I believe the RVM installation suggests putting this line (or something similar) in your .bashrc.

我相信 RVM 安装建议将这条线(或类似的东西)放在你的.bashrc.

Run the following command in Terminal:

在终端中运行以下命令:

echo "source $HOME/.rvm/scripts/rvm" >> ~/.bashrc

This appends the line source \$HOME/.rvm/scripts/rvmto the end of the .bashrcfile.

这会将行附加source \$HOME/.rvm/scripts/rvm.bashrc文件的末尾。

Doing so ensures that RVM is properly loaded each time you open up a terminal.

这样做可确保每次打开终端时正确加载 RVM。

回答by mpapis

the proper fix is it https://rvm.io/integration/gnome-terminal/

正确的解决方法是https://rvm.io/integration/gnome-terminal/

you should not add source ~/.rvm/scripts/rvmto ~/.bashrc, you can find some more details here: https://rvm.io/support/faq/#shell_login

您不应该添加source ~/.rvm/scripts/rvm~/.bashrc,您可以在此处找到更多详细信息:https: //rvm.io/support/faq/#shell_login

回答by look

Here is another possibility. This happened to me. Everything was working fine and sudo'ed into root. I left the terminal open and returned a couple of days later.

这是另一种可能性。这发生在我身上。一切正常,并且 sudo 进入根目录。我让终端开着,几天后又回来了。

rails would not work. Just like you said it was there in the gems. Turns out that I just needed to exit out of the root user and go back to my regular user and rails was fine.

导轨不起作用。就像你说的那样,它就在宝石中。事实证明,我只需要退出 root 用户并返回到我的常规用户,rails 就可以了。