Gem::LoadError 启动中间人服务器时

Gem::LoadError when starting middleman server

每当我开始 middleman server 时,我都会收到 Gem::LoadError。显然我的机器无法找到或安装 nokogiri。我错过了什么吗?

这是我的错误:

/Library/Ruby/Site/2.0.0/rubygems/dependency.rb:315:in `to_specs': Could not find 'nokogiri' (>= 1.3.3) among 67 total gem(s) (Gem::LoadError)
Checked in 'GEM_PATH=/Users/Wilhelm/.gem/ruby/2.0.0:/Library/Ruby/Gems/2.0.0:/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/gems/2.0.0', execute `gem env` for more information
    from /Library/Ruby/Site/2.0.0/rubygems/specification.rb:1311:in `block in activate_dependencies'
    from /Library/Ruby/Site/2.0.0/rubygems/specification.rb:1300:in `each'
    from /Library/Ruby/Site/2.0.0/rubygems/specification.rb:1300:in `activate_dependencies'
    from /Library/Ruby/Site/2.0.0/rubygems/specification.rb:1282:in `activate'
    from /Library/Ruby/Site/2.0.0/rubygems/specification.rb:1314:in `block in activate_dependencies'
    from /Library/Ruby/Site/2.0.0/rubygems/specification.rb:1300:in `each'
    from /Library/Ruby/Site/2.0.0/rubygems/specification.rb:1300:in `activate_dependencies'
    from /Library/Ruby/Site/2.0.0/rubygems/specification.rb:1282:in `activate'
    from /Library/Ruby/Site/2.0.0/rubygems/core_ext/kernel_gem.rb:67:in `block in gem'
    from /Library/Ruby/Site/2.0.0/rubygems/core_ext/kernel_gem.rb:66:in `synchronize'
    from /Library/Ruby/Site/2.0.0/rubygems/core_ext/kernel_gem.rb:66:in `gem'
    from /usr/bin/middleman:22:in `<main>'

这是我的rubygem env

RubyGems Environment:
  - RUBYGEMS VERSION: 1.8.23.2
  - RUBY VERSION: 1.9.3 (2014-11-13 patchlevel 551) [x86_64-darwin14.4.0]
  - INSTALLATION DIRECTORY: /Users/Wilhelm/.rbenv/versions/1.9.3-dev/lib/ruby/gems/1.9.1
  - RUBY EXECUTABLE: /Users/Wilhelm/.rbenv/versions/1.9.3-dev/bin/ruby
  - EXECUTABLE DIRECTORY: /Users/Wilhelm/.rbenv/versions/1.9.3-dev/bin
  - RUBYGEMS PLATFORMS:
    - ruby
    - x86_64-darwin-14
  - GEM PATHS:
     - /Users/Wilhelm/.rbenv/versions/1.9.3-dev/lib/ruby/gems/1.9.1
     - /Users/Wilhelm/.gem/ruby/1.9.1
  - GEM CONFIGURATION:
     - :update_sources => true
     - :verbose => true
     - :benchmark => false
     - :backtrace => false
     - :bulk_threshold => 1000
  - REMOTE SOURCES:
     - http://rubygems.org/
Could not find 'nokogiri' (>= 1.3.3)

意味着,您的机器上没有安装 nokogiri,但您的其他一些 gem 依赖于它。所以,你需要安装它。

如果您使用的是捆绑器,请添加 Gemfile:

gem 'nokogiri', '1.3.3'

然后,执行:

bundle install

安装nokogiri

如果您没有 Gemfile,只需执行:

gem install nokogiri -v 1.3.3

有时,安装 nokogiri 很棘手。理想情况下,我的上述建议应该有效并在您的计算机上安装 nokogiri。但是,如果您遇到任何其他错误,请检查此页面是否有 nokogiri installation