【M2 Mac】rbenv installでエラーになる時の解決法
困ったこと
$ rbenv install 2.4.1(省略)2 warnings generated.linking shared-object fiddle.bundleUndefined symbols for architecture arm64: "_ffi_prep_closure", referenced from: _initialize in closure.old: symbol(s) not found for architecture arm64clang: error: linker command failed with exit code 1 (use -v to see invocation)make[2]: *** [../../.ext/-darwin21/fiddle.bundle] Error 1make[1]: *** [ext/fiddle/all] Error 2make: *** [build-ext] Error 2
rbenv install
でRuby 2.4.1をインストールしようとすると上記のようにエラーになる。
筆者の環境
- M2 Mac
調べてみると、どうやらApple Silicon搭載のMacだとrbenv install
でコケることが多いらしい。
解決法
RUBY_CFLAGS="-w" rbenv install 2.4.1
RUBY_CFLAGS="-w"
を頭に付けるだけ。これで無事インストールできた。
参考