Impossible to use Jekyll on Mac M1

Hey,

I’m trying to set up Jekyll on my new Mac with the M1 chip. To install Homebrew I had to launch this command arch -x86_64 /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)". This worked, but the next to add the brew ruby path didn’t. I do not get any error for this one, but when I launch which ruby I still have /usr/bin/ruby and not /usr/local/opt/ruby/bin/ruby.

Does someone have a solution?

Thanks!

Do

echo $PATH

Your custom Homebrew installed ruby needs to be in there and before the system Ruby.

If Homebrew hasn’t added to your path then you have to do it yourself in .zshrc or .bashrc or similar.

export PATH="/usr/local/opt/ruby/bin:$PATH"

Then launch a new terminal.

And show all available Rubies

which -a ruby

Hey, thanks for your answer.

So I did echo $PATH and got this:

/usr/local/opt/ruby/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin

When I run which -a ruby I still have /usr/bin/ruby, but I opened .zshrc and export PATH="/usr/local/opt/ruby/bin:$PATH" is there…

OK. Good that you have /usr/local/opt/ruby/bin in PATH.

Is Ruby actually in there?

Run this:

ls /usr/local/opt/ruby/bin/
# bundle  bundler erb     gem     irb     racc    racc2y  rake    rdoc    ri      ruby    y2racc

And run the Ruby.

/usr/local/opt/ruby/bin/ruby --version
# ruby 2.7.2p137 (2020-10-01 revision 5445e04352) [x86_64-darwin19]

Make sure you are using ZSH if you edited .zshrc - or use Bash if you edit .bashrc

You can also try

brew uninstall ruby
brew install ruby@2.7

Hey,

When I run the first command I have

/usr/local/opt/ruby/bin/: No such file or directory

And when I try to uninstall it I have this error:

Error: No available formula or cask with the name "ruby".

Maybe it can come from the fact that Ruby is pre installed on Mac?

I also tried to install the version 2.7, it worked but when I run ruby -v I still have ruby 2.6.3p62. How can I switch on the new version?

Hi @JulSeb42. Are you launching your terminal app in Rosetta mode or without any modifications? It makes a difference because Homebrew installs packages in different locations depending on whether or not Rosetta is enabled. It can get complicated, so I wrote a script that will automatically detect the right settings and install Ruby in the correct location, as well as set the correct PATH in your shell file.
It will also install the Jekyll gem for you.

Hey @monfresh, I could fix the problem by following this tutorial Installing Jekyll on Apple Silicon – keng.blog
Also now I run this command to compile jekyll:

arch -x86_64 bundle exec jekyll serve

Great. I’m glad you got it to work. If you do it this way, you’ll have to remember to type arch -x86_64 before all commands. An easier way is to create a duplicate of the Terminal app that uses the Intel processor emulator, called Rosetta. That way, you can open the appropriate Terminal using the correct processor depending on what you’re working on.

  1. Quit all your Terminal applications
  2. From the Finder, go to Applications → Utilities
  3. Select the Terminal app
  4. Press command-D. This should prompt you for your Touch ID (or password) to duplicate Terminal
  5. Select one of the two Terminal apps and press command-i. This should open up an Info window
  6. Click on the arrow next to Name and Extension and rename it to “Terminal Rosetta”
  7. Under the “General” section at the top, click on the “Open using Rosetta” checkbox
  8. Close the Info window
  9. Launch the Terminal Rosetta app
  10. Try bundle exec jekyll serve

How about an alias?

alias bundle="arch -x86_64 bundle"
# use as
bundle exec jekyll serve


# OR
alias jekyll="arch -x86_64 bundle exec jekyll"
jekyll serve

I don’t recommend it because it will lead to confusion down the road. It’s best to keep the two environments separate, which is why Homebrew has 2 different installation locations depending on which architecture you’re using.