Ruby-on-rails Rails:找不到railties

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

Rails: Could not find railties

ruby-on-railsrubygems

提问by justnorris

?  ~  rvm -v

rvm 1.10.2 by Wayne E. Seguin <[email protected]>, Michal Papis <[email protected]> [https://rvm.beginrescueend.com/]

?  ~  ruby -v
ruby 1.9.3p0 (2011-10-30 revision 33570) [x86_64-darwin11.2.0]
?  ~  rails -v
/Users/hb/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/site_ruby/1.9.1/rubygems/dependency.rb:247:in `to_specs': Could not find railties (>= 0) amongst [bigdecimal-1.1.0, io-console-0.3, json-1.5.4, minitest-2.5.1, rake-0.9.2.2, rdoc-3.9.4] (Gem::LoadError)
    from /Users/hb/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/site_ruby/1.9.1/rubygems/dependency.rb:256:in `to_spec'
    from /Users/hb/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/site_ruby/1.9.1/rubygems.rb:1208:in `gem'
    from /Users/hb/.rvm/gems/ruby-1.9.3-p0/bin/rails:18:in `<main>'
?  ~  

I installed a clean installation of ruby just now, and rails, I removed all my previous gems, and I still keep getting this error. Any ideas ? And yes, I had this error before, and this is what I did

我刚刚安装了一个干净的ruby安装,和rails,我删除了我以前的所有gem,我仍然不断收到这个错误。有任何想法吗 ?是的,我以前遇到过这个错误,这就是我所做的

A little more info:

多一点信息:

?  ~  gem list

*** LOCAL GEMS ***

actionmailer (3.2.1)
actionpack (3.2.1)
activemodel (3.2.1)
activerecord (3.2.1)
activeresource (3.2.1)
activesupport (3.2.1)
arel (3.0.0)
builder (3.0.0)
bundler (1.0.22 ruby)
erubis (2.7.0)
hike (1.2.1)
i18n (0.6.0)
journey (1.0.1)
json (1.6.5)
mail (2.4.1)
mime-types (1.17.2)
multi_json (1.0.4)
polyglot (0.3.3)
rack (1.4.1)
rack-cache (1.1)
rack-ssl (1.3.2)
rack-test (0.6.1)
rails (3.2.1)
railties (3.2.1)
rake (0.9.2.2, 0.9.2)
rdoc (3.12)
sprockets (2.3.0, 2.1.2)
thor (0.14.6)
tilt (1.3.3)
treetop (1.4.10)
tzinfo (0.3.31)

?  ~  gem install rails
Successfully installed rails-3.2.1
1 gem installed
Installing ri documentation for rails-3.2.1...
Installing RDoc documentation for rails-3.2.1...
?  ~  rails -v
/Users/hb/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/site_ruby/1.9.1/rubygems/dependency.rb:247:in `to_specs': Could not find railties (>= 0) amongst [bigdecimal-1.1.0, io-console-0.3, json-1.5.4, minitest-2.5.1, rake-0.9.2.2, rdoc-3.9.4] (Gem::LoadError)
    from /Users/hb/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/site_ruby/1.9.1/rubygems/dependency.rb:256:in `to_spec'
    from /Users/hb/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/site_ruby/1.9.1/rubygems.rb:1208:in `gem'
    from /Users/hb/.rvm/gems/ruby-1.9.3-p0/bin/rails:18:in `<main>'
?  ~  

采纳答案by justnorris

rvm implodewas the answer. Something probably went wrong before, now everything works after a rvm reinstall.

rvm implode是答案。之前可能出了点问题,现在重新安装 rvm 后一切正常。

回答by Simone Carletti

It means your Rails installation is corrupted or incomplete. If you list your gems, chances are you won't find railties

这意味着您的 Rails 安装已损坏或不完整。如果你列出你的宝石,你很可能找不到railties

$ gem list

Run the command

运行命令

$ gem install rails

again. It will download and install missing dependencies, including railties.

再次。它将下载并安装缺少的依赖项,包括 railties。

回答by Arkaaito

I ran into the same problem and, in my case, it turned out to be because I had installed using sudo - it does not necessarily make rails available to ordinary users. Try running just gem install railsif you previously ran sudo gem install rails.

我遇到了同样的问题,就我而言,结果是因为我使用 sudo 进行了安装 - 它不一定使普通用户可以使用 rails。gem install rails如果您以前运行过,请尝试运行sudo gem install rails

回答by Haris Krajina

Worked for me

对我来说有效

rvm reinstall 1.9.3

then

然后

gem install rails

回答by Verdi Erel Ergün

I ran into this same issue. If you're using RVM it's possible you switched to the wrong Ruby version which causes a gem load error if the directory uses a different version than the one you are currently set to use.

我遇到了同样的问题。如果您使用的是 RVM,则可能您切换到了错误的 Ruby 版本,如果目录使用的版本与您当前设置使用的版本不同,则会导致 gem 加载错误。

To fix, type rvm use -yourrubyversion in the app's directory in terminal. For example, if your app is set up to use ruby 1.9.3 type rvm use -1.9.3.

要修复,请在终端的应用程序目录中键入 rvm use -yourrubyversion。例如,如果您的应用程序设置为使用 ruby​​ 1.9.3,请键入 rvm use -1.9.3。

RVM works by separating your gems by ruby version by app, so if you switch to a different ruby version RVM will separate previously used and installed gems from the different ruby version, which is why you may be seeing tho issue.

RVM 的工作原理是将您的 gems 按 ruby​​ 版本按应用程序分开,因此如果您切换到不同的 ruby​​ 版本,RVM 会将以前使用和安装的 gems 与不同的 ruby​​ 版本分开,这就是您可能会看到这个问题的原因。

回答by zhoubaozhou

Maybe you installed two or more version of rails and railties.

也许您安装了两个或更多版本的 rails 和 railties。

gem uninstall railties
gem uninstall rails

then reinstall.

然后重新安装。

回答by vidur punj

I got the same error when I installed ruby 1.9.3p194

我在安装 ruby​​ 1.9.3p194 时遇到了同样的错误

and then I reinstalled ruby and rails

然后我重新安装了 ruby​​ 和 rails

回答by DNorthrup

I also had this issue after I installed ZSH (Wanted to mess with it's templates.)

安装 ZSH 后我也遇到了这个问题(想弄乱它的模板。)

Ran

brew update

which did find some updates I wasn't missing before, but in the end

确实找到了一些我以前没有错过的更新,但最终

gem install rails

suddenly completely re-installing the rail/ties system. Unsure why ZSH removed it.

突然完全重新安装导轨/系杆系统。不确定为什么 ZSH 删除了它。

回答by valk

Simone's answer is great. However, if you already have your Rails gem in your Gemfile, just try to use bundle exec instead:

西蒙娜的回答很棒。但是,如果您的 Gemfile 中已经有 Rails gem,请尝试使用 bundle exec 代替:

bundle exec rails c

And that should suffice. If not, then add

这应该就足够了。如果没有,则添加

bundle install

before the mentioned command.

在提到的命令之前。

回答by knaija

I did 'gem install rails' on my system (ubuntu) and it installed the missing gems approx 28 of them then i did 'gem list' to check and it was all there.

我在我的系统(ubuntu)上安装了“gem install rails”,它安装了大约 28 个缺失的 gem,然后我做了“gem list”检查,一切都在那里。