在mac M1上使用ruby-install安装ruby2.6.6或2.7.2时,会出现以下错误。Ruby 3.0.0运行良好,但是任何较旧的版本都会在readline中出错,并且不允许安装ruby。
readline.c:1905: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
^
/opt/homebrew/opt/readline/include/readline/readline.h:485:14: note: 'rl_username_completion_function' declared here
extern char *rl_username_completion_function PARAMS((const char *, int));发布于 2021-04-14 22:59:54
我已经能够安装作为x86_64代码和3.0.1作为arm64代码。我使用rvm,但这应该适用于其他东西。

中
alias abrew="/opt/homebrew/bin/brew"
alias i="arch -x86_64"
alias ibrew="arch -x86_64 /usr/local/bin/brew"
alias irvm="arch -x86_64 rvm"
# Add RVM to PATH for scripting. Make sure this is the last PATH variable change.
export PATH="$PATH:$HOME/.rvm/bin"
_ARCH=$(arch)
PROMPT="$_ARCH $PROMPT"
# Requires iterm2
if [[ "$_ARCH" == "i386" ]]; then
echo -ne "\033]1337;SetColors=bg=000FC5\007"
#usr/local is X_86
export PATH="/usr/local/bin:$PATH"
export PATH="/usr/local/opt:$PATH"
fi
if [[ "$_ARCH" == "arm64" ]]; then
#usr/local is X_86
export PATH="/opt/homebrew/bin:$PATH"
export PATH="/opt/homebrew/opt:$PATH"
fi这样,我就可以在x86 shell中编译2.6.6 (我假设是2.7.2),在arm64 shell中分别编译3.0.1。
我的rvm列表如下所示:
ruby-2.4.6 [ x86_64 ]
ruby-2.4.9 [ x86_64 ]
* ruby-2.6.5 [ x86_64 ]
ruby-2.6.6 [ x86_64 ]
ruby-2.7.0 [ x86_64 ]
ruby-2.7.2 [ x86_64 ]
=> ruby-3.0.1 [ arm64 ]另外,我有时仍然会遇到让rails正确链接到mysql的问题。ruby / rails / mysql似乎都必须采用相同的架构。还在追查那辆车。
发布于 2021-04-25 10:21:14
我终于在m1芯片macbook pro上安装了老版本的ruby,包括2.6.6,步骤如下:
首先,我必须使用以下命令重新安装rbenv、ruby-build和readline:
brew reinstall rbenv ruby-build readline其次,使用CONFIGURE_OPTS破坏了我的OpenSSL构建。请改用RUBY_CONFIGURE_OPTS。我使用的是hombrew,并且必须使用以下标志:
RUBY_CONFIGURE_OPTS="--with-openssl-dir=`brew --prefix openssl` --with-readline-dir=`brew --prefix readline`"第三,设置以下内容,以允许make命令中的警告不会停止构建:
RUBY_CFLAGS="-Wno-error=implicit-function-declaration"第四,确保在通过rbenv安装时设置了arch标志:
arch -x86_84第五,确保您的自制路径设置正确:
export PATH="/opt/homebrew/bin:$PATH"
export PATH="/opt/homebrew/opt:$PATH"成功安装ruby 2.6.6的最后一个命令是:
export PATH="/opt/homebrew/bin:$PATH"
export PATH="/opt/homebrew/opt:$PATH"
RUBY_CFLAGS="-Wno-error=implicit-function-declaration" RUBY_CONFIGURE_OPTS="--with-openssl-dir=`brew --prefix openssl` --with-readline-dir=`brew --prefix readline`" sudo arch -x86_64 rbenv install --verbose 2.6.6我使用sudo将mkdir权限授予脚本。
https://stackoverflow.com/questions/66645381
复制相似问题