gem v1.2.2.0 fails to compile native extension with Ruby 3.3.8 on Windows (MINGW)
Gem Version: duckdb 1.2.2.0 Ruby Version: ruby 3.3.8 (2025-04-09 revision b200bad6cd) [x64-mingw-ucrt] Operating System: Windows (e.g., Windows 10, as per log Microsoft Windows [Version 10.0.26100.3775]) Compiler/Environment: MINGW/MSYS2 (as indicated by x64-mingw-ucrt and the build process)
Installation Command Used:
gem install duckdb -N -- --with-duckdb-include="C:\PortableApps\Databases\duckdb" --with-duckdb-lib="C:\PortableApps\Databases\duckdb"
Problem Description:
The duckdb gem (version 1.2.2.0) fails to build its native extension when installing on Ruby 3.3.8 on a Windows system using the MINGW toolchain. The compilation process errors out in appender.c.
Core Error:
The compilation log shows multiple instances of the following error pattern:
appender.c:XXX:YY: error: passing argument 3 of 'rb_define_method' (or 'rb_define_private_method') from incompatible pointer type [-Wincompatible-pointer-types]
For example:
appender.c:379:53: error: passing argument 3 of 'rb_define_method' from incompatible pointer type [-Wincompatible-pointer-types]
379 | rb_define_method(cDuckDBAppender, "initialize", appender_initialize, 3);
| ^~~~~~~~~~~~~~~~~~~
| |
| VALUE (*)(VALUE, VALUE, VALUE, VALUE)
C:/PortableApps/Ruby/Ruby33/include/ruby-3.3.0/ruby/internal/method.h:99:61: note: expected 'VALUE (*)(void)' but argument is of type 'VALUE (*)(VALUE, VALUE, VALUE, VALUE)'
99 | void rb_define_method(VALUE klass, const char *mid, VALUE (*func)(ANYARGS), int arity);
|
~~~~~~~~^~~~~~~~~~~~~~
Analysis:
The Ruby C API in version 3.3.8 (specifically functions like rb_define_method and rb_define_private_method as declared in ruby/internal/method.h and ruby/internal/intern/class.h) expects the third argument (func) to be a function pointer of type VALUE (*)(void) (i.e., a function taking no arguments and returning a VALUE). However, the appender.c file in duckdb gem v1.2.2.0 is passing function pointers with different signatures (e.g., taking one or more VALUE arguments).
This suggests an incompatibility between the gem's C extension code and changes in the Ruby 3.3.8 C API, particularly concerning the ANYARGS macro or stricter enforcement of function pointer types for method definitions. The issue appears consistently across multiple method definitions within appender.c.
Thank you for your reporting
Hmm, I don't have any windows environment now.
But on CI with ruby 3.3.8 (2025-04-09 revision b200bad6cd) [x64-mingw-ucrt] works fine.
So I can't reproduce the error now 🤔
https://github.com/suketa/ruby-duckdb/actions/runs/14963476348/job/42029256002?pr=944#step:3:46
https://github.com/suketa/ruby-duckdb/actions/runs/14963476348/job/42029256002?pr=944#step:7:47
Thanks for considering this issue. Perhaps someone else can confirm the error.
Using AI gives the following answer:
When a gem like duckdb uses native extensions , it means part of the gem is written in C and must be compiled when you install it. That compilation step failed here.
The specific problem:
-
The C code defines Ruby methods using a function called rb_define_method.
-
These methods expect a specific kind of function (called a "callback") that matches what Ruby expects.
-
But the functions being passed to rb_define_method don’t match the expected format anymore in Ruby 3.3 .
-
For example, Ruby now expects a method like this:
VALUE my_method(VALUE self)But the code might be using something like:
VALUE my_method(VALUE self, VALUE arg1, VALUE arg2)
These mismatches cause compiler errors like:
passing argument 3 of 'rb_define_method' from incompatible pointer type
This kind of issue is common when new versions of Ruby come out — especially major ones like Ruby 3.3 — and gems that rely on native extensions take time to adapt. So it's not necessarily your fault or a mistake in your setup; it's just that the gem hasn't caught up yet with the latest Ruby version.
This issues seems to be solved with Ruby version 3.3.9.