Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cannot load such file -- ffi on windows #150

Closed
ahorek opened this issue May 9, 2019 · 5 comments
Closed

cannot load such file -- ffi on windows #150

ahorek opened this issue May 9, 2019 · 5 comments
Labels

Comments

@ahorek
Copy link

ahorek commented May 9, 2019

after this change #132

ffi gem isn't part of the gemspec anymore and bundler doesn't require such dependencies

require 'ffi' will raise an error LoadError: cannot load such file -- ffi even if the gem is actually installed

backtrace
LoadError: cannot load such file -- ffi
C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/childprocess-1.0.1/lib/childprocess/windows.rb:1:in `require'
C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/childprocess-1.0.1/lib/childprocess/windows.rb:1:in `'
C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/childprocess-1.0.1/lib/childprocess.rb:209:in `require'
C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/childprocess-1.0.1/lib/childprocess.rb:209:in `'
C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/selenium-webdriver-3.142.1/lib/selenium/webdriver.rb:20:in `require'
C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/selenium-webdriver-3.142.1/lib/selenium/webdriver.rb:20:in `'
C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/selenium-webdriver-3.142.1/lib/selenium-webdriver.rb:20:in `require'
C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/selenium-webdriver-3.142.1/lib/selenium-webdriver.rb:20:in `'
C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/bundler-1.17.3/lib/bundler/runtime.rb:81:in `require'
C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/bundler-1.17.3/lib/bundler/runtime.rb:81:in `block (2 levels) in require'
C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/bundler-1.17.3/lib/bundler/runtime.rb:76:in `each'
C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/bundler-1.17.3/lib/bundler/runtime.rb:76:in `block in require'
C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/bundler-1.17.3/lib/bundler/runtime.rb:65:in `each'
C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/bundler-1.17.3/lib/bundler/runtime.rb:65:in `require'
C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/bundler-1.17.3/lib/bundler.rb:114:in `require'
c:/redmine/config/application.rb:7:in `'
C:/Ruby25-x64/lib/ruby/site_ruby/2.5.0/rubygems/core_ext/kernel_require.rb:59:in `require'
C:/Ruby25-x64/lib/ruby/site_ruby/2.5.0/rubygems/core_ext/kernel_require.rb:59:in `require'
c:/redmine/Rakefile:5:in `'
C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/rake-12.3.2/lib/rake/rake_module.rb:29:in `load'
C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/rake-12.3.2/lib/rake/rake_module.rb:29:in `load_rakefile'
C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/rake-12.3.2/lib/rake/application.rb:703:in `raw_load_rakefile'
C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/rake-12.3.2/lib/rake/application.rb:104:in `block in load_rakefile'
C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/rake-12.3.2/lib/rake/application.rb:186:in `standard_exception_handling'
C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/rake-12.3.2/lib/rake/application.rb:103:in `load_rakefile'
C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/rake-12.3.2/lib/rake/application.rb:82:in `block in run'
C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/rake-12.3.2/lib/rake/application.rb:186:in `standard_exception_handling'
C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/rake-12.3.2/lib/rake/application.rb:80:in `run'
C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/rake-12.3.2/exe/rake:27:in `'
C:/Ruby25-x64/bin/rake:23:in `load'
C:/Ruby25-x64/bin/rake:23:in `'

if I add gem 'ffi' into app's Gemfile it works fine, but I think that childprocess should require it as a dependency, not just install the gem under the hood.

@sds
Copy link
Collaborator

sds commented May 12, 2019

Hey @ahorek, what does Gem.win_platform? return for you?

The gem should install the ffi gem on Windows automatically. See:

if Gem.win_platform?
inst.install 'ffi', Gem::Requirement.new('~> 1.0', '>= 1.0.11')
end

@sds
Copy link
Collaborator

sds commented May 12, 2019

Sorry, I misread your comment.

This is likely because you are running your application via Bundler. With Bundler, your LOAD_PATH is changed based on whatever gems are explicitly listed in your Gemfile. There's nothing childprocess can do about this—you need to configure your Gemfile appropriately if you are going to be running your application via bundle exec or similar.

Hope that helps!

@sds sds closed this as completed May 12, 2019
@sds sds added the question label May 12, 2019
@ahorek
Copy link
Author

ahorek commented May 12, 2019

You're right, but I also don't have gem 'childprocess' in my Gemfile explicitly, other gems depend on it. The same way 'ffi' should be a runtime dependency of 'childprocess'.
It's no big deal for me and the workaround works.

@sds
Copy link
Collaborator

sds commented May 12, 2019

Ah, understood. This is an unfortunate case, but there are good reasons we don't include the ffi gem by default, which are described in the PR you reference. Most users don't need it, and installing a gem that requires native extensions to be built increases install time substantially.

Whichever gems are depending on childprocess should also be including an explicit dependency on ffi if they want to support Windows. Suggest you open an issue on those gems.

@sds
Copy link
Collaborator

sds commented Sep 20, 2019

Following up here to say we've removed the magic ffi install logic in #160. Recommend you always include ffi as a dependency in your Gemfile going forward. This will be shipped in ChildProcess 3.0.0. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants