Git Product home page Git Product logo

Comments (11)

sds avatar sds commented on July 20, 2024 1

Hey all, after a quick investigation I don't have a good answer here.

The error is caused by the RubyGems runtime not being able to find a dependency in the local domain

Unable to resolve dependency: user requested 'ffi (~> 1.0, >= 1.0.11)'

I tried modifying the mkrf_conf.rb file to specify the local domain explicitly to see if that resolved it, but we get the same error.

installer_options = {}
installer_options[:domain] = :local
inst = Gem::DependencyInstaller.new(installer_options)

Here are the options we have:

  1. Dig into RubyGems internals to understand if there's a way to get this to work using only locally-installed gems.
  2. Vendor the gems you're installing so you don't need to run gem install in the first place and thus avoid this issue.
  3. Remove this native extension installation workaround entirely and clearly document that Windows users need to explicitly include ffi as a gem dependency in their projects in order to use childprocess.

I'm coming around to 3 given the fact that conditional installation does seem a little bit deceptive. Developers should be able to see clearly what their gems are installing without having to look at custom extensions code.

@DavidS Any thoughts on removing the extension code since you implemented this in #132?

from childprocess.

aidistan avatar aidistan commented on July 20, 2024 1

Since Gem::Installer#install always tries to reinstall, I guess a simple way to fix this is to check whether a satisfied version of ffi exists (see PR #159).

from childprocess.

reggieb avatar reggieb commented on July 20, 2024

We are also getting an error with Windows installations via gemfile. An update of the selenium-webdriver in our Rails app has bumped childprocess from version from 1.0.1 to 2.0.0. This has worked fine for those of the team using Linux and Mac development platforms. But a Windows user now gets this error on running bundle:

Fetching childprocess 2.0.0
Installing childprocess 2.0.0 with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

current directory:
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/childprocess-2.0.0/ext
C:/Ruby26-x64/bin/ruby.exe mkrf_conf.rb

rake failed, exit code 1

Gem files will remain installed in
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/childprocess-2.0.0 for inspection.
Results logged to
C:/Ruby26-x64/lib/ruby/gems/2.6.0/extensions/x64-mingw32/2.6.0/childprocess-2.0.0/gem_make.out

An error occurred while installing childprocess (2.0.0), and Bundler cannot
continue.
Make sure that `gem install childprocess -v '2.0.0' --source
'https://rubygems.org/'` succeeds before bundling.

In Gemfile:
  webdrivers was resolved to 4.1.2, which depends on
    selenium-webdriver was resolved to 3.142.4, which depends on
      childprocess

from childprocess.

sds avatar sds commented on July 20, 2024

Hey @aidistan and @reggieb, thanks for the reports.

Can you provide the output of gem_make.out from your respective environments (the Results logged to line)? This could help us better understand what's happening in this case.

Thanks!

from childprocess.

reggieb avatar reggieb commented on July 20, 2024

I'm afraid it's not very helpful:

current directory: C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/childprocess-2.0.0/ext
C:/Ruby26-x64/bin/ruby.exe mkrf_conf.rb

rake failed, exit code 1

from childprocess.

aidistan avatar aidistan commented on July 20, 2024

Mine is the same as reggieb's.


Here I've tried gem install childprocess -v '2.0.0' --source 'https://rubygems.org/' and succeeded, though gem install --local childprocess-2.0.0.gem without network access still got failed.

from childprocess.

DavidS avatar DavidS commented on July 20, 2024

The original reason for me having that has vanished, so I have no objections to revert all of that. :(

from childprocess.

sds avatar sds commented on July 20, 2024

Hey @aidistan, thanks for opening #159.

I still believe the answer here is to remove this logic, and clearly document that Windows users need to explicitly install ffi themselves. This is for the following reasons:

  1. Regardless of platform, you always see a Building native extensions. This could take a while... message when this is not actually the case. ChildProcess is just piggybacking off of the RubyGems extension facilities to conditionally install a gem. This is confusing.
  2. When installing ffi via this workaround, it isn't clear to the user that it is happening. You see the aforementioned Building native extensions message, but aren't told that the ffi gem was installed. Again, this is potentially confusing, but also deceptive in that it hides the dependency.
  3. The workaround requires us to specify a dependency constraint that doesn't respect the constraints defined in the user's own gem dependencies. Users then need to align their dependency constraints with what we've defined in mkrf_conf.rb, duplicating them in their Gemfile/etc. See #150 for an example where this confusion occurs.
  4. It introduces a dependency on the rake gem (see #144), unnecessarily coupling us to Rake's release cycle. See #147 for an example where we had to cut a new release when Rake issued a new release.

We (specifically, myself) originally merged this in #132 without truly understanding the consequences of that pull request. For this reason and those mentioned above, we're removing this logic in #160.

from childprocess.

aidistan avatar aidistan commented on July 20, 2024

Hey @sds, thanks for the comments and opening #160.

Since we had no further progress under this issue for several days, I opened #159 and left the logic untouched 😄

I completely agree with your first and second points. However, besides the document, I suggest to raise a LoadError when running without ffi gem on Windows platform (refer to this discussion).

from childprocess.

sds avatar sds commented on July 20, 2024

Thanks for the suggestion. Added a more descriptive error message in c0cc6f2.

from childprocess.

sds avatar sds commented on July 20, 2024

Fixed in #160. Shipped in ChildProcess 3.0.0. Thanks again for the report!

from childprocess.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.