Mac M1上的Ruby问题

np8igboo  于 2023-05-17  发布在  Ruby
关注(0)|答案(2)|浏览(502)

我在M1 Mac上安装Ruby和使用自制软件时遇到问题。
我正在尝试安装Ruby,以便可以通过Jekyll启动网站。我在Jekyll网站上跟踪installation guide并运行ruby-install ruby 3.1.3命令,但仍然得到相同的错误消息。
以下是完整的输出以供参考:

kamilszafraniak@Kamils-Air ~ % ruby-install ruby 3.1.3
>>> Installing ruby 3.1.3 into /Users/kamilszafraniak/.rubies/ruby-3.1.3 ...
>>> Installing dependencies for ruby 3.1.3 ...
Warning: openssl@1.1 1.1.1t is already installed and up-to-date.
To reinstall 1.1.1t, run:
  brew reinstall openssl@1.1
Warning: readline 8.2.1 is already installed and up-to-date.
To reinstall 8.2.1, run:
  brew reinstall readline
Warning: libyaml 0.2.5 is already installed and up-to-date.
To reinstall 0.2.5, run:
  brew reinstall libyaml
Error: Cannot install in Homebrew on ARM processor in Intel default prefix (/usr/local)!
Please create a new installation in /opt/homebrew using one of the
"Alternative Installs" from:
  https://docs.brew.sh/Installation
You can migrate your previously installed formula list with:
  brew bundle dump
Error: Cannot install in Homebrew on ARM processor in Intel default prefix (/usr/local)!
Please create a new installation in /opt/homebrew using one of the
"Alternative Installs" from:
  https://docs.brew.sh/Installation
You can migrate your previously installed formula list with:
  brew bundle dump
!!! Installing dependencies failed!

我已经尝试了StackOverflow的许多不同的解决方案,但我一直得到错误消息:Error: Cannot install in Homebrew on ARM processor in Intel default prefix (/usr/local)!我试过在不同的前缀上安装Homebrew,更改默认路径,并使用arch -x86_64 brew install命令前缀,但这些解决方案都不起作用。
我已经尝试了这么多不同的解决办法,不知下一步该怎么办才好。如果任何人对这个问题有经验,我将非常感谢任何帮助。如果您需要我的计算机上的任何其他信息或文件,请告诉我。
(This只是我正在努力解决的一个具体问题,我需要有人来帮助我一劳永逸地解决我设备上的这个自制软件问题。)
谢谢你!
编辑1:运行brew doctor命令,收到以下警告:

Warning: You have unlinked kegs in your Cellar.
Leaving kegs unlinked can lead to build-trouble and cause formulae that depend on
those kegs to fail to run properly once built. Run `brew link` on these:
  node
  python@3.11

Warning: Your Homebrew's prefix is not /opt/homebrew.

Many of Homebrew's bottles (binary packages) can only be used with the default prefix.
Consider uninstalling Homebrew and reinstalling into the default prefix.
It is expected behaviour that some formulae will fail to build in this unsupported configuration.
It is expected behaviour that Homebrew will be buggy and slow.
Do not create any issues about this on Homebrew's GitHub repositories.
Do not create any issues even if you think this message is unrelated.
Any opened issues will be immediately closed without response.
Do not ask for help from Homebrew or its maintainers on social media.
You may ask for help in Homebrew's discussions but are unlikely to receive a response.
Try to figure out the problem yourself and submit a fix as a pull request.
We will review it but may or may not accept it.

我向GPT 3.5发送了第一个警告,它告诉我:
要链接Homebrew Cellar中未链接的桶,请运行brew link node和brew link python@3.11。这将确保依赖于这些小桶的任何配方可以正确地访问它们。
我这样做了,并且:

kamilszafraniak@Kamils-Air ~ % brew link node
Linking /usr/local/Cellar/node/20.1.0... 
Error: Could not symlink bin/node
Target /usr/local/bin/node
already exists. You may want to remove it:
  rm '/usr/local/bin/node'

To force the link and overwrite all conflicting files:
  brew link --overwrite node

To list all files that would be deleted:
  brew link --overwrite --dry-run node
kamilszafraniak@Kamils-Air ~ % brew link --overwrite node
Linking /usr/local/Cellar/node/20.1.0... 
Error: Could not symlink include/node/common.gypi
/usr/local/include/node is not writable.
kamilszafraniak@Kamils-Air ~ % rm '/usr/local/bin/node'
rm: /usr/local/bin/node: No such file or directory
kamilszafraniak@Kamils-Air ~ % rm '/usr/local/bin/node 
quote> 
kamilszafraniak@Kamils-Air ~ % rm '/usr/local/bin/node'
rm: /usr/local/bin/node: No such file or directory

然后我尝试了sudo brew link --overwrite node

Error: Running Homebrew as root is extremely dangerous and no longer supported.
As Homebrew does not drop privileges on installation you would be giving all
build scripts full access to your system.

我刚刚重新安装了homebrew-并使用AI来帮助我处理所有事情,brew doctor现在没有显示任何警告,我即将再次安装ruby并确认没有问题。
现在,我再次运行相同的命令并收到相同的错误,现在运行brew doctor后,我得到了前面提到的相同错误。我又回到起点了。我想ruby必须安装一个特定的前缀?那是什么前缀
很抱歉给你留了这么长的口信

yc0p9oo0

yc0p9oo01#

看起来你在ARM处理器上使用Homebrew安装Ruby时遇到了问题。错误消息建议您在/opt/homebrew目录中创建一个新的Homebrew安装。
以下是成功安装Ruby的步骤:
1.卸载Homebrew(如果已经安装):

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/uninstall.sh)"

1.在/opt/homebrew目录下安装Homebrew:

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

1.更新你的shell配置文件(例如~/.bash_profile,~/.zshrc)以正确设置Homebrew路径:

eval "$(/opt/homebrew/bin/brew shellenv)"

1.关闭并重新打开终端以加载更新的配置。
1.使用Homebrew安装Ruby:

brew install ruby@3.1.3

1.验证安装:

ruby -v

它应该显示已安装的Ruby版本,确认安装成功。

moiiocjp

moiiocjp2#

rbenv帮助我在M1 Mac上安装Ruby:

  1. brew install rbenv ruby-build
  2. rbenv init
    1.关闭终端窗口并打开一个新窗口,以便您的更改生效。
  3. rbenv install 3.1.3
    https://github.com/rbenv/rbenv

相关问题