Homebrew / homebrew-core

🍻 Default formulae for the missing package manager for macOS (or Linux)
https://brew.sh
BSD 2-Clause "Simplified" License
13.38k stars 12.17k forks source link

ruby >= 3.2 bottles have an incorrect path in RbConfig::CONFIG["AR"] #170978

Open eregon opened 1 month ago

eregon commented 1 month ago

brew gist-logs <formula> link OR brew config AND brew doctor output

$ brew config
HOMEBREW_VERSION: 4.2.19
ORIGIN: https://github.com/Homebrew/brew
HEAD: 54bea636b41f7953c01a7da5f488f08c1b42ffd1
Last commit: 2 weeks ago
Core tap HEAD: 9038b2b1e9129bb42808892573e426d6deb88230
Core tap last commit: 2 weeks ago
Core tap JSON: 22 Apr 18:07 UTC
Core cask tap HEAD: 9599051069decc2863265e1c688612c332976d91
Core cask tap last commit: 2 weeks ago
Core cask tap JSON: 22 Apr 18:07 UTC
HOMEBREW_PREFIX: /opt/homebrew
HOMEBREW_CASK_OPTS: ["--no-quarantine"]
HOMEBREW_COLOR: set
HOMEBREW_GITHUB_API_TOKEN: set
HOMEBREW_MAKE_JOBS: 3
HOMEBREW_NO_AUTO_UPDATE: set
HOMEBREW_NO_INSTALL_CLEANUP: set
Homebrew Ruby: 3.1.4 => /opt/homebrew/Library/Homebrew/vendor/portable-ruby/3.1.4/bin/ruby
CPU: 3-core 64-bit dunno
Clang: 15.0.0 build 1500
Git: 2.44.0 => /opt/homebrew/bin/git
Curl: 8.4.0 => /usr/bin/curl
macOS: 14.4.1-arm64
CLT: 15.3.0.0.1.1708646388
Xcode: 15.0.1 => /Applications/Xcode_15.0.1.app/Contents/Developer
Rosetta 2: false

$ brew doctor
Please note that these warnings are just used to help the Homebrew maintainers
with debugging if you file an issue. If everything you use Homebrew for is
working fine: please don't worry or file an issue; just ignore this. Thanks!

Warning: Some installed formulae are deprecated or disabled.
You should find replacements for the following formulae:
  openssl@1.1
  packer

Warning: You have an unnecessary local Cask tap.
This can cause problems installing up-to-date casks.
Please remove it by running:
  brew untap homebrew/cask

Warning: You have an unnecessary local Core tap!
This can cause problems installing up-to-date formulae.
Please remove it by running:
 brew untap homebrew/core

Verification

What were you trying to do (and why)?

In https://github.com/ruby/prism/issues/2716 we had a report that someone using ruby from Homebrew failed to build the Prism gem. After investigation it became clear the problem is that the value of RbConfig::CONFIG["AR"] is incorrect in the bottles of the ruby 3.2 and 3.3 formulae.

What happened (include all command output)?

CC is fine, and this explains why most gems with native extensions install fine:

$ for v in 3.0 3.1 3.2 3.3; do echo $v; /opt/homebrew/opt/ruby@$v/bin/ruby -e 'pp RbConfig::CONFIG["CC"]'; done       
3.0
"clang -fdeclspec"
3.1
"clang"
3.2
"clang"
3.3
"clang"

AR:

$ for v in 3.0 3.1 3.2 3.3; do echo $v; /opt/homebrew/opt/ruby@$v/bin/ruby -e 'pp RbConfig::CONFIG["AR"]'; done       
3.0
"ar"
3.1
"ar"
3.2
"/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ar"
3.3
"/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ar"

But AR is this absolute path from Ruby 3.2, which can cause problems. Notably, the path /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ar does not exist if XCode is not installed and only the Command Line Tools are installed. This means any Ruby relying on RbConfig::CONFIG["AR"] is broken.

What did you expect to happen?

RbConfig::CONFIG["AR"] is valid and existing path for any Homebrew user, whether they have XCode installed or not.

This change might be partly caused by changes in CRuby upstream. However, it seems clear Homebrew should ship a properly-built Ruby with correct paths. See https://github.com/Homebrew/homebrew-portable-ruby/pull/187 which seems a fairly similar issue but for homebrew-portable-ruby instead of the ruby@3.2/ruby@3.3 formulae. The fix can very likely be the same/similar.

Step-by-step reproduction instructions (by running brew commands)

brew install ruby@3.2
/opt/homebrew/opt/ruby@3.2/bin/ruby -e 'pp RbConfig::CONFIG["AR"]'

brew install ruby@3.3
/opt/homebrew/opt/ruby@3.3/bin/ruby -e 'pp RbConfig::CONFIG["AR"]'
eregon commented 1 month ago

I copy here the whole RbConfig::CONFIG. Note that NM is also incorrect and has the same problem ("NM"=>"/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/nm --no-llvm-bc",).

/opt/homebrew/opt/ruby@3.3/bin/ruby -e 'pp RbConfig::CONFIG.sort.to_h'                                              
{"ADDITIONAL_DLDFLAGS"=>"",
 "ALLOCA"=>"",
 "AR"=>"/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ar",
 "ARCHFILE"=>"",
 "ARCH_FLAG"=>"-arch arm64",
 "ARFLAGS"=>"rcu ",
 "AS"=>"as",
 "ASFLAGS"=>"",
 "ASMEXT"=>"S",
 "BUILTIN_TRANSSRCS"=>" enc/trans/newline.c",
 "CARGO"=>"",
 "CARGO_BUILD_ARGS"=>"",
 "CC"=>"clang",
 "CCDLFLAGS"=>"-fno-common",
 "CC_VERSION"=>"clang --version",
 "CC_VERSION_MESSAGE"=>
  "Apple clang version 15.0.0 (clang-1500.1.0.2.5)\n" +
  "Target: arm64-apple-darwin23.2.0\n" +
  "Thread model: posix\n" +
  "InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin",
 "CC_WRAPPER"=>"",
 "CFLAGS"=>
  "-fdeclspec -O3 -fno-fast-math -ggdb3 -Wall -Wextra -Wextra-tokens -Wdeprecated-declarations -Wdivision-by-zero -Wdiv-by-zero -Wimplicit-function-declaration -Wimplicit-int -Wpointer-arith -Wshorten-64-to-32 -Wwrite-strings -Wold-style-definition -Wmis
sing-noreturn -Wno-cast-function-type -Wno-constant-logical-operand -Wno-long-long -Wno-missing-field-initializers -Wno-overlength-strings -Wno-parentheses-equality -Wno-self-assign -Wno-tautological-compare -Wno-unused-parameter -Wno-unused-value -Wunus
ed-variable -Wmisleading-indentation -Wundef -fno-common -pipe",
 "CHDIR"=>"cd -P",
 "COMMON_HEADERS"=>"",
 "COMMON_LIBS"=>"",
 "COMMON_MACROS"=>"",
 "CONFIGURE"=>"configure",
 "COROUTINE_TYPE"=>"arm64",
 "COUTFLAG"=>"-o ",
 "CP"=>"cp",
 "CPP"=>"clang -E",
 "CPPFLAGS"=>"-D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT  ",
 "CPPOUTFILE"=>"-o conftest.i",
 "CROSS_COMPILING"=>"no",
 "CSRCFLAG"=>"",
 "CXX"=>"clang++",
 "CXXFLAGS"=>"-fdeclspec",
 "DEFS"=>"",
 "DESTDIR"=>"",
 "DLDFLAGS"=>"-L/opt/homebrew/opt/libyaml/lib -L/opt/homebrew/opt/openssl@3/lib -Wl,-undefined,dynamic_lookup",
 "DLDLIBS"=>"",
 "DLDSHARED"=>"clang -dynamiclib",
 "DLEXT"=>"bundle",
 "DLLWRAP"=>"",
 "DLNOBJ"=>"dln.o",
 "DOT"=>"",
 "DOXYGEN"=>"",
 "ECHO_C"=>"\\\\c",
 "ECHO_N"=>"",
 "ECHO_T"=>"",
 "EGREP"=>"/usr/bin/grep -E",
 "ENABLE_DEBUG_ENV"=>"",
 "ENABLE_SHARED"=>"yes",
 "ENCSTATIC"=>"",
 "EXECUTABLE_EXTS"=>"",
 "EXEEXT"=>"",
 "EXPORT_PREFIX"=>"",
 "EXTDLDFLAGS"=>"",
 "EXTLDFLAGS"=>"",
 "EXTOUT"=>".ext",
 "EXTSTATIC"=>"",
 "GCC"=>"yes",
 "GIT"=>"git",
 "GNU_LD"=>"no",
 "GREP"=>"/usr/bin/grep",
 "HAVE_GIT"=>"yes",
 "INSTALL"=>"/usr/bin/install -c",
 "INSTALL_DATA"=>"/usr/bin/install -c -m 644",
 "INSTALL_PROGRAM"=>"/usr/bin/install -c",
 "INSTALL_SCRIPT"=>"/usr/bin/install -c",
 "INSTALL_STATIC_LIBRARY"=>"no",
 "LD"=>"ld",
 "LDFLAGS"=>"-L. -fstack-protector-strong -L/opt/homebrew/opt/libyaml/lib -L/opt/homebrew/opt/openssl@3/lib",
 "LDSHARED"=>"clang -dynamic -bundle",
 "LDSHAREDXX"=>"clang++ -dynamic -bundle",
 "LIBEXT"=>"a",
 "LIBPATHENV"=>"DYLD_LIBRARY_PATH",
 "LIBPATHFLAG"=>" -L%s",
 "LIBRUBY"=>"libruby.3.3.dylib",
 "LIBRUBYARG"=>"-lruby.3.3",
 "LIBRUBYARG_SHARED"=>"-lruby.3.3",
 "LIBRUBYARG_STATIC"=>"-lruby.3.3-static -framework CoreFoundation -ldl -lobjc -lpthread ",
 "LIBRUBY_A"=>"libruby.3.3-static.a",
 "LIBRUBY_ALIASES"=>"libruby.dylib",
 "LIBRUBY_RELATIVE"=>"no",
 "LIBRUBY_SO"=>"libruby.3.3.dylib",
 "LIBRUBY_SONAME"=>"libruby.3.3.dylib",
 "LIBS"=>"-lpthread ",
 "LINK_SO"=>"\n" + "dsymutil $@ 2>/dev/null; { test -z '$(RUBY_CODESIGN)' || codesign -s '$(RUBY_CODESIGN)' -f $@; }",
 "LN_S"=>"ln -s",
 "MAINLIBS"=>"-ldl -lobjc -lpthread ",
 "MAJOR"=>"3",
 "MAKEDIRS"=>"mkdir -p",
 "MAKEFILES"=>"Makefile GNUmakefile",
 "MANTYPE"=>"doc",
 "MINOR"=>"3",
 "MKDIR_P"=>"mkdir -p",
 "MKMF_VERBOSE"=>"0",
 "NM"=>"/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/nm --no-llvm-bc",
 "NULLCMD"=>":",
 "OBJCOPY"=>":",
 "OBJDUMP"=>"objdump",
 "OBJEXT"=>"o",
 "OUTFLAG"=>"-o ",
 "PACKAGE"=>"ruby",
 "PACKAGE_BUGREPORT"=>"",
 "PACKAGE_NAME"=>"",
 "PACKAGE_STRING"=>"",
 "PACKAGE_TARNAME"=>"",
 "PACKAGE_URL"=>"",
 "PACKAGE_VERSION"=>"",
 "PATCHLEVEL"=>"0",
 "PATH_SEPARATOR"=>":",
 "PKG_CONFIG"=>"pkg-config",
 "PLATFORM_DIR"=>"",
 "POSTLINK"=>"dsymutil $@ 2>/dev/null; { test -z '$(RUBY_CODESIGN)' || codesign -s '$(RUBY_CODESIGN)' -f $@; }",
 "PRELOADENV"=>"DYLD_INSERT_LIBRARIES",
 "PREP"=>"miniruby",
 "RANLIB"=>"ranlib",
 "RI_BASE_NAME"=>"ri",
 "RJIT_SUPPORT"=>"yes",
 "RM"=>"rm -f",
 "RMALL"=>"rm -fr",
 "RMDIR"=>"rmdir",
 "RMDIRS"=>"rmdir -p",
 "RPATHFLAG"=>"",
 "RUBYW_BASE_NAME"=>"rubyw",
 "RUBYW_INSTALL_NAME"=>"",
 "RUBY_API_VERSION"=>"3.3",
 "RUBY_BASE_NAME"=>"ruby",
 "RUBY_DEVEL"=>"",
 "RUBY_EXEC_PREFIX"=>"/opt/homebrew/Cellar/ruby/3.3.0",
 "RUBY_INSTALL_NAME"=>"ruby",
 "RUBY_LIB_VERSION"=>"",
 "RUBY_LIB_VERSION_STYLE"=>"3\t/* full */",
 "RUBY_PROGRAM_VERSION"=>"3.3.0",
 "RUBY_SEARCH_PATH"=>"",
 "RUBY_SO_NAME"=>"ruby.3.3",
 "RUBY_VERSION_NAME"=>"ruby-3.3.0",
 "RUSTC"=>"rustc",
 "SDKROOT"=>"",
 "SET_MAKE"=>"",
 "SHELL"=>"/bin/sh",
 "SOEXT"=>"dylib",
 "SOLIBS"=>"-ldl -lobjc -lpthread ",
 "STATIC"=>"",
 "STRIP"=>"strip -A -n",
 "SYMBOL_PREFIX"=>"_",
 "TEENY"=>"0",
 "TEST_RUNNABLE"=>"yes",
 "THREAD_MODEL"=>"pthread",
 "TRY_LINK"=>"",
 "UNICODE_EMOJI_VERSION"=>"15.0",
 "UNICODE_VERSION"=>"15.0.0",
 "UNIVERSAL_ARCHNAMES"=>"",
 "UNIVERSAL_INTS"=>"",
 "USE_LLVM_WINDRES"=>"",
 "WASMOPT"=>"",
 "WERRORFLAG"=>"-Werror",
 "WINDRES"=>"",
 "YJIT_LIBS"=>"yjit/target/release/libyjit.a",
 "YJIT_OBJ"=>"yjit.o",
 "YJIT_SUPPORT"=>"yes",
 "arch"=>"arm64-darwin23",
 "archdir"=>"/opt/homebrew/Cellar/ruby/3.3.0/lib/ruby/3.3.0/arm64-darwin23",
 "archincludedir"=>"/opt/homebrew/Cellar/ruby/3.3.0/include/arm64-darwin23",
 "archlibdir"=>"/opt/homebrew/Cellar/ruby/3.3.0/lib/arm64-darwin23",
 "bindir"=>"/opt/homebrew/Cellar/ruby/3.3.0/bin",
 "build"=>"aarch64-apple-darwin23.2.0",
 "build_alias"=>"",
 "build_cpu"=>"aarch64",
 "build_os"=>"darwin23.2.0",
 "build_vendor"=>"apple",
 "cflags"=>
  "-fdeclspec -O3 -fno-fast-math -ggdb3 -Wall -Wextra -Wextra-tokens -Wdeprecated-declarations -Wdivision-by-zero -Wdiv-by-zero -Wimplicit-function-declaration -Wimplicit-int -Wpointer-arith -Wshorten-64-to-32 -Wwrite-strings -Wold-style-definition -Wmis
sing-noreturn -Wno-cast-function-type -Wno-constant-logical-operand -Wno-long-long -Wno-missing-field-initializers -Wno-overlength-strings -Wno-parentheses-equality -Wno-self-assign -Wno-tautological-compare -Wno-unused-parameter -Wno-unused-value -Wunus
ed-variable -Wmisleading-indentation -Wundef",
 "cleanlibs"=>"$(TARGET_SO).dSYM",
 "codesign"=>"codesign",
 "configure_args"=>
  " '--prefix=/opt/homebrew/Cellar/ruby/3.3.0' '--enable-shared' '--disable-silent-rules' '--with-sitedir=/opt/homebrew/lib/ruby/site_ruby' '--with-vendordir=/opt/homebrew/lib/ruby/vendor_ruby' '--with-opt-dir=/opt/homebrew/opt/libyaml:/opt/homebrew/opt/
openssl@3' '--without-gmp' 'MJIT_CC=/usr/bin/clang' 'CC=clang' 'CXX=clang++'",
 "cppflags"=>"",
 "cxxflags"=>"",
 "datadir"=>"/opt/homebrew/Cellar/ruby/3.3.0/share",
 "datarootdir"=>"/opt/homebrew/Cellar/ruby/3.3.0/share",
 "debugflags"=>"-ggdb3",
 "docdir"=>"/opt/homebrew/Cellar/ruby/3.3.0/share/doc/ruby",
 "dsymutil"=>"dsymutil",
 "dvidir"=>"/opt/homebrew/Cellar/ruby/3.3.0/share/doc/ruby",
 "exec"=>"exec",
 "exec_prefix"=>"/opt/homebrew/Cellar/ruby/3.3.0",
 "host"=>"arm64-apple-darwin23",
 "host_alias"=>"",
 "host_cpu"=>"arm64",
 "host_os"=>"darwin23",
 "host_vendor"=>"apple",
 "htmldir"=>"/opt/homebrew/Cellar/ruby/3.3.0/share/doc/ruby",
 "incflags"=>"-I/opt/homebrew/opt/libyaml/include -I/opt/homebrew/opt/openssl@3/include",
 "includedir"=>"/opt/homebrew/Cellar/ruby/3.3.0/include",
 "incflags"=>"-I/opt/homebrew/opt/libyaml/include -I/opt/homebrew/opt/openssl@3/include",                                                                                                                                                             [1/1264]
 "includedir"=>"/opt/homebrew/Cellar/ruby/3.3.0/include",
 "infodir"=>"/opt/homebrew/Cellar/ruby/3.3.0/share/info",
 "libdir"=>"/opt/homebrew/Cellar/ruby/3.3.0/lib",
 "libdirname"=>"libdir",
 "libexecdir"=>"/opt/homebrew/Cellar/ruby/3.3.0/libexec",
 "localedir"=>"/opt/homebrew/Cellar/ruby/3.3.0/share/locale",
 "localstatedir"=>"/opt/homebrew/Cellar/ruby/3.3.0/var",
 "mandir"=>"/opt/homebrew/Cellar/ruby/3.3.0/share/man",
 "oldincludedir"=>"/usr/include",
 "optflags"=>"-O3 -fno-fast-math",
 "pdfdir"=>"/opt/homebrew/Cellar/ruby/3.3.0/share/doc/ruby",
 "platform"=>"arm64-darwin23",
 "prefix"=>"/opt/homebrew/Cellar/ruby/3.3.0",
 "psdir"=>"/opt/homebrew/Cellar/ruby/3.3.0/share/doc/ruby",
 "ridir"=>"/opt/homebrew/Cellar/ruby/3.3.0/share/ri",
 "ruby_install_name"=>"ruby",
 "ruby_pc"=>"ruby-3.3.pc",
 "ruby_version"=>"3.3.0",
 "rubyarchdir"=>"/opt/homebrew/Cellar/ruby/3.3.0/lib/ruby/3.3.0/arm64-darwin23",
 "rubyarchhdrdir"=>"/opt/homebrew/Cellar/ruby/3.3.0/include/ruby-3.3.0/arm64-darwin23",
 "rubyarchprefix"=>"/opt/homebrew/Cellar/ruby/3.3.0/lib/ruby/arm64-darwin23",
 "rubyhdrdir"=>"/opt/homebrew/Cellar/ruby/3.3.0/include/ruby-3.3.0",
 "rubylibdir"=>"/opt/homebrew/Cellar/ruby/3.3.0/lib/ruby/3.3.0",
 "rubylibprefix"=>"/opt/homebrew/Cellar/ruby/3.3.0/lib/ruby",
 "rubysitearchprefix"=>"/opt/homebrew/Cellar/ruby/3.3.0/lib/ruby/arm64-darwin23",
 "rubyw_install_name"=>"",
 "runstatedir"=>"/opt/homebrew/Cellar/ruby/3.3.0/var/run",
 "sbindir"=>"/opt/homebrew/Cellar/ruby/3.3.0/sbin",
 "setup"=>"Setup",
 "sharedstatedir"=>"/opt/homebrew/Cellar/ruby/3.3.0/com",
 "sitearch"=>"arm64-darwin23",
 "sitearchdir"=>"/opt/homebrew/lib/ruby/site_ruby/3.3.0/arm64-darwin23",
 "sitearchhdrdir"=>"/opt/homebrew/Cellar/ruby/3.3.0/include/ruby-3.3.0/site_ruby/arm64-darwin23",
 "sitearchincludedir"=>"/opt/homebrew/Cellar/ruby/3.3.0/include/arm64-darwin23",
 "sitearchlibdir"=>"/opt/homebrew/Cellar/ruby/3.3.0/lib/arm64-darwin23",
 "sitedir"=>"/opt/homebrew/lib/ruby/site_ruby",
 "sitehdrdir"=>"/opt/homebrew/Cellar/ruby/3.3.0/include/ruby-3.3.0/site_ruby",
 "sitelibdir"=>"/opt/homebrew/lib/ruby/site_ruby/3.3.0",
 "strict_warnflags"=>"",
 "sysconfdir"=>"/opt/homebrew/Cellar/ruby/3.3.0/etc",
 "target"=>"arm64-apple-darwin23",
 "target_alias"=>"",
 "target_cpu"=>"arm64",
 "target_os"=>"darwin23",
 "target_vendor"=>"apple",
 "topdir"=>"/opt/homebrew/Cellar/ruby/3.3.0/lib/ruby/3.3.0/arm64-darwin23",
 "try_header"=>"",
 "vendorarchdir"=>"/opt/homebrew/lib/ruby/vendor_ruby/3.3.0/arm64-darwin23",
 "vendorarchhdrdir"=>"/opt/homebrew/Cellar/ruby/3.3.0/include/ruby-3.3.0/vendor_ruby/arm64-darwin23",
 "vendordir"=>"/opt/homebrew/lib/ruby/vendor_ruby",
 "vendorhdrdir"=>"/opt/homebrew/Cellar/ruby/3.3.0/include/ruby-3.3.0/vendor_ruby",
 "vendorlibdir"=>"/opt/homebrew/lib/ruby/vendor_ruby/3.3.0",
 "warnflags"=>
  "-Wall -Wextra -Wextra-tokens -Wdeprecated-declarations -Wdivision-by-zero -Wdiv-by-zero -Wimplicit-function-declaration -Wimplicit-int -Wpointer-arith -Wshorten-64-to-32 -Wwrite-strings -Wold-style-definition -Wmissing-noreturn -Wno-cast-function-type
 -Wno-constant-logical-operand -Wno-long-long -Wno-missing-field-initializers -Wno-overlength-strings -Wno-parentheses-equality -Wno-self-assign -Wno-tautological-compare -Wno-unused-parameter -Wno-unused-value -Wunused-variable -Wmisleading-indentation 
-Wundef",
 "wasmoptflags"=>""}
eregon commented 1 month ago

My brew doctor output says Your system is ready to brew. and am still able to reproduce my issue.

I ticked this box even though the output says differently but I am absolutely certain that would change nothing, and the issue reproduces 100% regardless of that brew doctor output. It's an issue that is simply part of the prebuilt ruby@3.2 and ruby@3.3 bottles.


One more thought: this problem could likely also be solved if the bottle was built on a system which does not have XCode installed, because then CRuby wouldn't find those executables. Or maybe there are ways to tell CRuby which toolchain to use (the CLT is better if it's always guaranteed to be there for Homebrew) rather than letting it guess.

Bo98 commented 1 month ago

This is caused by https://github.com/ruby/ruby/commit/038f9ade3c4d965415e4956561975454cf9eeb21.

eregon commented 1 month ago

Indeed, I see:

bash-3.2$ cc -print-prog-name=ar
/Applications/Xcode_15.0.1.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ar
bash-3.2$ cc -print-prog-name=nm
/Applications/Xcode_15.0.1.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/nm
bash-3.2$ cc -print-prog-name=ld
/Applications/Xcode_15.0.1.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld

Interesting that LD above is not affected but AR and NM are.

Any idea how to fix this in Homebrew? Maybe AR=ar NM=nm ./configure ... or so could work.

Maybe it should be changed in CRuby? But that wouldn't fix it for existing 3.2 and 3.3 releases.

cc @nobu since you did this change and might know more about it

Bo98 commented 1 month ago

This bug will likely affect all macOS Ruby builds (unless Xcode is missing) so definitely seems like an upstream fix is desirable here.

eregon commented 1 month ago

Agreed, although for the common case of compiling ruby from source on the same machine it's not an issue because then either no XCode and fine anyway, or XCode is installed and then those paths will most likely work fine (unless XCode is later uninstalled).

eregon commented 1 month ago

@Bo98 Could you file an issue at https://bugs.ruby-lang.org/ ?

Also, since this basically only happens with Homebrew builds of CRuby (Homebrew is one of the very few to have binary builds of Ruby on macOS), it seems worth working around in parallel in Homebrew until it gets fixed & released in CRuby.

Bo98 commented 1 month ago

Likely affects MacPorts too - but I haven't checked for sure.

Can open an issue shortly, and maybe a pull request too if I find the time.

Bo98 commented 1 month ago

Apologies for the delay: https://bugs.ruby-lang.org/issues/20499

ZhongRuoyu commented 1 month ago

Fixed upstream at ruby/ruby@8277cf0799145bed0c813bfcc187739f77b3102d

github-actions[bot] commented 3 weeks ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.

ParadoxV5 commented 2 weeks ago

Upstream fix backported to Ruby 3.3.3: ruby/ruby@d3b1398

Bo98 commented 2 weeks ago

Should be fixed now after a brew upgrade ruby.

We will accept a PR to apply the patch to ruby@3.2 (I may get around to it but probably not for a few days).