我在Windows上并且正在运行Ruby 2.7.0。
运行gem install rails
时出现此错误:
ERROR: Error installing rails:
The last version of nokogiri (>= 1.6) to support your Ruby & RubyGems was 1.10.9.
Try installing it with `gem install nokogiri -v 1.10.9` and then running the current command again
nokogiri requires Ruby version >= 2.3, < 2.7.dev. The current ruby version is 2.7.0.0.
当我运行gem install nokogiri -v '1.10.9'
时,我得到相同的确切错误。
我已经安装了gem install nokogiri -v 1.11.0.rc1 --pre
,但是仍然出现相同的错误。
$ nokogiri -v
# Nokogiri (1.11.0.rc1)
---
warnings: []
nokogiri: 1.11.0.rc1
ruby:
version: 2.7.0
platform: x64-mingw32
description: ruby 2.7.0p0 (2019-12-25 revision 647ee6f091) [x64-mingw32]
engine: ruby
libxml:
source: packaged
patches:
- 0001-Revert-Do-not-URI-escape-in-server-side-includes.patch
- 0002-Remove-script-macro-support.patch
- 0003-Update-entities-to-remove-handling-of-ssi.patch
- 0004-libxml2.la-is-in-top_builddir.patch
compiled: 2.9.10
loaded: 2.9.10
libxslt:
source: packaged
patches: []
compiled: 1.1.34
loaded: 1.1.34
所以,我知道Ruby 2.7.0高于2.7.dev,但是我安装了nokogiri gem。
而且,Ruby 2.6.5一切正常。我确实将其卸载,将其从“路径”中删除,然后重新启动计算机。
[如果有人有任何想法,我很想听听他们。
似乎在您尝试安装nokogiri
时,会安装与您的ruby版本不兼容的版本并显示该错误。
即使您指定要安装的版本,它也会忽略指定的版本号,并安装最新版本,如错误所示。
$ nokogiri -v
# Nokogiri (1.11.0.rc1)
---
warnings: []
nokogiri: 1.11.0.rc1
因此,请尝试使gem自行下载当前安装的ruby版本。
gem install nokogiri --platform=ruby
PS,这可能需要一段时间...