I'm having trouble installing Ruby and using homebrew on my M1 Mac.
I'm trying to install Ruby so that I can launch a website through Jekyll. I'm following the installation guide on the Jekyll website and ran the command ruby-install ruby 3.1.3
, but I'm getting an error message:
kamil@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!
I've tried many different solutions, but still getting the error message: Error: Cannot install in Homebrew on ARM processor in Intel default prefix (/usr/local)!
I've tried installing Homebrew on a different prefix, changing the default path, and using the arch -x86_64 brew install
command prefix, but none have worked.
Edit 1: Ran brew doctor
command, received the following warnings:
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 told me that:
To link the unlinked kegs in your Homebrew Cellar, run brew link node and brew link python@3.11. This will ensure that any formulae that depend on these kegs can access them properly.
I did it, and then:
kamil@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
kamil@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.
kamil@Kamils-Air ~ % rm '/usr/local/bin/node'
rm: /usr/local/bin/node: No such file or directory
kamil@Kamils-Air ~ % rm '/usr/local/bin/node
quote>
kamil@Kamils-Air ~ % rm '/usr/local/bin/node'
rm: /usr/local/bin/node: No such file or directory
I then tried 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.
I re-installed homebrew. Brew doctor did not indicate any warnings.
After installing ruby again, I ran the same command again and received the same error, and after running brew doctor
now, I got the same errors stated previously. I'm back to square one.
rbenv worked for me to install Ruby on M1 Mac:
brew install rbenv ruby-build
rbenv init
rbenv install 3.1.3