LoginSignup
0
0

More than 1 year has passed since last update.

macOS Ventura 13.1 に rbenv で Ruby 3.1.3 をインストールする

Posted at

仕事で使っている MacBook が調子悪くなり、新しい MacBook に ruby を rbenv でインストールしようとしたらうまくいかなかったので、原因は不明だが解決できたので方法をメモしておく。

環境

MacBook Pro 14インチ 2021
Apple M1 Pro
macOS 13.1 (Ventura)

状況

ほぼ真っさらな状態から、Xcode 14.2 と Xcode 14.3 をインストールしたあと、Ruby 3.1.3 を rbenv でインストールしようとしたら、以下のエラーが発生した

% rbenv install 3.1.4    
To follow progress, use 'tail -f /var/folders/8z/q0ddcj4942b7w72dz_bqqxfh0000gq/T/ruby-build.20230409015913.23491.log' or pass --verbose
Downloading openssl-3.1.0.tar.gz...
-> https://dqw8nmjcqpjn7.cloudfront.net/aaa925ad9828745c4cad9d9efeb273deca820f2cdcf2c3ac7d7c1212b7c497b4
Installing openssl-3.1.0...
Installed openssl-3.1.0 to ~/.rbenv/versions/3.1.4

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

BUILD FAILED (macOS 13.1 using ruby-build 20230330)

Inspect or clean up the working tree at /var/folders/8z/q0ddcj4942b7w72dz_bqqxfh0000gq/T/ruby-build.20230409015913.23491.uux2tc
Results logged to /var/folders/8z/q0ddcj4942b7w72dz_bqqxfh0000gq/T/ruby-build.20230409015913.23491.log

Last 10 log lines:
checking for llvm-strip... no
checking for gcc... clang
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables... 
checking whether we are cross compiling... configure: error: in `/var/folders/8z/q0ddcj4942b7w72dz_bqqxfh0000gq/T/ruby-build.20230409015913.23491.uux2tc/ruby-3.1.4':
configure: error: cannot run C compiled programs.
If you meant to cross compile, use `--host'.
See `config.log' for more details
make: *** No targets specified and no makefile found.  Stop.

やったこと

新しい Xcode (Command Line Tools) と ruby 3.1.3 の組み合わせが悪いのかと思い以下を試した

  • xcode-select -s 【Xcode 14.2のパス】 で Xcode 14.2 を指定
  • Xcode 14.3 を アインインストール
  • Command Line Tools をアンインストールして
    • rm -rf /Library/Developer/CommandLineTools
    • xcode-select --install
  • readline をアンインストールしてインストール
    • brew uninstall readline
    • brew install readline

その他にも、各コマンドをsudoコマンドで実行したり、覚えてないくらい色々試しました。

結果

以下のコマンドを実行したらインストールできました。

brew update && brew upgrade ruby-build && brew upgrade readline && rbenv install 3.1.3
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0