简体   繁体   English

无法安装新的Rails应用; 主目录中缺少RVM'global'gemset,但在应用程序子目录中可见

[英]can't install new Rails app; RVM 'global' gemset missing from main directory but visible in app sub-directories

When I try to create a new Rails app in the directory in which I keep all my Rails apps, I get the following error: 当我尝试在将所有Rails应用程序保留在其中的目录中创建新的Rails应用程序时,出现以下错误:

Rails is not currently installed on this system. To get the latest version, simply type:

    $ sudo gem install rails

You can then rerun your "rails" command.

I've recently been working with an RVM tutorial, so I thought it might have something to do with a gemset I had created. 我最近一直在研究RVM教程,所以我认为这可能与我创建的gemset有关。 I typed 'rvm gemset list' and found the following: 我输入“ rvm gemset list”,发现以下内容:

gemsets for system (found in /Users/rickthomas/.rvm/gems/system)
=> (default)
   *

But the weird thing is, I cd'ed into the directory of one of the apps, and ran the same command, and found this: 但是奇怪的是,我进入其中一个应用程序的目录,并运行相同的命令,发现了这一点:

gemsets for ruby-1.9.3-p429 (found in /Users/rickthomas/.rvm/gems/ruby-1.9.3-p429)
=> (default)
   global

When I run the 'rails --version' command in the main directory, I get the message to run 'sudo gem install rails', but when I run the same command from within the app directory, I get this: 当我在主目录中运行“ rails --version”命令时,我得到了运行“ sudo gem install rails”的消息,但是当我在app目录中运行相同命令时,我得到了:

Rails 3.2.12

Kinda confused why I all of a sudden can't create a new Rails app, since the last one I created was this morning, a day after I finished the RVM tutorial, and didn't make any gemset changes since then. Kinda感到困惑,为什么突然之间我无法创建新的Rails应用程序,因为我创建的最后一个应用程序是在我完成RVM教程后的第二天早上,并且从那时起就没有进行任何gemset更改。

It looks like your "system" ruby doesn't have the Rails gem installed. 看来您的“系统”红宝石没有安装Rails gem。 You probably don't want to be using the system ruby anyway. 无论如何,您可能都不希望使用系统红宝石。 How about you try this: 您如何尝试:

rvm use 1.9.3      # switch to your Ruby 1.9.3 that the other app used
gem list           # make sure rails is listed
gem install rails  # (only if rails was not listed)
rails new myapp

There is nothing weird about the "weird thing" you observed. 您观察到的“怪异”没有什么奇怪的。 When you cd into a directory, RVM looks at files like .rvmrc, .ruby-version, and .ruby-gemset in that directory and it automatically changes your environment to match. 当您进入目录时,RVM会在该目录中查看.rvmrc,.ruby-version和.ruby-gemset之类的文件,它会自动更改您的环境以进行匹配。 You can run "rvm info" to see what kind of environment you are currently in (I usually focus on the GEM_HOME and GEM_PATH variables). 您可以运行“ rvm info”来查看当前所处的环境(我通常关注GEM_HOME和GEM_PATH变量)。 In this case, cd'ing into your Rails app directory caused RVM to switch you to Ruby 1.9.3, and that's the Ruby where you had the rails gem installed. 在这种情况下,将CD插入Rails应用程序目录会导致RVM将您切换到Ruby 1.9.3,这就是您安装Rails gem的Ruby。 Seems normal to me. 对我来说似乎很正常。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM