How to install Nokogiri on Ruby 2.7.0

て烟熏妆下的殇ゞ 提交于 2020-05-29 06:53:42

问题


I recently upgraded to Ruby v2.7.0.

When I tried to install Nokogiri I got the following error:

ERROR:  Error installing nokogiri:
        The last version of nokogiri (>= 0) to support your Ruby & RubyGems was
1.10.9. Try installing it with `gem install nokogiri -v 1.10.9`
        nokogiri requires Ruby version >= 2.3, < 2.7.dev. The current ruby versi
on is 2.7.0.0.

I tried to install this gem with

gem install nokogiri -v 1.10.9

but I got the same error.

How can I install Nokogiri now that I am using Ruby v2.7.0? Do I need to install an earlier version of Ruby?

The results of gem env are:

RubyGems Environment:
  - RUBYGEMS VERSION: 3.1.2
  - RUBY VERSION: 2.7.0 (2019-12-25 patchlevel 0) [x64-mingw32]
  - INSTALLATION DIRECTORY: C:/Ruby27-x64/lib/ruby/gems/2.7.0
  - USER INSTALLATION DIRECTORY: C:/Users/gritz/.gem/ruby/2.7.0
  - RUBY EXECUTABLE: C:/Ruby27-x64/bin/ruby.exe
  - GIT EXECUTABLE: C:\Program Files\Git\cmd/git.EXE
  - EXECUTABLE DIRECTORY: C:/Ruby27-x64/bin
  - SPEC CACHE DIRECTORY: C:/Users/gritz/.gem/specs
  - SYSTEM CONFIGURATION DIRECTORY: C:/ProgramData
  - RUBYGEMS PLATFORMS:
    - ruby
    - x64-mingw32
  - GEM PATHS:
     - C:/Ruby27-x64/lib/ruby/gems/2.7.0
     - C:/Users/gritz/.gem/ruby/2.7.0
  - GEM CONFIGURATION:
     - :update_sources => true
     - :verbose => true
     - :backtrace => false
     - :bulk_threshold => 1000
  - REMOTE SOURCES:
     - https://rubygems.org/
  - SHELL PATH:
     - C:\windows\system32
     - C:\windows
     - C:\windows\System32\Wbem
     - C:\windows\System32\WindowsPowerShell\v1.0\
     - C:\windows\System32\OpenSSH\
     - C:\Program Files\Intel\WiFi\bin\
     - C:\Program Files\Common Files\Intel\WirelessCommon\
     - C:\Program Files\erl10.3\bin
     - C:\Program Files (x86)\Elixir\bin
     - C:\Users\gritz\.mix\escripts
     - C:\Program Files\Git\cmd
     - C:\Users\gritz\.rbenv-win\bin
     - C:\Users\gritz\.rbenv-win\shims
     - C:\Users\gritz\.rbenv-win\bin
     - C:\Users\gritz\.rbenv-win\shims
     - C:\Users\gritz\.rbenv-win\bin
     - C:\Users\gritz\.rbenv-win\shims
     - _SZ    C:\Ruby26\bin
     - C:\Ruby27-x64\bin
     - C:\Ruby26-x64\bin
     - %USERPROFILE%\AppData\Local\Microsoft\WindowsApps

In response to one of the comments, I am adding the results of gem specification -r nokogiri:

-r nokogiri
--- !ruby/object:Gem::Specification
name: nokogiri
version: !ruby/object:Gem::Version
  version: 1.10.9
platform: ruby
authors:
- Aaron Patterson
- Mike Dalessio
- Yoko Harada
- Tim Elliott
- Akinori MUSHA
- John Shahid
- Lars Kanis
autorequire:
bindir: bin
cert_chain: []
date: 2020-03-01 00:00:00.000000000 Z
dependencies:
- !ruby/object:Gem::Dependency
  name: mini_portile2
  requirement: !ruby/object:Gem::Requirement
    requirements:
    - - "~>"
      - !ruby/object:Gem::Version
        version: 2.4.0
  type: :runtime
  prerelease: false
  version_requirements: !ruby/object:Gem::Requirement
    requirements:
    - - "~>"
      - !ruby/object:Gem::Version
        version: 2.4.0
- !ruby/object:Gem::Dependency
  name: concourse
  requirement: !ruby/object:Gem::Requirement
    requirements:
    - - "~>"
      - !ruby/object:Gem::Version
        version: '0.24'
  type: :development
  prerelease: false
  version_requirements: !ruby/object:Gem::Requirement
    requirements:
    - - "~>"
      - !ruby/object:Gem::Version
        version: '0.24'
- !ruby/object:Gem::Dependency
  name: hoe-bundler
  requirement: !ruby/object:Gem::Requirement
    requirements:
    - - "~>"
      - !ruby/object:Gem::Version
        version: '1.2'
  type: :development
  prerelease: false
  version_requirements: !ruby/object:Gem::Requirement
    requirements:
    - - "~>"
      - !ruby/object:Gem::Version
        version: '1.2'
- !ruby/object:Gem::Dependency
  name: hoe-debugging
  requirement: !ruby/object:Gem::Requirement
    requirements:
    - - "~>"
      - !ruby/object:Gem::Version
        version: '2.0'
  type: :development
  prerelease: false
  version_requirements: !ruby/object:Gem::Requirement
    requirements:
    - - "~>"
      - !ruby/object:Gem::Version
        version: '2.0'
- !ruby/object:Gem::Dependency
  name: hoe-gemspec
  requirement: !ruby/object:Gem::Requirement
    requirements:
    - - "~>"
      - !ruby/object:Gem::Version
        version: '1.0'
  type: :development
  prerelease: false
  version_requirements: !ruby/object:Gem::Requirement
    requirements:
    - - "~>"
      - !ruby/object:Gem::Version
        version: '1.0'
- !ruby/object:Gem::Dependency
  name: hoe-git
  requirement: !ruby/object:Gem::Requirement
    requirements:
    - - "~>"
      - !ruby/object:Gem::Version
        version: '1.6'
  type: :development
  prerelease: false
  version_requirements: !ruby/object:Gem::Requirement
    requirements:
    - - "~>"
      - !ruby/object:Gem::Version
        version: '1.6'
- !ruby/object:Gem::Dependency
  name: minitest
  requirement: !ruby/object:Gem::Requirement
    requirements:
    - - "~>"
      - !ruby/object:Gem::Version
        version: '5.8'
  type: :development
  prerelease: false
  version_requirements: !ruby/object:Gem::Requirement
    requirements:
    - - "~>"
      - !ruby/object:Gem::Version
        version: '5.8'
- !ruby/object:Gem::Dependency
  name: racc
  requirement: !ruby/object:Gem::Requirement
    requirements:
    - - "~>"
      - !ruby/object:Gem::Version
        version: 1.4.14
  type: :development
  prerelease: false
  version_requirements: !ruby/object:Gem::Requirement
    requirements:
    - - "~>"
      - !ruby/object:Gem::Version
        version: 1.4.14
- !ruby/object:Gem::Dependency
  name: rake
  requirement: !ruby/object:Gem::Requirement
    requirements:
    - - "~>"
      - !ruby/object:Gem::Version
        version: '12.0'
  type: :development
  prerelease: false
  version_requirements: !ruby/object:Gem::Requirement
    requirements:
    - - "~>"
      - !ruby/object:Gem::Version
        version: '12.0'
- !ruby/object:Gem::Dependency
  name: rake-compiler
  requirement: !ruby/object:Gem::Requirement
    requirements:
    - - "~>"
      - !ruby/object:Gem::Version
        version: 1.1.0
  type: :development
  prerelease: false
  version_requirements: !ruby/object:Gem::Requirement
    requirements:
    - - "~>"
      - !ruby/object:Gem::Version
        version: 1.1.0
- !ruby/object:Gem::Dependency
  name: rake-compiler-dock
  requirement: !ruby/object:Gem::Requirement
    requirements:
    - - "~>"
      - !ruby/object:Gem::Version
        version: 0.7.0
  type: :development
  prerelease: false
  version_requirements: !ruby/object:Gem::Requirement
    requirements:
    - - "~>"
      - !ruby/object:Gem::Version
        version: 0.7.0
- !ruby/object:Gem::Dependency
  name: rexical
  requirement: !ruby/object:Gem::Requirement
    requirements:
    - - "~>"
      - !ruby/object:Gem::Version
        version: 1.0.5
  type: :development
  prerelease: false
  version_requirements: !ruby/object:Gem::Requirement
    requirements:
    - - "~>"
      - !ruby/object:Gem::Version
        version: 1.0.5
- !ruby/object:Gem::Dependency
  name: rubocop
  requirement: !ruby/object:Gem::Requirement
    requirements:
    - - "~>"
      - !ruby/object:Gem::Version
        version: '0.73'
  type: :development
  prerelease: false
  version_requirements: !ruby/object:Gem::Requirement
    requirements:
    - - "~>"
      - !ruby/object:Gem::Version
        version: '0.73'
- !ruby/object:Gem::Dependency
  name: simplecov
  requirement: !ruby/object:Gem::Requirement
    requirements:
    - - "~>"
      - !ruby/object:Gem::Version
        version: '0.16'
  type: :development
  prerelease: false
  version_requirements: !ruby/object:Gem::Requirement
    requirements:
    - - "~>"
      - !ruby/object:Gem::Version
        version: '0.16'
- !ruby/object:Gem::Dependency
  name: rdoc
  requirement: !ruby/object:Gem::Requirement
    requirements:
    - - ">="
      - !ruby/object:Gem::Version
        version: '4.0'
    - - "<"
      - !ruby/object:Gem::Version
        version: '7'
  type: :development
  prerelease: false
  version_requirements: !ruby/object:Gem::Requirement
    requirements:
    - - ">="
      - !ruby/object:Gem::Version
        version: '4.0'
    - - "<"
      - !ruby/object:Gem::Version
        version: '7'
- !ruby/object:Gem::Dependency
  name: hoe
  requirement: !ruby/object:Gem::Requirement
    requirements:
    - - "~>"
      - !ruby/object:Gem::Version
        version: '3.22'
  type: :development
  prerelease: false
  version_requirements: !ruby/object:Gem::Requirement
    requirements:
    - - "~>"
      - !ruby/object:Gem::Version
        version: '3.22'
description: |-
  Nokogiri (?) is an HTML, XML, SAX, and Reader parser.  Among
  Nokogiri's many features is the ability to search documents via XPath
  or CSS3 selectors.
email:
- aaronp@rubyforge.org
- mike.dalessio@gmail.com
- yokolet@gmail.com
- tle@holymonkey.com
- knu@idaemons.org
- jvshahid@gmail.com
- lars@greiz-reinsdorf.de
executables: []
extensions: []
extra_rdoc_files: []
files: []
homepage: https://nokogiri.org
licenses: []
metadata:
  homepage_uri: https://nokogiri.org
  bug_tracker_uri: https://github.com/sparklemotion/nokogiri/issues
  documentation_uri: https://nokogiri.org/rdoc/index.html
  changelog_uri: https://nokogiri.org/CHANGELOG.html
  source_code_uri: https://github.com/sparklemotion/nokogiri
post_install_message:
rdoc_options: []
require_paths:
- lib
required_ruby_version: !ruby/object:Gem::Requirement
  requirements:
  - - ">="
    - !ruby/object:Gem::Version
      version: 2.3.0
required_rubygems_version: !ruby/object:Gem::Requirement
  requirements:
  - - ">="
    - !ruby/object:Gem::Version
      version: '0'
requirements: []
rubygems_version: 3.1.2
signing_key:
specification_version: 4
summary: Nokogiri (?) is an HTML, XML, SAX, and Reader parser
test_files: []


回答1:


If you're using Ruby + DevKit, try this command:

gem install nokogiri --platform=ruby

It should install nokogiri and make it fit with your version of Ruby. In case if it fails again or takes forever to fetch and install gem, run this command first:

ridk exec pacman -S mingw-w64-x86_64-libxslt

Then this one:

gem install nokogiri --platform=ruby -- --use-system-libraries

Nokogori should be installed after these commands.



来源:https://stackoverflow.com/questions/60658746/how-to-install-nokogiri-on-ruby-2-7-0

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!