TIL

asdfでRubyのインストールに失敗した

rbenvの代わりにasdfでrubyのバージョン管理をしようとしたらruby-buildでコケた。

エラー発生時のログ
❯ asdf install ruby latest
Downloading openssl-3.0.5.tar.gz...
-> https://dqw8nmjcqpjn7.cloudfront.net/aa7d8d9bef71ad6525c55ba11e5f4397889ce49c2c9349dcea6d3e4f0b024a7a
Installing openssl-3.0.5...
Installed openssl-3.0.5 to /Users/gengogo5/.asdf/installs/ruby/3.1.2

Downloading ruby-3.1.2.tar.gz...
-> https://cache.ruby-lang.org/pub/ruby/3.1/ruby-3.1.2.tar.gz
Installing ruby-3.1.2...
ruby-build: using readline from homebrew

BUILD FAILED (macOS 12.4 using ruby-build 20220726)

Inspect or clean up the working tree at /var/folders/nm/kgmhlhyx4hx6s7dkclnzjjhr0000gn/T/ruby-build.20220807182454.3928.mBJLId
Results logged to /var/folders/nm/kgmhlhyx4hx6s7dkclnzjjhr0000gn/T/ruby-build.20220807182454.3928.log

Last 10 log lines:
                                                                       ^
In file included from compile.c:40:
./vm_callinfo.h:216:16: error: use of undeclared identifier 'RUBY_FUNCTION_NAME_STRING'
    if (debug) rp(ci);
               ^
./internal.h:94:72: note: expanded from macro 'rp'
#define rp(obj) rb_obj_info_dump_loc((VALUE)(obj), __FILE__, __LINE__, RUBY_FUNCTION_NAME_STRING)
                                                                       ^
2 errors generated.
make: *** [compile.o] Error 1

M1 Macだからかな?と思ったけど、brew doctorしてみたら「Command Line Toolsが古い」と何度目かわからない指摘をいただいた。

brew doctorの結果
❯ 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: Your Command Line Tools are too outdated.
Update them from Software Update in System Preferences or run:
  softwareupdate --all --install --force

If that doesn't show you any updates, run:
  sudo rm -rf /Library/Developer/CommandLineTools
  sudo xcode-select --install

Alternatively, manually download them from:
  https://developer.apple.com/download/all/.
You should download the Command Line Tools for Xcode 13.4.


Warning: A newer Command Line Tools release is available.
Update them from Software Update in System Preferences or run:
  softwareupdate --all --install --force

If that doesn't show you any updates, run:
  sudo rm -rf /Library/Developer/CommandLineTools
  sudo xcode-select --install

Alternatively, manually download them from:
  https://developer.apple.com/download/all/.
You should download the Command Line Tools for Xcode 13.4.

言われた通りにxcodeを最新化したら無事通るようになった。

ネイティブコードのビルドで失敗してる時はだいたいこれが原因のような気がする。

類似Issueだと色々な原因で落ちている人たちがいた。

https://github.com/rbenv/ruby-build/issues/1409


多分この先も同じところで躓くことがありそう。


<< 記事一覧へ