gpt4 book ai didi

ruby - 在 Mac M1 上使用 ruby​​-install 安装 ruby​​ 会导致错误

转载 作者:行者123 更新时间:2023-12-04 12:56:20 29 4
gpt4 key购买 nike

在mac M1上使用ruby-install安装ruby 2.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));

最佳答案

我已经能够将 x86_64 代码和 3.0.1 安装为 arm64 代码。我使用 rvm 但这应该适用于其他事情。

  • 我使用 iTerm2 并制作了 2 个副本。一个我使用 Get Info 将一个应用程序更改为使用 Rosetta。我什至在某处找到了 x86 应用程序的蓝色图标。

  • enter image description here
  • 我有 2 个版本的 Homebrew。一个在/opt/homebrew/bin/brew 中,另一个在/usr/local/bin/brew 中。
  • 我的 .zshrc 配置文件中有 2 组导出。我使用架构来为 shell 选择正确的架构。
  • 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 ]
    PS有时我仍然无法让rails正确链接到mysql。 ruby/rails/mysql 似乎都必须是相同的架构。还在追那个。

    关于ruby - 在 Mac M1 上使用 ruby​​-install 安装 ruby​​ 会导致错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66645381/

    29 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com