Skip to content

fix: use require instead of require_relative for native extension#14

Merged
cpetersen merged 3 commits intoscientist-labs:mainfrom
kisp:fix/use-require-for-native-extension
Mar 24, 2026
Merged

fix: use require instead of require_relative for native extension#14
cpetersen merged 3 commits intoscientist-labs:mainfrom
kisp:fix/use-require-for-native-extension

Conversation

@kisp
Copy link
Copy Markdown
Contributor

@kisp kisp commented Mar 15, 2026

The native extension was loaded with require_relative which forces Ruby to look inside the gem's lib/ directory. RubyGems installs compiled extensions into a separate extensions path and adds it to $LOAD_PATH. Using require resolves via $LOAD_PATH and finds the extension correctly.

See also:
scientist-labs/red-candle#75 / scientist-labs/red-candle@d4d881d

@kisp
Copy link
Copy Markdown
Contributor Author

kisp commented Mar 23, 2026

@cpetersen thanks for fixing the related issue so fast: scientist-labs/red-candle#75

For this project I did not open an issue but made a PR. The situation is very similar.

It seems that the PR so far got unnoticed.

Can we try running the workflow?

I tried to add tests similar to how you resolved the issue in the other project. But I won't promise that they pass.

Sending this from my mobile / Hope it's okay that this is sort of a little reminder:)

cpetersen and others added 3 commits March 23, 2026 13:59
rb-sys 0.9.117 did not support Ruby 4.0's C API changes, causing
"Failed to setup stable API" during native extension compilation.

- Update magnus from 0.6 to 0.8 in Cargo.toml
- Update rb-sys from 0.9.117 to 0.9.124 in Cargo.lock
- Migrate all Rust source files from deprecated magnus 0.6 APIs to
  the new Ruby-handle-based 0.8 APIs (Ruby::get().unwrap() pattern)
- Zero deprecation warnings

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The native extension was loaded with require_relative which forces Ruby
to look inside the gem's lib/ directory. RubyGems installs compiled
extensions into a separate extensions path and adds it to $LOAD_PATH.
Using require resolves via $LOAD_PATH and finds the extension correctly.
@cpetersen cpetersen force-pushed the fix/use-require-for-native-extension branch from 65d39b8 to b9b3216 Compare March 24, 2026 00:53
@cpetersen cpetersen merged commit 3087ff7 into scientist-labs:main Mar 24, 2026
1 check passed
@cpetersen
Copy link
Copy Markdown
Member

Thank you for your contribution! You're right, I did miss this one, thank you for the nudge. I just cut a new release (0.2.5) with your contribution!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants