Skip to content

Fix native extension loading for versioned Ruby directories#2

Open
twokidsCarl wants to merge 1 commit intomarcoroth:mainfrom
twokidsCarl:fix/ruby-version-routing-native-ext
Open

Fix native extension loading for versioned Ruby directories#2
twokidsCarl wants to merge 1 commit intomarcoroth:mainfrom
twokidsCarl:fix/ruby-version-routing-native-ext

Conversation

@twokidsCarl
Copy link
Copy Markdown

Problem

The precompiled gem ships native .bundle files under versioned subdirectories:

lib/bubblezone/3.2/bubblezone.bundle
lib/bubblezone/3.3/bubblezone.bundle
lib/bubblezone/3.4/bubblezone.bundle
lib/bubblezone/4.0/bubblezone.bundle

But lib/bubblezone.rb uses:

require_relative "bubblezone/bubblezone"

This only resolves to lib/bubblezone/bubblezone.bundle (which doesn't exist), causing a LoadError on all Ruby versions.

Fix

Try the versioned path first, fall back to the unversioned path:

begin
  major, minor, = RUBY_VERSION.split(".")
  require_relative "bubblezone/#{major}.#{minor}/bubblezone"
rescue LoadError
  require_relative "bubblezone/bubblezone"
end

This matches the approach already used by bubbletea-ruby.

Test plan

  • Verified on Ruby 4.0.0 (arm64-darwin): require "bubblezone" now succeeds
  • Fallback path preserved for non-versioned layouts

🤖 Generated with Claude Code

The precompiled gem ships `.bundle` files under versioned subdirectories
(e.g. `lib/bubblezone/3.4/`, `lib/bubblezone/4.0/`) but the loader
uses `require_relative "bubblezone/bubblezone"` which only looks in the
top-level directory.

Try the versioned path `bubblezone/{major}.{minor}/bubblezone` first,
falling back to the unversioned path. This matches the approach used by
bubbletea-ruby.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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.

1 participant