3
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Mac(M1)でrbenv install時に BUILD FAILEDになった場合の対処法

Posted at

概要

brew upgrade rbenv ruby-bildしてから、rbenv install 3.1.4をしたら、ruby 3.1.4 のインストールに失敗。
BUILD FAILEDのログは以下のような感じ。

# `rbenv install 3.1.4` build failure log
            
readline.c:1903:37: error: use of undeclared identifier 'username_completion_function'; did you mean 'rl_username_completion_function'?
                           rl_username_completion_function);
                           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                           rl_username_completion_function
readline.c:79:42: note: expanded from macro 'rl_username_completion_function'
# define rl_username_completion_function username_completion_function
                                         ^
/usr/local/opt/readline/include/readline/readline.h:494:14: note: 'rl_username_completion_function' declared here
extern char *rl_username_completion_function (const char *, int);
^
1 error generated.

原因

PCはARMなのに、x86_64用のHomebrewが入っているのがよくないらしい。
アーキテクチャの齟齬がエラーの原因では、と。

解決策

  • 手っ取り早い方法:エラーを黙らせてインストール(↓ arch -x86_64いらないかも?)
    RUBY_CFLAGS="-Wno-error=implicit-function-declaration" arch -x86_64 rbenv install 3.1.4

  • 正攻法
    1. 現状の確認
      • which -a brew/usr/local/bin/brew
      • brew configmacOS: 13.6.3-x86_64  となっているのを確認

    2. Homebrewのアンインストール
      sudo NONINTERACTIVE=1 /bin/bash -c "$(curl -fsSLhttps://raw.githubusercontent.com/Homebrew/install/HEAD/uninstall.sh)"
      

    3. Homebrewの再インストール
      /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
      

    4. 結果を確認
      • which -a brew/opt/homebrew/bin/brew
      • brew configmacOS: 13.6.3-x86_64    となっているのを確認 :tada:

    5. rbenv install 3.1.4 成功 :sparkles:

参考

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?