Where communities thrive

  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
Repo info
    Joseph Giralt
    that's good to know.
    thanks for the response!
    Steve Loveless
    you might try some benchmarking? maybe that’ll show that it’s worth it?
    Joseph Giralt
    first I'm going to have to really learn me some rust :)
    Steve Loveless
    Well, ruru was a big springboard for me to jump in to Rust from Ruby. I really wanted to see what I could switch to Rust, but still use in Ruby-land, so I started here. It was a bit rough since, IMO, there are some things in ruru that aren’t quite super straightforward from a Rust perspective (Rust code, wrapping C code, which does Ruby things). ruru is a great library though—I’m sure you’ll get some traction with it.
    Dmytrii Nagirniak

    Hey guys, I was trying to follow the basic example with the String#blank? so basically just copy pasted it from README into a Rust crate.

    Then compiled it (as per https://github.com/d-unseductable/ruru#how-do-i-use-it) and fired up the (pry) console hoping to see the magic.
    Unfortunately got this, so scratching my head a little.

    > library = Fiddle::dlopen('rust/play/target/release/libplay.dylib')
    > Fiddle::Function.new(library['initialize_string'], [], Fiddle::TYPE_VOIDP)
    Fiddle::DLError: unknown symbol "initialize_string" from (pry):17:in `[]'

    Any pointers please?

    > ruby --version
    ruby 2.5.1p57 (2018-03-29 revision 63029) [x86_64-darwin17]
    > irb # then:
    > RbConfig::CONFIG['configure_args'].include?('--enable-shared')
    => true
    > rustc --version
    rustc 1.27.0 (3eda71b00 2018-06-19)
    > cat Cargo.toml
    name = "play"
    version = "0.1.0"
    authors = ["<me>"]
    crate-type = ["dylib"]
    ruru = "0.9.0"
    Dmytrii Nagirniak

    Recompiling the crate seems to have fixed this, so not sure what was going on TBH :innocent:
    But now a different error that seems to come from Class::from_existing("String")

    Error: [BUG] Segmentation fault at 0x0000000000000438
    C stack:

    0   libruby.2.5.dylib                   0x00000001084ddc87 rb_vm_bugreport + 135
    1   libruby.2.5.dylib                   0x0000000108362258 rb_bug_context + 472
    2   libruby.2.5.dylib                   0x0000000108450b31 sigsegv + 81
    3   libsystem_platform.dylib            0x00007fff7ac5ef5a _sigtramp + 26
    4   libruby.2.4.0.dylib                 0x0000000108a57fe1 ruby_xmalloc + 17
    5   libruby.2.4.0.dylib                 0x0000000108b256fa st_init_table_with_size + 74
    6   libruby.2.4.0.dylib                 0x0000000108a2f80e rb_enc_init + 110
    7   libruby.2.4.0.dylib                 0x0000000108a30be5 rb_usascii_encoding + 21
    8   libruby.2.4.0.dylib                 0x0000000108b4f3c7 rb_intern + 23
    9   libplay.dylib                     0x00000001087bf1ec _ZN4ruru7binding4util11internal_id17hdb1af469e236d7dcE + 108
    10  libplay.dylib                     0x00000001087bf149 _ZN4ruru7binding4util12get_constant17ha4887c45800de38aE + 41
    ==>>>>>> 11  libplay.dylib                     0x00000001087c0caf _ZN4ruru5class5class5Class13from_existing17h9fe2a0f2fe1e0735E + 63
    12  libplay.dylib                     0x00000001087b8e2e initialize_string + 30
    13  libffi.dylib                        0x00007fff79298f64 ffi_call_unix64 + 76
    14  libffi.dylib                        0x00007fff7929977c ffi_call + 808
    15  fiddle.bundle                       0x00000001087af6fb nogvl_ffi_call + 27
    16  libruby.2.5.dylib                   0x000000010848a762 rb_thread_call_without_gvl + 82
    17  fiddle.bundle                       0x00000001087af187 function_call + 823
    18  libruby.2.5.dylib                   0x00000001084d15bb vm_call_cfunc + 283
    19  libruby.2.5.dylib                   0x00000001084baa04 vm_exec_core + 12196
    20  libruby.2.5.dylib                   0x00000001084cbe8e vm_exec + 142
    21  libruby.2.5.dylib                   0x000000010836c0f1 ruby_exec_internal + 177
    Dmytrii Nagirniak
    Looks like this fails on stable but is fine on nightly (rustc 1.28.0-nightly (60efbdead 2018-06-23)). Very unfortunate :(
    Steve Loveless
    @dnagir i just ran through the steps for this using rust 1.26.2, ruru 0.9.0, and ruby 2.3.3 (although I thought I was running 2.5.1)—it worked fine. Once I realized I was running 2.3.3, i switched to 2.5.1 and got the ruby crash
    I just switched ruru to use master and that seems to work ok though
    ruru = { git = "ssh://github.com/d-unseductable/ruru.git" }
    Steve Loveless
    ruru 0.9.3 is about a year and a half old, so it might be worth using master anyway
    Dmytrii Nagirniak
    Thanks @turboladen. Using master is not ideal unfortunately.
    Dmytrii Nagirniak
    Just a quick question?
    Can ruru support DSL for (nested) modules/classes? Can we override methods on an existing Ruby class C that is in A::B module?
    Steve Loveless
    On mobile here, so will be brief... just follow the same pattern you would in ruby. IIRC with ruru there’s at Class::get_nested_class() method to open up the class so you can define the method.
    Daniel P. Clark
    Hey all. Just wanted to give you a head up that I've made an official fork of Ruru called Rutie. Lots of additional work has been done and it is actively maintained.
    Steve Loveless
    fwiw, I’ve switched to rutie for a few projects and it’s been great. Thanks for picking that up @danielpclark
    Marc Siegel
    @danielpclark in the interests of making the state of things discoverable, have you opened a PR to Ruru to add information about your fork near the top of the README?
    even if your PR is never responded to, it will appear in searches and be more discoverable than this random message I happened to see in the gitter chat room ;)
    Daniel P. Clark
    Will do @ms-ati, thanks.
    And thank you @turboladen
    Steve Loveless