Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Missing FFI::ManagedStruct #2097

Closed
sempervictus opened this Issue · 17 comments

4 participants

@sempervictus

Attempting to use gd2-ffij in rubinius results in:

NameError: Missing or uninitialized constant: FFI::ManagedStruct
from kernel/common/module.rb:472:in const_missing'
from /usr/local/rvm/gems/rbx-head@testing/gems/gd2-ffij-0.0.6/lib/gd2/ffi_struct.rb:37:in
module_init (FFIStruct)'
from /usr/local/rvm/gems/rbx-head@testing/gems/gd2-ffij-0.0.6/lib/gd2/ffi_struct.rb:24:in __script__'
from kernel/common/codeloader.rb:212:in
require'
from kernel/common/kernel.rb:648:in gem_original_require (require)'
from /usr/local/rvm/rubies/rbx-head/lib/rubygems/custom_require.rb:36:in
require'
from /usr/local/rvm/gems/rbx-head@testing/gems/gd2-ffij-0.0.6/lib/gd2-ffij.rb:192:in __script__'
from kernel/common/codeloader.rb:212:in
require'
from kernel/common/kernel.rb:648:in gem_original_require (require)'
from /usr/local/rvm/rubies/rbx-head/lib/rubygems/custom_require.rb:60:in
require'
from (irb):1
from kernel/common/block_environment.rb:75:in call_on_instance'
from kernel/common/eval.rb:75:in
eval'
from kernel/common/kernel19.rb:42:in loop'
from kernel/common/throw_catch19.rb:8:in
catch'
from kernel/common/throw_catch.rb:10:in register'
from kernel/common/throw_catch19.rb:7:in
catch'
from kernel/common/throw_catch19.rb:8:in catch'
from kernel/common/throw_catch.rb:10:in
register'
from kernel/common/throw_catch19.rb:7:in catch'
from kernel/delta/codeloader.rb:68:in
load_script'
from kernel/delta/codeloader.rb:118:in load_script'
from kernel/loader.rb:615:in
script'
from kernel/loader.rb:816:in `main'

Probably unwise for me to try and tackle this @ 0330, but it seems we need ManagedStruct defined for FFI to play nice with this gem. The gem itself is a set of FFI bindings to libgd2 which is a widely used graphics library. Would be very useful to get this working on Rubinius.

@dwbutler

+1 (I need FFI::ManagedStruct for RDF::Raptor)

@brixen
Owner

We now bundle a 1.2.0 version of the FFI gem, however, there is a bug in RVM that omits the pre-installed gems. So if using RVM, use the recently released 1.3.0 FFI gem which builds correctly on Rubinius.

@brixen brixen closed this
@dwbutler

I just tried it out and unfortunately I'm running into a lot of compatibility issues with FFI 1.3.0. Specifically, TypeError: no implicit conversion from nil to integer in certain FFI calls. This happens in all rubies, not just Rubinius, so I figure something must have broken in FFI itself.

@brixen
Owner

@dwbutler could you try with the bundled 1.2.0 FFI gem? RVM appears to have fixed the issue with pre-installed gems rvm/rvm#1430 Also, could you open an issue with the FFI project?

@dwbutler

Yeah, I'll probably open up a separate issue with FFI, if I can figure out what exactly is causing the problem! I burned a few hours last night to no avail.

I'm still having trouble getting FFI 1.2.0 to work with Rubinius. Is the latest version of Rubinious available from RVM the correct version to be using, or do I need to clone the source from Github and build manually?

Here are the steps I took and the error I got:

> rvm get head
> rvm -v

rvm 1.17.7 (master) by Wayne E. Seguin <wayneeseguin@gmail.com>, Michal Papis <mpapis@gmail.com> [https://rvm.io/]

> rvm install rbx-head --1.9
> rvm use rbx@global
> gem install ffi -v 1.2.0 --no-rdoc
Building native extensions.  This could take a while...
Successfully installed ffi-1.2.0
1 gem installed
> irb
rubinius-2.0.0.rc1 :001 > require 'ffi'
LoadError: no such file to load -- ffi.rb
    from kernel/common/codeloader.rb:389:in `load_error'
    from kernel/common/codeloader.rb:376:in `resolve_require_path'
    from kernel/common/codeloader.rb:104:in `require'
    from kernel/bootstrap/rubinius.rb:150:in `synchronize'
    from kernel/common/codeloader.rb:103:in `require'
    from kernel/common/codeloader.rb:206:in `require'
    from kernel/common/kernel.rb:649:in `gem_original_require (require)'
    from /Users/david/.rvm/rubies/rbx-head/lib/rubygems/custom_require.rb:60:in `require'
    from /Users/david/.rvm/gems/rbx-head@global/gems/ffi-1.2.0/lib/ffi.rb:24:in `__script__'
    from kernel/common/codeloader.rb:212:in `require'
    from kernel/common/kernel.rb:649:in `gem_original_require (require)'
    from /Users/david/.rvm/rubies/rbx-head/lib/rubygems/custom_require.rb:60:in `require'
    from (irb):2
    from kernel/common/block_environment.rb:75:in `call_on_instance'
    from kernel/common/eval.rb:75:in `eval'
    from kernel/common/kernel19.rb:42:in `loop'
    from kernel/common/throw_catch19.rb:8:in `catch'
    from kernel/common/throw_catch.rb:10:in `register'
    from kernel/common/throw_catch19.rb:7:in `catch'
    from kernel/common/throw_catch19.rb:8:in `catch'
    from kernel/common/throw_catch.rb:10:in `register'
    from kernel/common/throw_catch19.rb:7:in `catch'
    from kernel/delta/codeloader.rb:68:in `load_script'
    from kernel/delta/codeloader.rb:118:in `load_script'
    from kernel/loader.rb:615:in `script'
    from kernel/loader.rb:816:in `main'rubinius-2.0.0.rc1
@brixen
Owner

@dwbutler you must use the pre-installed 1.2.0 gem. You cannot install it. The version on rubygems.org installs in a broken state.

If you have installed Rubinius via RVM, get the latest RVM and reinstall rbx so that the pre-installed gems are available. See rvm/rvm#1430

@mpapis

@dwbutler try in this order:

rvm remove rbx-head --gems
rvm install rbx-head --1.9

the --gems is behavior from old times - RVM1 by default does not remove gems when removing, it will be changed(fixed) in RVM2.

@dwbutler

Not sure what's going on... I tried the steps above and I'm getting the same result.

> rvm get head
> rvm -v  

rvm 1.17.7 (master) by Wayne E. Seguin <wayneeseguin@gmail.com>, Michal Papis <mpapis@gmail.com> [https://rvm.io/]

> rvm remove rbx-head --gems
> rvm install rbx-head --1.9
> ruby -v
rubinius 2.0.0.rc1 (1.9.3 8be92cf7 yyyy-mm-dd JI) [x86_64-apple-darwin12.2.0]
> gem list 

*** LOCAL GEMS ***

bundler (1.2.3)
rake (10.0.3)
rubygems-bundler (1.1.0)
rvm (1.11.3.5)

> irb -r ffi
kernel/common/codeloader.rb:389:in `load_error':LoadError: no such file to load -- ffi
rubinius-2.0.0.rc1 :001 > 

I can, however, load the old Rubinius FFI which doesn't have ManagedStruct:

> irb -r 'rubinius/ffi'
rubinius-2.0.0.rc1 :001 > FFI
 => Rubinius::FFI 
rubinius-2.0.0.rc1 :002 > FFI::ManagedStruct
NameError: Missing or uninitialized constant: Rubinius::FFI::ManagedStruct
@mpapis

@dwbutler please add a comment to rvm/rvm#1430 including gist of:

rvm remove rbx-head --gems
rvm install rbx-head --1.9 --trace
@dwbutler

Okay, I finally got Rubinius to pre-install FFI 1.2.0.

However, I'm getting the same error now that I was originally only getting with version 1.3.0: TypeError: no implicit conversion from nil to integer

I'm not getting this error with FFI 1.2.0 in other Rubies (1.9.3, 1.8.7). My platform is OSX.

Is there some commonality between Rubinius-bundled FFI 1.2.0, and the official FFI 1.3.0 release?

@brixen
Owner

@dwbutler yeah, it rolls in some commits that are in the 1.3.0 release so that the gem builds and loads correctly on Rubinius. Could you provide a small repro in a new issue that cross-links to the FFI project issue? Or just link me to the FFI issue?

@dwbutler

Alright, I created an issue over at FFI: ffi/ffi#245

I also created a gist to document the issue in detail:
https://gist.github.com/4499941

@dwbutler

Turns out this was a bug in FFI 1.3.0. It's fixed now in FFI 1.3.1.

Perhaps Rubinius should come bundled with FFI 1.3.1+?

@brixen
Owner

@dwbutler there's no reason to bundle 1.3.0+ because those install and run correctly on Rubinius. We only bundle 1.2.x to simplify things for people using that version. Ideally, everyone would upgrade immediately to 1.3.x. I'm pushing an updated pre-installed 1.2.0 with the upstream fix.

@dwbutler

Oh I see. I guess that should work as long as people are aware of the caveats. For example, my usual workflow is to create a new gemset for each separate project. Unfortunately, Rubinius only pre-bundles the gems into the default gemset.

@brixen
Owner

Yes, I hope to deprecate our bundled version as soon as possible. The only reason I'm bundling is because the project wouldn't release a 1.2.x that builds correctly on Rubinius.

@mpapis

@dwbutler added moving gems to @global too rvm/rvm@956f30e - now it should work in all gemsets (you need to install again)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.