1

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 still getting the same error message.

Here's the full output for reference:

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!

I've tried many different solutions from StackOverflow, but I keep 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 of these solutions have worked.

I'm at a loss for what to do next, as I've tried so many different solutions. If anyone has experience with this issue, I would greatly appreciate any help. Let me know if you need any additional information or files from my computer.

(This is just one specific issue I am struggling with, I need someone to help me fix this homebrew issue on my device once and for all.)

Thank you!

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.

I sent the first warning to GPT 3.5, and it 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 so and:

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

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 just now — and used AI to help me with everything and brew doctor now did not indicate any warnings, I'm about to install ruby again and confirm there are no issues.

Now, 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. I suppose ruby must be installed with a specific prefix? What prefix is that

I'm sorry for the long-winded message.

Kamil
  • 27
  • 5
  • 7
    If you've upgraded your machine and ported over your drive you may need to trash your local Homebrew install and start clean with the ARM version of same. – tadman May 12 '23 at 14:04
  • Have you tried `brew doctor`? – Chiperific May 13 '23 at 05:21
  • @tadman Does this mean I'll have to re-install everything I downloaded with Homebrew on my computer? I did use migration assistant twice, but both were with M1 chips. Could you provide me with steps for doing this? – Kamil May 13 '23 at 15:13
  • 1
    @Chiperific I ran brew doctor and got the following warnings (I'll put them in the edited post) – Kamil May 13 '23 at 15:17
  • 2
    You can't copy an old brew (from an Intel Mac) to a new Apple Silicon Mac. You can generate a list of installed packages on the old machine (if you still have it) and reinstall that list on the new machine. Use `brew leaves` to get a top-level list of the installed packages. – dawg May 13 '23 at 17:03

1 Answers1

0

rbenv worked for me to install Ruby on M1 Mac:

  1. brew install rbenv ruby-build
  2. rbenv init
  3. Close your Terminal window and open a new one so your changes take effect.
  4. rbenv install 3.1.3

https://github.com/rbenv/rbenv

B Seven
  • 44,484
  • 66
  • 240
  • 385