【问题标题】:Getting error in Hartl's tutorial running "bundle exec rspec spec/requests/static_pages_spec.rb"在运行“bundle exec rspec spec/requests/static_pages_spec.rb”的 Hartl 教程中出现错误
【发布时间】:2013-06-19 18:16:00
【问题描述】:

我正在从 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$

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

【问题讨论】:

    标签: ruby-on-rails ruby testing


    【解决方案1】:

    您应该安装 nokogiri 依赖项:

    brew install libxml2 --with-xml2-config
    brew install libxslt
    

    【讨论】:

    • 感谢您的回复。当我尝试这样做时,我得到了这个:“sudo:apt-get:找不到命令”
    • 我在 Retina MacBook Pro 上使用 OS X Mountain Lion。
    • 我更新了答案。我不知道 OS X,但我认为应该可以。
    • 嘿,再次感谢。我收到“警告:已安装 libxml2-2.9.1”和“警告:已安装 libxslt-1.1.28”
    • 好的,我让它工作了。由于某种原因,我不得不重新安装 Capybara!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-06-26
    • 1970-01-01
    • 2013-11-15
    • 2014-06-26
    相关资源
    最近更新 更多