Rails 安装失败:activesupport 需要 Ruby 版本 >= 2.2.2
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/38515733/
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
Rails install fails: activesupport requires Ruby version >= 2.2.2
提问by Donato
I want to create a new Rails app. I am using rvm with ruby-2.1.2. I am usint the @globalgemset and plan to use bundler to manage gem dependencies. However, gem install railsfails:
我想创建一个新的 Rails 应用程序。我在 ruby-2.1.2 中使用 rvm。我正在使用@globalgemset 并计划使用 bundler 来管理 gem 依赖项。但是,gem install rails失败:
$ gem install rails
Fetching: concurrent-ruby-1.0.3.pre3.gem (100%)
Successfully installed concurrent-ruby-1.0.3.pre3
Fetching: minitest-5.9.0.gem (100%)
Successfully installed minitest-5.9.0
Fetching: thread_safe-0.3.5.gem (100%)
Successfully installed thread_safe-0.3.5
Fetching: tzinfo-1.2.2.gem (100%)
Successfully installed tzinfo-1.2.2
Fetching: i18n-0.7.0.gem (100%)
Successfully installed i18n-0.7.0
Fetching: activesupport-5.0.0.gem (100%)
ERROR: Error installing rails:
activesupport requires Ruby version >= 2.2.2.
Yes, it is true I am using ruby-2.1.2 and not ruby-2.2.2, but shouldn't I still be allowed to use ruby-2.1.2? Are we not allowed to use ruby-2.1.2 anymore?
是的,我使用 ruby-2.1.2 而不是 ruby-2.2.2 是真的,但我不应该仍然被允许使用 ruby-2.1.2 吗?我们不再允许使用 ruby-2.1.2 了吗?
I thought maybe that ActiveSupport 5 was already installed in the @globalgemset and that ActiveSupport 5 required 2.2.2, but actually there is no ActiveSupport 5 in the @globalgemset:
我想也许 ActiveSupport 5 已经安装在@globalgemset 中并且 ActiveSupport 5 需要 2.2.2,但实际上@globalgemset 中没有 ActiveSupport 5 :
$ rvm gemdir
/Users/myuser/.rvm/gems/ruby-2.1.2@global
$ cd /Users/myuser/.rvm/gems/ruby-2.1.2@global
$ cd gems
$ ls
bundler-unload-1.0.2 gem-wrappers-1.2.4 rake-10.1.0 rvm-1.11.3.9 tzinfo-1.2.2
concurrent-ruby-1.0.3.pre3 i18n-0.7.0 rdoc-4.1.0 test-unit-2.1.2.0
executable-hooks-1.3.2 minitest-5.9.0 rubygems-bundler-1.4.4 thread_safe-0.3.5
So how can I prevent this error from occurring while trying to use ruby-2.1.2?
那么如何在尝试使用 ruby-2.1.2 时防止发生此错误?
回答by GPrimola
You're allowed to use any ruby version of your will, however you can't use any ruby version with the latest version of Rails.
When you do gem install railsyou're getting the latest Rails' version (Rails 5), which isn't compatible with Ruby 2.1.2 at all.
您可以使用任何 ruby 版本的遗嘱,但是您不能在最新版本的 Rails 中使用任何 ruby 版本。当您这样做时,gem install rails您将获得最新的 Rails 版本(Rails 5),它与 Ruby 2.1.2 完全不兼容。
If you really want to use Ruby 2.1.2, try this: gem install rails -v 4.2.2.
如果你真的想使用Ruby 2.1.2,试试这个:gem install rails -v 4.2.2。
As the use of gemset, since I like this pretty organized, I never use the global. I always create a new gemset for every project. This guarantee that I can have many projects, each one with a ruby and rails version, without getting any incompatibility between the gems. This of gemset as your Ruby on Rails workspace. If you separate them by project, you will minimize the odds of oddities with gem incompatibility.
至于gemset的使用,由于我喜欢这种很有条理的,我从不使用全局的。我总是为每个项目创建一个新的 gemset。这保证了我可以有很多项目,每个项目都有一个 ruby 和 rails 版本,而不会在 gems 之间出现任何不兼容。这个 gemset 作为你的 Ruby on Rails 工作区。如果您按项目将它们分开,您将最大限度地减少因宝石不兼容而出现的奇怪现象。
回答by Hasmukh Rathod
gem install rails
Above command will use latest version of rails, that is stable release of Rails 5, which require >= ruby 2.2.2.
以上命令将使用最新版本的 rails,即 Rails 5 的稳定版本,需要 >= ruby 2.2.2。
We can use 2.1.2 with lower version of Rails. Please specify version at the time of installing rails may solve your issue, For Example:
我们可以将 2.1.2 与较低版本的 Rails 一起使用。请在安装 rails 时指定版本可能会解决您的问题,例如:
gem install rails --version 4.2.4
or
或者
gem install rails -v 4.2.4
Let me know if it works. Thank you.
让我知道它是否有效。谢谢你。
回答by Ahmed Lotfy
I faced it fore CocoaPod and it fixes by the following:
我在 CocoaPod 面前遇到了它,它通过以下方式修复:
- sudo gem install activesupport -v 4.2.6
- sudo gem install cocoapods
- 须藤 gem install activesupport -v 4.2.6
- sudo gem 安装 cocoapods
回答by blueskin
Using RVM worked for me, I've followed instructions here
使用 RVM 对我有用,我已按照此处的说明进行操作
curl -sSL https://rvm.io/mpapis.asc | gpg --import - &&\
curl -L get.rvm.io | bash -s stable &&\
source /etc/profile.d/rvm.sh && /usr/local/rvm/bin/rvm reload &&\
/usr/local/rvm/bin/rvm requirements run &&\
/usr/local/rvm/bin/rvm install 2.2.4 &&\
/usr/local/rvm/bin/rvm use 2.2.4 --default && ruby --version
My environment was a Docker container with CentOS installed
我的环境是一个安装了 CentOS 的 Docker 容器
回答by Naveen Segaran
If you're using rbenv
如果您使用rbenv
Please verify that rbenv is properly set up using this rbenv-doctor script:
请使用此 rbenv-doctor 脚本验证 rbenv 是否已正确设置:
$ curl -fsSL https://github.com/rbenv/rbenv-installer/raw/master/bin/rbenv-doctor | bash

