LoginSignup
4
1

More than 1 year has passed since last update.

macOSバージョンアップした後、rubyのインストールができなくなった

Last updated at Posted at 2023-03-18

はじめに

rubyの環境構築を試みたところ、エラーが出てしまった。
macOSのアップロードをした後、rubyがインストールできなくなってしまっていた。

※注意※
プログラミング学習中の初心者です。
記述に間違いがあれば、ご指摘いただけますと幸いです。

環境

macOS Ventura 13.2.1

試したこと

まずmacM1チップ用のコードを打ち込みました。

$ OPENSSL_CFLAGS=-Wno-error=implicit-function-declaration RUBY_CFLAGS=-DUSE_FFI_CLOSURE_ALLOC rbenv install 2.6.6

エラーが出てインストール出来ませんでした。
(エラーログ撮り損ねてしまいましたので、割愛します)

$ ruby -v
rbenv: version `2.6.6' is not installed (set by /Users/ユーザー名/workspace/136567_ExamPostApp_Sorcery/.ruby-version)

続いて下記のコードも試してみましたが、エラーとなりました。

$ RUBY_CONFIGURE_OPTS="--with-openssl-dir=$(brew --prefix openssl@1.1)" rbenv install 2.6.6
To follow progress, use 'tail -f /var/folders/ww/blyvnpr94n99mgj80b_b3c6w0000gn/T/ruby-build.20230318172246.85478.log' or pass --verbose
Downloading ruby-2.6.6.tar.bz2...
-> https://cache.ruby-lang.org/pub/ruby/2.6/ruby-2.6.6.tar.bz2
Installing ruby-2.6.6...

WARNING: ruby-2.6.6 is past its end of life and is now unsupported.
It no longer receives bug fixes or critical security updates.

ruby-build: using readline from homebrew

BUILD FAILED (macOS 13.2.1 using ruby-build 20230208.1)

Inspect or clean up the working tree at /var/folders/ww/blyvnpr94n99mgj80b_b3c6w0000gn/T/ruby-build.20230318172246.85478.nDK0jT
Results logged to /var/folders/ww/blyvnpr94n99mgj80b_b3c6w0000gn/T/ruby-build.20230318172246.85478.log

Last 10 log lines:
transform_mjit_header: SKIPPED to transform __sputc
transdb.h updated
Undefined symbols for architecture arm64:
  "__mh_execute_header", referenced from:
      _rb_dump_backtrace_with_lines in addr2line.o
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [libruby.2.6.dylib] Error 1
make: *** Waiting for unfinished jobs....
ln -sf ../../../.ext/include/-darwin22/rb_mjit_min_header-2.6.6.h include/ruby-2.6.0/-darwin22/rb_mjit_min_header-2.6.6.h

治らなかったため、rbenvを一度アンインストールするなどしましたが、
結局下記のコードを実行したところ、インストール成功しました。

$ RUBY_CFLAGS="-w" rbenv install 2.6.6 
To follow progress, use 'tail -f /var/folders/ww/blyvnpr94n99mgj80b_b3c6w0000gn/T/ruby-build.20230318183454.13481.log' or pass --verbose
Downloading openssl-1.1.1t.tar.gz...
-> https://dqw8nmjcqpjn7.cloudfront.net/8dee9b24bdb1dcbf0c3d1e9b02fb8f6bf22165e807f45adeb7c9677536859d3b
Installing openssl-1.1.1t...
Installed openssl-1.1.1t to /Users/ユーザー名/.rbenv/versions/2.6.6

Downloading ruby-2.6.6.tar.bz2...
-> https://cache.ruby-lang.org/pub/ruby/2.6/ruby-2.6.6.tar.bz2
Installing ruby-2.6.6...

WARNING: ruby-2.6.6 is past its end of life and is now unsupported.
It no longer receives bug fixes or critical security updates.

ruby-build: using readline from homebrew
Installed ruby-2.6.6 to /Users/ユーザー名/.rbenv/versions/2.6.6

まとめ

ruby-buildがビルド時にhomebrewのバージョンを使おうとするため、エラーとなっていたことが判明しました
RUBY_CFLAGS="-w"(デフォルトのCFLAGS(C言語のコンパイラオプション))とすることにより、
コンパイラからの警告メッセージを出力しないように設定でき、
例外が発生せず、インストールする事が可能になったようです。

$ RUBY_CFLAGS="-w" rbenv install 2.6.6 

参考ページ

4
1
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
4
1