在Ubuntu 12.04上使用RVM来使用Rails.目前尚未安装"rails"程序

Onl*_*ere 25 ruby linux ubuntu ruby-on-rails rvm

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

我关掉了我的机器.

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

塞尔吉奥@塞尔吉奥 - 工作〜$ rails -v

目前尚未安装"rails"程序.您可以通过键入以下命令安装它:sudo apt-get install rails

我可以运行ruby -v得很好,并得到以下消息:

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

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

我也可以运行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)
Run Code Online (Sandbox Code Playgroud)

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

我似乎无法在RVM的帮助部分(我最初找到它)找到这个命令,而且由于我不熟悉Linux,这些高级配置对我来说很复杂.

有任何想法吗?

Jus*_*ᚄᚒᚔ 37

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

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

在终端中运行以下命令:

echo "source \$HOME/.rvm/scripts/rvm" >> ~/.bashrc
Run Code Online (Sandbox Code Playgroud)

这会将该行追加source \$HOME/.rvm/scripts/rvm.bashrc文件末尾.

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


mpa*_*pis 13

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

你不应该添加source ~/.rvm/scripts/rvm~/.bashrc,你可以在这里找到一些细节:https://rvm.io/support/faq/#shell_login