-
Notifications
You must be signed in to change notification settings - Fork 61
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
Is Rutie#init necessary? #142
Comments
I'm not aware of any issues in doing it that way as long as |
Just saw that this; might be related to #151 |
@milgner this definitely looks related. After making the changes above (and dropping We didn't have any further issues - we've been running quite happily in production since mid-April 2021. |
@ball-hayden I just gave it a try and it seems to have resolved the problem, too! Many thanks, really great tip! I just had to |
Ruby will execute the initializing function named “Init_LIBRARY” in the library when requiring the extension: https://docs.ruby-lang.org/en/3.0/doc/extension_rdoc.html danielpclark/rutie#142
Requiring the .so file doesn't work on OSX, apparently (see #12), so `Rutie.init` *is* necessary (danielpclark/rutie#142). Is the following documentation is Linux specific? https://docs.ruby-lang.org/en/3.0/extension_rdoc.html Anyway, since we use Thermite we need to resolve the extension at `lib/tantiny.so`, hence `lib_path` and `lib_prefix` options.
Requiring the .so file doesn't work on OSX, apparently (see #12), so `Rutie.init` *is* necessary (danielpclark/rutie#142). Is the following documentation is Linux specific? https://docs.ruby-lang.org/en/3.0/extension_rdoc.html Anyway, since we use Thermite we need to resolve the extension at `lib/tantiny.so`, hence `lib_path` and `lib_prefix` options.
Thank you for the project, and apologies for the Q&A/Discussion issue.
Rutie's really interesting, and has helped myself and @saty9 get a Ruby/Rust integration going pretty quickly.
An issue we've come across is that Rails becomes very upset when loading a gem that has a call out to
Rutie#init
(specifically, we get Bus Errors). I suspect the issue is with Spring's forking, but it could also be an issue with Zeitwerk, or some of Rails' other loading "magic".This has led us to investigate a bit further about Ruby's initialisation of native extensions. What we've found is that Ruby will call an initialisation function when
require
ing a shared library, removing the need forRutie#init
[source].For example, we can adapt the example in https://github.com/danielpclark/rutie/tree/master/examples/rutie_ruby_example slightly and get the correct behaviour:
This seems to play more nicely with Rails. My question is: is this safe, or are we missing something?
I'm happy to open a PR if it is safe and you'd like to adopt this pattern.
The text was updated successfully, but these errors were encountered: