简体   繁体   English

在 [] (Gem::LoadError) 中找不到导轨 (>= 0)

[英]Could not find rails (>= 0) amongst [] (Gem::LoadError)

After installing rvm, updating.gmrc file, updating rubygems and running gem install rails -v ">=3.1.0rc" , I now seem to have a complete mess:在安装 rvm、更新 .gmrc 文件、更新 rubygems 并运行gem install rails -v ">=3.1.0rc"之后,我现在似乎一团糟:

$ rails -v
/usr/local/lib/site_ruby/1.8/rubygems/dependency.rb:247:in `to_specs': Could not find rails (>= 0) amongst [] (Gem::LoadError)
    from /usr/local/lib/site_ruby/1.8/rubygems/dependency.rb:256:in `to_spec'
    from /usr/local/lib/site_ruby/1.8/rubygems.rb:1182:in `gem'
    from /var/lib/gems/1.8/bin/rails:18

myhome@myhome-mini:~$ gem env

RubyGems Environment:
  - RUBYGEMS VERSION: 1.6.2
  - RUBY VERSION: 1.9.2 (2011-02-18 patchlevel 180) [i686-linux]
  - INSTALLATION DIRECTORY: /home/myhome/gems
  - RUBY EXECUTABLE: /home/myhome/.rvm/rubies/ruby-1.9.2-p180/bin/ruby
  - EXECUTABLE DIRECTORY: /home/myhome/gems/bin
  - RUBYGEMS PLATFORMS:
    - ruby
    - x86-linux
  - GEM PATHS:
     - /home/myhome/gems
     - /usr/lib/ruby/gems/1.8
  - GEM CONFIGURATION:
     - :update_sources => true
     - :verbose => true
     - :benchmark => false
     - :backtrace => false
     - :bulk_threshold => 1000
     - "gemhome" => "/home/myhome/gems"
     - "gempath" => ["/home/myhome/gems", "/usr/lib/ruby/gems/1.8"]
  - REMOTE SOURCES:
     - http://rubygems.org/

I've had a similiar problem.我有一个类似的问题。 Not sure if that helps you, but you might try to install gems with rvmsudo gem install [gemname] instead of just doing gem install [gemname] or sudo gem install [gemname] .不确定这是否对您有帮助,但您可以尝试使用rvmsudo gem install [gemname]安装 gem,而不仅仅是执行gem install [gemname]sudo gem install [gemname]

I try to explain this a bit because of the upvotes:由于赞成票,我试图解释一下:
This basically is a path issue.这基本上是一个路径问题。 If you set up gems via gem install , they mostly likely will be in another directory (eg /usr/local/ ) compared to gems set up via bundler (where you can override it with --path ).如果您通过gem install设置 gem,与通过 bundler 设置的 gem(您可以使用--path覆盖它)相比,它们很可能会在另一个目录中(例如/usr/local/ )。 Using sudo may also set them up into another directory since sudo starts a subshell which has a different environment then.使用sudo也可以将它们设置到另一个目录,因为sudo会启动一个具有不同环境的子 shell。 This is why you have rvmsudo .这就是您拥有rvmsudo的原因。

If you want to see the differences, compare $PATH , $GEM_HOME , $GEM_PATH and $BUNDLE_PATH when echoing directly, with sudo and with rvmsudo .如果您想查看差异,请在直接回显时比较$PATH$GEM_HOME$GEM_PATH$BUNDLE_PATH ,使用sudorvmsudo

I had to sudo gem install bundler to make it work again.我不得不sudo gem install bundler让它再次工作。

I got a problem similar to this, there may be a compatible problem of rvm.我遇到了类似的问题,可能是rvm的兼容问题。 I fixed by updating rvm to latest version:我通过将 rvm 更新到最新版本来修复:

curl -L https://get.rvm.io | bash -s stable --ruby

Then you should reload rvm or just open new terminal window.然后你应该重新加载 rvm 或者只是打开新的终端 window。 Then I reinstalled the bundler 'gem install bundler' and ran 'bundle install' as normal然后我重新安装了捆绑程序“gem install bundler”并正常运行“bundle install”

rvm rubygems current

did the trick for me.为我做了伎俩。

remove ruby first then先删除 ruby 然后

sudo apt-get install build-essential libssl-dev libreadline5 libreadline5-dev zlib1g zlib1g-dev

to install all needed lib then you could install ruby and rails安装所有需要的库然后你可以安装 ruby 和 rails

rvm install 1.9.3
rvm --default use 1.9.3
rvm gem install rails

I know this is a really old question but I just recently decided to move to RVM on a server I had setup a while ago and was having this same problem where gems were being installed in the wrong place and it was just messing everything up.我知道这是一个非常老的问题,但我最近才决定在我不久前设置的服务器上迁移到 RVM,并且遇到了同样的问题,即 gem 安装在错误的位置,它只是把一切都搞砸了。

After a few hours of crawling through SO, I finally figured out that in my .gemrc file in my root folder, I had previously setup the gemhome: and gempath: variables and they were messing with the whole system.经过几个小时的搜索,我终于发现在我的根文件夹中的.gemrc文件中,我之前已经设置了gemhome: and gempath:变量,它们弄乱了整个系统。

After removing these lines, all my gems were working property.删除这些线后,我所有的宝石都是工作财产。

Just thought I would post my answer in case someone was in the same position.只是想我会发布我的答案,以防有人在同一个 position 中。

I had pretty much the same message when trying to generate a controller after installing IntelliJ IDEA and the associated Plugin for Rail Dev.在安装 IntelliJ IDEA 和相关的 Rail Dev 插件后尝试生成 controller 时,我收到了几乎相同的消息。 From my app directory I just executed bundle install and was then able to generate controllers again.从我的应用程序目录中,我刚刚执行了捆绑安装,然后能够再次生成控制器。

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

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