Project

General

Profile

Actions

Bug #21845

closed

Need to rebuild C extension of bundled gems after bumping RUBY_ABI_VERSION

Bug #21845: Need to rebuild C extension of bundled gems after bumping RUBY_ABI_VERSION

Added by hsbt (Hiroshi SHIBATA) 1 day ago. Updated 1 day ago.

Status:
Closed
Assignee:
-
Target version:
-
[ruby-core:124596]

Description

I have encountered an issue where fiddle tests are not executed when running make test-bundled-gems, so I investigated the conditions for reproducing the issue.

It caused by RUBY_ABI_VERSION. If I bumped RUBY_ABI_VERSION to 2 from 1, we can't load .bundle/extensions/arm64-darwin-25/4.1.0+2/fiddle-1.1.8/fiddle.bundle

diff --git a/include/ruby/internal/abi.h b/include/ruby/internal/abi.h
index e6d1fa7e8f3..0c99d93bf9b 100644
--- a/include/ruby/internal/abi.h
+++ b/include/ruby/internal/abi.h
@@ -24,7 +24,7 @@
  * In released versions of Ruby, this number is not defined since teeny
  * versions of Ruby should guarantee ABI compatibility.
  */
-#define RUBY_ABI_VERSION 1
+#define RUBY_ABI_VERSION 2

 /* Windows does not support weak symbols so ruby_abi_version will not exist
  * in the shared library. */
diff --git a/lib/fiddle.rb b/lib/fiddle.rb
index f242de8..12b8277 100644
--- a/lib/fiddle.rb
+++ b/lib/fiddle.rb
@@ -1,7 +1,11 @@
 # frozen_string_literal: true

 if RUBY_ENGINE == 'ruby'
-  require 'fiddle.so'
+  begin
+    require 'fiddle.so'
+  rescue LoadError => e
+    puts e.message
+  end
 else
   require 'fiddle/ffi_backend'
 end
@@ -9,6 +13,7 @@
 require 'fiddle/function'
 require 'fiddle/version'

+
 module Fiddle
   if RUBY_ENGINE != 'ruby' # FFI backend
     def self.last_error

I rebuild ruby with make -j and run make test-bundled-gems.

❯ make test-bundled-gems BUNDLED_GEMS=fiddle
generating known_errors.inc
generating encdb.h
generating enc.mk
known_errors.inc unchanged
fetching v1.1.8 ...
encdb.h unchanged
making srcs under enc
making enc
generating transdb.h
transdb.h unchanged
generating makefiles ext/configure-ext.mk
making trans
making encs
ext/configure-ext.mk unchanged
generating makefile exts.mk
exts.mk unchanged
generating known_errors.inc
known_errors.inc unchanged
checking out v1.1.8 (v=1.1.8) ...
M	lib/fiddle.rb
HEAD is now at 310b843 Add 1.1.8 entry

Testing the fiddle gem
["/Users/hsbt/Documents/github.com/ruby/ruby/exe/ruby", "-C", "/Users/hsbt/Documents/github.com/ruby/ruby/gems/src/fiddle", "/Users/hsbt/Documents/github.com/ruby/ruby/.bundle/bin/rake", "test"]
Dummy `compile` task defined in /Users/hsbt/Documents/github.com/ruby/ruby/gems/lib/rake/extensiontask.rb
compile =>
Dummy `compile` task defined in /Users/hsbt/Documents/github.com/ruby/ruby/gems/lib/rake/extensiontask.rb
compile =>
/Users/hsbt/Documents/github.com/ruby/ruby/exe/ruby test/run.rb
/Users/hsbt/Documents/github.com/ruby/ruby/gems/src/fiddle/test/fiddle/test_pointer.rb:288: warning: ambiguous first argument; put parentheses or a space even after `-` operator
incompatible ABI version of binary - /Users/hsbt/Documents/github.com/ruby/ruby/.bundle/extensions/arm64-darwin-25/4.1.0+2/fiddle-1.1.8/fiddle.bundle
/Users/hsbt/Documents/github.com/ruby/ruby/gems/src/fiddle/lib/fiddle.rb:56:in '<module:Fiddle>': uninitialized constant Fiddle::WINDOWS (NameError)

    if WINDOWS
       ^^^^^^^
	from /Users/hsbt/Documents/github.com/ruby/ruby/gems/src/fiddle/lib/fiddle.rb:17:in '<top (required)>'
	from /Users/hsbt/Documents/github.com/ruby/ruby/gems/src/fiddle/test/fiddle/helper.rb:5:in 'Kernel#require'
	from /Users/hsbt/Documents/github.com/ruby/ruby/gems/src/fiddle/test/fiddle/helper.rb:5:in '<top (required)>'
	from /Users/hsbt/Documents/github.com/ruby/ruby/gems/src/fiddle/test/fiddle/test_pointer.rb:3:in 'Kernel#require_relative'
	from /Users/hsbt/Documents/github.com/ruby/ruby/gems/src/fiddle/test/fiddle/test_pointer.rb:3:in '<top (required)>'
	from /Users/hsbt/Documents/github.com/ruby/ruby/.bundle/gems/test-unit-3.7.7/lib/test/unit/collector/load.rb:118:in 'Kernel#require'
	from /Users/hsbt/Documents/github.com/ruby/ruby/.bundle/gems/test-unit-3.7.7/lib/test/unit/collector/load.rb:118:in 'block in Test::Unit::Collector::Load#collect_file'
	from /Users/hsbt/Documents/github.com/ruby/ruby/.bundle/gems/test-unit-3.7.7/lib/test/unit/collector/load.rb:140:in 'Test::Unit::Collector::Load#add_load_path'
	from /Users/hsbt/Documents/github.com/ruby/ruby/.bundle/gems/test-unit-3.7.7/lib/test/unit/collector/load.rb:116:in 'Test::Unit::Collector::Load#collect_file'
	from /Users/hsbt/Documents/github.com/ruby/ruby/.bundle/gems/test-unit-3.7.7/lib/test/unit/collector/load.rb:91:in 'block in Test::Unit::Collector::Load#collect_recursive'
	from /Users/hsbt/Documents/github.com/ruby/ruby/.bundle/gems/test-unit-3.7.7/lib/test/unit/collector/load.rb:89:in 'Array#each'
	from /Users/hsbt/Documents/github.com/ruby/ruby/.bundle/gems/test-unit-3.7.7/lib/test/unit/collector/load.rb:89:in 'Test::Unit::Collector::Load#collect_recursive'
	from /Users/hsbt/Documents/github.com/ruby/ruby/.bundle/gems/test-unit-3.7.7/lib/test/unit/collector/load.rb:47:in 'block (2 levels) in Test::Unit::Collector::Load#collect'
	from /Users/hsbt/Documents/github.com/ruby/ruby/.bundle/gems/test-unit-3.7.7/lib/test/unit/collector/load.rb:44:in 'Array#each'
	from /Users/hsbt/Documents/github.com/ruby/ruby/.bundle/gems/test-unit-3.7.7/lib/test/unit/collector/load.rb:44:in 'block in Test::Unit::Collector::Load#collect'
	from /Users/hsbt/Documents/github.com/ruby/ruby/.bundle/gems/test-unit-3.7.7/lib/test/unit/collector/load.rb:140:in 'Test::Unit::Collector::Load#add_load_path'
	from /Users/hsbt/Documents/github.com/ruby/ruby/.bundle/gems/test-unit-3.7.7/lib/test/unit/collector/load.rb:38:in 'Test::Unit::Collector::Load#collect'
	from /Users/hsbt/Documents/github.com/ruby/ruby/.bundle/gems/test-unit-3.7.7/lib/test/unit/autorunner.rb:109:in 'block in <class:AutoRunner>'
	from /Users/hsbt/Documents/github.com/ruby/ruby/.bundle/gems/test-unit-3.7.7/lib/test/unit/autorunner.rb:490:in 'Test::Unit::AutoRunner#run'
	from /Users/hsbt/Documents/github.com/ruby/ruby/.bundle/gems/test-unit-3.7.7/lib/test/unit/autorunner.rb:69:in 'Test::Unit::AutoRunner.run'
	from test/run.rb:21:in '<main>'
rake aborted!
Command failed with status (1): [/Users/hsbt/Documents/github.com/ruby/ruby/exe/ruby test/run.rb]
/Users/hsbt/Documents/github.com/ruby/ruby/gems/src/fiddle/Rakefile:5:in 'block in <top (required)>'
/Users/hsbt/Documents/github.com/ruby/ruby/.bundle/gems/rake-13.3.1/exe/rake:27:in '<top (required)>'
Tasks: TOP => test
(See full trace by running task with --trace)
Tests failed with exit code 1
Failed gems: fiddle
make: *** [uncommon.mk:1599: yes-test-bundled-gems-run] Error 1

Simple confirmation is here:

❯ ./exe/ruby -e "require_relative '.bundle/extensions/arm64-darwin-25/4.1.0+2/fiddle-1.1.8/fiddle.bundle'"
-e:1:in 'Kernel#require_relative': incompatible ABI version of binary - /Users/hsbt/Documents/github.com/ruby/ruby/.bundle/extensions/arm64-darwin-25/4.1.0+2/fiddle-1.1.8/fiddle.bundle (LoadError)
	from -e:1:in '<main>'

I fixed this with git clean -fxd and delete all old artifacts or use fresh clone of ruby/ruby repository.

Actions

Also available in: PDF Atom