-
Notifications
You must be signed in to change notification settings - Fork 36
Description
Curses gem fails to build on Ruby 3.4.7 with macOS (arm64): "convertible type of chtype... failed"
Environment
- Ruby version: 3.4.7
- Curses gem version: 1.5.3
- Operating System: macOS 26.1 (Build 25B78)
- Architecture: arm64 (Apple Silicon)
- Compiler: Apple clang version 21.0.0
- ncurses: 6.5 (installed via Homebrew at
/opt/homebrew/opt/ncurses)
Description
The curses gem fails to compile on Ruby 3.4.7 during the native extension build. The build fails at the chtype type conversion test in extconf.rb.
Steps to Reproduce
gem install curses -- --use-system-libraries --with-ncurses-dir=/opt/homebrew/opt/ncursesError Output
From gem_make.out:
checking for convertible type of chtype... failed
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers.
Root Cause
From analyzing mkmf.log, the issue appears to be twofold:
-
Ruby 3.4.7 header warning: Ruby's internal header (
ruby/internal/core/rstring.h:398) triggers a compiler warning:warning: default initialization of an object of type 'struct RString' with const member leaves the object uninitialized [-Wdefault-const-init-field-unsafe] -
chtype conversion test failure: The test to determine the C type equivalent of
chtypefails with:conftest.c:8:20: error: 'conftest_const' declared as an array with a negative size int conftest_const[((rbcv_typedef_)-1 < 0) ? 1 : -1];
The test program attempts to determine if chtype is signed, but the compilation fails before it can complete the type detection logic.
Attempted Workarounds
- Setting
--with-cflags="-Wno-error=default-const-init-field-unsafe"does not resolve the issue - The warning flag is applied correctly, but the chtype conversion test still fails
Relevant Log Excerpt
convertible_int: checking for convertible type of chtype... -------------------- failed
DYLD_LIBRARY_PATH=.:/Users/coder2000/.local/share/mise/installs/ruby/3.4.7/lib ASAN_OPTIONS=detect_leaks=0 "clang -I/Users/coder2000/.local/share/mise/installs/ruby/3.4.7/include/ruby-3.4.0/arm64-darwin25 -I/Users/coder2000/.local/share/mise/installs/ruby/3.4.0/ruby/backward -I/Users/coder2000/.local/share/mise/installs/ruby/3.4.7/include/ruby-3.4.0 -I. -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT -Wno-error=default-const-init-field-unsafe -arch arm64 -c conftest.c"
...
conftest.c:8:20: error: 'conftest_const' declared as an array with a negative size
8 | int conftest_const[((rbcv_typedef_)-1 < 0) ? 1 : -1];
Expected Behavior
The gem should compile successfully and the chtype type conversion should be detected properly.
Additional Notes
- This appears to be specific to Ruby 3.4.x on macOS with Apple Silicon
- The same issue may affect other recent Ruby 3.4.x versions
- ncurses libraries are found correctly - all function checks pass up until the
chtypeconversion test
Question
Is there a known incompatibility with Ruby 3.4.x's internal headers and the type detection logic in extconf.rb? Would it be possible to update the type detection mechanism to be more robust against compiler warnings in Ruby headers?