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
9.3 : Gem::LoadError: You have already activated ffi 1.15.1, but your Gemfile requires ffi 1.15.3. #6751
Comments
Ok I suspect that the problem here is due to some Windows logic in our standard library or boot code is probably activating FFI before Bundler can get in there and pick the right one. The most likely suspect is the code linked below, which loads on boot to support
There are a few ways we could fix this:
I think deferring the load of this |
Note there's similar code below this for Solaris that could also be moved inside a lazy load. |
It's not very obvious to me where I can lazy-load it. I see that these workarounds are loaded in Can you give me some pointers on the where, and perhaps referencing a similar workaround in the code? |
@HoneyryderChuck Yeah looking at it more closely this would be difficult to do lazily. The constants are being pulled out of FFI as well, and would be accessed before any method is called. It may be possible to modify that file (jruby/kernel/file.rb) to attempt to activate the gem first, which will impact startup but may be compatible with Bundler installing a newer FFI. |
Activating FFI this early prevents it being upgraded by RubyGems or Bundler. This also happens so early that there's no way to eagerly activate the gem to pick up a newer version. As a result, bundles or gems that depend on newer FFI will error or warn about the mismatch. This change modifies the FFI-based File methods on Windows (File.symlink) and Solaris (File#flock) to lazily require a separate file that loads FFI and redefines those methods. Fixes jruby#6751
Looks like an acceptable trade-off. Thx @headius |
I realized the constants I was worried about are literally just used by the adjacent FFI logic, so I have moved the entire ball of crap into a separate file that is lazy-loaded on first call of If you can test it out that would be great! Easy to build from the branch in #6760 or I will merge it once green and you can pick up a snapshot build of master. |
It seems like this code was broken before I messed with it. The FFI::Config constant does not exist, so this was not actually defining the FFI-based File.symlink. As a result, my change to load that logic lazily caused a stack overflow. The changes here fix this: * Always define the Windows-specific String function present here. * Only check for the FFI constant to know if FFI is available. * If FFI is not available *or* it cannot bind the necessary functions, instead define File.symlink to raise NotImplemented. See jruby#6751.
A few issues were unearthed by my fix so I have pushed #6762 to address them. I have confirmed the following:
|
@HoneyryderChuck Could you help us out by writing some tests for the cases I describe above, perhaps including a case that confirms FFI does not get loaded until after you try to call Tests that basically just shell out and relaunch JRuby with various options would be great! |
@headius I'm currently on holidays, will come back to it next week 👍 |
@headius I can confirm that the ffi issue doesn't show up anymore. Only had some issues in my test build due to declaring "win32ole" instead of "jruby-win32ole" in my Gemfile (installing works, requiring works, but there's no "WIN32OLE" available after). Once I got it done, all went well: https://github.com/HoneyryderChuck/idnx/actions/runs/1087751417 Thank you again for your help! |
If it helps anyone, what eventually helped me was to uninstall the wrong ffi version completely: |
Continuing after fixing #6732 , I'm seeing an issue when testing on Windows, using
jruby-head
andffi
, namely, there's a conflict between a "loose" dependency, and what jruby perceives as the default gem version.The dependency is set like:
The error message is:
Build log here: https://github.com/HoneyryderChuck/idnx/runs/3044772603?check_suite_focus=true
It's worth noting that this issue happens only on windows (if you run through the other jruby jobs, on mac and linux, all is well).
Is the change a plain bundler update, or is it more involved?
Environment Information
Provide at least:
The text was updated successfully, but these errors were encountered: