![](/img/trans.png)
[英]Ruby on Rails: Error `require': cannot load such file -- bundler/setup (LoadError)
[英]Ruby on Rails BDD Error with 'Bundle Exec Rspec' cannot load such file — ffi (LoadError)
我正在使用Michael Hartl的Ruby on Rails教程来学习Rails。 我在第3.2.2节(测试驱动开发)中,当我运行以下命令来运行rspec测试时:
$ bundle exec rspec spec / requests / static_pages_spec.rb
我收到以下错误:
c:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/childprocess-0.5.1/lib/childprocess/windows.rb:1:in `require': cannot load such file -- ffi (LoadError) from c:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/childprocess-0.5.1/lib/childprocess/windows.rb:1:in `<top (required)>' from c:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/childprocess-0.5.1/lib/childprocess.rb:176:in `require'
from c:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/childprocess-0.5.1/lib/childprocess.rb:176:in `<top (required)>'
from c:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/selenium-webdriver-2.35.1/lib/selenium/webdriver.rb:1:in `require'
from c:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/selenium-webdriver-2.35.1/lib/selenium/webdriver.rb:1:in `<top (required)>'
from c:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/selenium-webdriver-2.35.1/lib/selenium-webdriver.rb:1:in `require'
from c:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/selenium-webdriver-2.35.1/lib/selenium-webdriver.rb:1:in `<top (required)>'
from c:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/bundler-1.3.5/lib/bundler/runtime.rb:72:in `require'
from c:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/bundler-1.3.5/lib/bundler/runtime.rb:72:in `block (2 levels) in require'
from c:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/bundler-1.3.5/lib/bundler/runtime.rb:70:in `each'
from c:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/bundler-1.3.5/lib/bundler/runtime.rb:70:in `block in require'
from c:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/bundler-1.3.5/lib/bundler/runtime.rb:59:in `each'
from c:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/bundler-1.3.5/lib/bundler/runtime.rb:59:in `require'
from c:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/bundler-1.3.5/lib/bundler.rb:132:in `require'
from d:/source/training/ruby/railstutorial/sample_app/config/application.rb:12:in `<top (required)>'
from d:/source/training/ruby/railstutorial/sample_app/config/environment.rb:2:in `require'
from d:/source/training/ruby/railstutorial/sample_app/config/environment.rb:2:in `<top (required)>'
from d:/source/training/ruby/railstutorial/sample_app/spec/spec_helper.rb:3:in `require'
from d:/source/training/ruby/railstutorial/sample_app/spec/spec_helper.rb:3:in `<top (required)>'
from d:/source/training/ruby/railstutorial/sample_app/spec/requests/static_pages_spec.rb:1:in `require'
from d:/source/training/ruby/railstutorial/sample_app/spec/requests/static_pages_spec.rb:1:in `<top (required)>'
from c:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/rspec-core-2.13.1/lib/rspec/core/configuration.rb:819:in `load'
from c:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/rspec-core-2.13.1/lib/rspec/core/configuration.rb:819:in `block in load_spec_files'
from c:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/rspec-core-2.13.1/lib/rspec/core/configuration.rb:819:in `each'
from c:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/rspec-core-2.13.1/lib/rspec/core/configuration.rb:819:in `load_spec_files'
from c:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/rspec-core-2.13.1/lib/rspec/core/command_line.rb:22:in `run'
from c:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/rspec-core-2.13.1/lib/rspec/core/runner.rb:80:in `run'
from c:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/rspec-core-2.13.1/lib/rspec/core/runner.rb:17:in `block in autorun'
这是我的Gemfile:
source 'https://rubygems.org'
ruby '2.0.0'
gem 'rails', '4.0.3'
group :development, :test do
gem 'sqlite3', '1.3.8'
gem 'rspec-rails', '2.13.1'
end
group :test do
gem 'selenium-webdriver', '~> 2.35.1'
gem 'capybara', '2.1.0'
end
gem 'sass-rails', '4.0.1'
gem 'uglifier', '2.1.1'
gem 'coffee-rails', '4.0.1'
gem 'jquery-rails', '3.0.4'
gem 'turbolinks', '1.1.1'
gem 'jbuilder', '1.0.2'
group :doc do
gem 'sdoc', '0.3.20', require: false
end
group :production do
gem 'pg', '0.15.1'
gem 'rails_12factor', '0.0.2'
end
这是我的static_pages_spec.rb
require 'spec_helper'
describe "Static pages" do
describe "Home page" do
it "should have the content 'Sample App'" do
visit 'static_pages/home'
expect(page).to have_content('Sample App')
end
end
end
当我评论这一行
#require 'spec_helper'
然后出现红色失败测试,但有一些错误,表明它无法识别某些功能,例如访问。 我尝试安装无法显示错误消息的ffi,但仍然出现此错误。
操作系统 : Windows 7 x64 ,有什么帮助吗?
谢谢
根据此https://github.com/ffi/ffi/issues/176,您应将其安装为
gem install ffi --platform=ruby
每次找到它时,都必须在gemfile.lock中将del X86替换为X64。 例如,您必须用此ffi(1.9.3-x64-mingw32)替换此ffi(1.9.3-x86 -mingw32)。
进行这些更改后,保存gemfile.lock并捆绑安装
如果以上解决方案均无效,请尝试在gem文件中显式声明gem。 它对我有用。
gem 'ffi'
注意:您可能仍然需要安装MikeZ提到的gem
gem install ffi --platform=ruby
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.