2

我正在从 Michael Hartl 的教程中学习 Ruby。我正在一步一步地按照步骤进行操作,但是我无法通过这一步骤。当我输入“bundle exec rspec spec/requests/static_pages_spec.rb”时,我得到一个很长的错误响应,而不是简单的“1 个示例,0 个失败”。我更改了静态页面目录中的必要代码,并且我相当确信代码是正确的,因为我只是简单地复制和粘贴。错误信息是这样的:

/Users/marlon/.rvm/gems/ruby-1.9.2-p320/gems/nokogiri-1.6.0/lib/nokogiri.rb:28:in `require': dlopen(/Users/marlon/.rvm/gems/ruby-1.9.2-p320/gems/nokogiri-1.6.0/lib/nokogiri/nokogiri.bundle, 9): Library not loaded: /Users/marlon/.bundler/tmp/1219/gems/nokogiri-1.6.0/ports/i686-apple-darwin11/libxml2/2.8.0/lib/libxml2.2.dylib (LoadError)
  Referenced from: /Users/marlon/.rvm/gems/ruby-1.9.2-p320/gems/nokogiri-1.6.0/lib/nokogiri/nokogiri.bundle
  Reason: Incompatible library version: nokogiri.bundle requires version 11.0.0 or later, but libxml2.2.dylib provides version 10.0.0 - /Users/marlon/.rvm/gems/ruby-1.9.2-p320/gems/nokogiri-1.6.0/lib/nokogiri/nokogiri.bundle
    from /Users/marlon/.rvm/gems/ruby-1.9.2-p320/gems/nokogiri-1.6.0/lib/nokogiri.rb:28:in `<top (required)>'
    from /Users/marlon/.rvm/gems/ruby-1.9.2-p320/gems/capybara-1.1.2/lib/capybara.rb:2:in `require'
    from /Users/marlon/.rvm/gems/ruby-1.9.2-p320/gems/capybara-1.1.2/lib/capybara.rb:2:in `<top (required)>'
    from /Users/marlon/.rvm/gems/ruby-1.9.2-p320@global/gems/bundler-1.3.5/lib/bundler/runtime.rb:72:in `require'
    from /Users/marlon/.rvm/gems/ruby-1.9.2-p320@global/gems/bundler-1.3.5/lib/bundler/runtime.rb:72:in `block (2 levels) in require'
    from /Users/marlon/.rvm/gems/ruby-1.9.2-p320@global/gems/bundler-1.3.5/lib/bundler/runtime.rb:70:in `each'
    from /Users/marlon/.rvm/gems/ruby-1.9.2-p320@global/gems/bundler-1.3.5/lib/bundler/runtime.rb:70:in `block in require'
    from /Users/marlon/.rvm/gems/ruby-1.9.2-p320@global/gems/bundler-1.3.5/lib/bundler/runtime.rb:59:in `each'
    from /Users/marlon/.rvm/gems/ruby-1.9.2-p320@global/gems/bundler-1.3.5/lib/bundler/runtime.rb:59:in `require'
    from /Users/marlon/.rvm/gems/ruby-1.9.2-p320@global/gems/bundler-1.3.5/lib/bundler.rb:132:in `require'
    from /Users/marlon/rails_projects/sample_app/config/application.rb:7:in `<top (required)>'
    from /Users/marlon/rails_projects/sample_app/config/environment.rb:2:in `require'
    from /Users/marlon/rails_projects/sample_app/config/environment.rb:2:in `<top (required)>'
    from /Users/marlon/rails_projects/sample_app/spec/spec_helper.rb:3:in `require'
    from /Users/marlon/rails_projects/sample_app/spec/spec_helper.rb:3:in `<top (required)>'
    from /Users/marlon/rails_projects/sample_app/spec/requests/static_pages_spec.rb:1:in `require'
    from /Users/marlon/rails_projects/sample_app/spec/requests/static_pages_spec.rb:1:in `<top (required)>'
    from /Users/marlon/.rvm/gems/ruby-1.9.2-p320/gems/rspec-core-2.11.1/lib/rspec/core/configuration.rb:780:in `load'
    from /Users/marlon/.rvm/gems/ruby-1.9.2-p320/gems/rspec-core-2.11.1/lib/rspec/core/configuration.rb:780:in `block in load_spec_files'
    from /Users/marlon/.rvm/gems/ruby-1.9.2-p320/gems/rspec-core-2.11.1/lib/rspec/core/configuration.rb:780:in `map'
    from /Users/marlon/.rvm/gems/ruby-1.9.2-p320/gems/rspec-core-2.11.1/lib/rspec/core/configuration.rb:780:in `load_spec_files'
    from /Users/marlon/.rvm/gems/ruby-1.9.2-p320/gems/rspec-core-2.11.1/lib/rspec/core/command_line.rb:22:in `run'
    from /Users/marlon/.rvm/gems/ruby-1.9.2-p320/gems/rspec-core-2.11.1/lib/rspec/core/runner.rb:69:in `run'
    from /Users/marlon/.rvm/gems/ruby-1.9.2-p320/gems/rspec-core-2.11.1/lib/rspec/core/runner.rb:8:in `block in autorun'
dyn172-30-28-254:sample_app marlon$

请让我知道我能做些什么来解决这个问题。感谢所有的帮助,在此先感谢!

4

1 回答 1

3

您应该安装 nokogiri 依赖项:

brew install libxml2 --with-xml2-config
brew install libxslt
于 2013-06-19T18:24:49.690 回答