How to install jekyll on Apple M1 Macbook
If you have recently bought a M1 mac and have been doing blogging using Jekyll, then you must have experienced that installing Jekyll on the M1 architecture is not so straightforward. We will see how we can install Jekyll for M1 Mac.
In this post, we will see how we can install Jekyll on Apple’s M1 Macbook Pro, Air or Mac Mini.
Before I share with you the commands I followed to install the Jekyll locally, I must share with you my OS. I am using MacBook Air (M1, 2020) with macOS BigSur (11.6).
Requires Xcode installation
If you have recently purchased your Macbook, then you may not have installed Xcode yet. Xcode comes with a set of libraries required by other programs including for our installation of Jekyll.
xcode-select --install
Requires Homebrew
I use Homebrew to install third party packages on my Mac. It can be installed by simply:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
Install Rbenv
We need to install a Ruby version that is compatible with ARM processor.
brew install rbenv ruby-build
Install ARM based Ruby 3.0.0
rbenv install 3.0.0
rbenv global 3.0.0
ruby -v
rbenv rehash
Add the ruby and gems path to your shell configuration
Now, add rbenv to bash so that it loads every time you open a terminal
if you are using zsh
echo 'eval "$(rbenv init - zsh)"' >> ~/.zshrc
if you are using bash
echo 'eval "$(rbenv init - bash)"' >> ~/.bash_profile
If you are not sure which shell you are using, you can check that using the command:
echo $SHELL
Install Jekyll
Finally, we can proceed to install Jekyll and Bundler. We will be doing the local install (it does not require sudo
privileges).
gem install --user-install bundler jekyll
if you are using zsh
Replace 3.0.0
with your ruby version. You can check your ruby version by ruby -v
. If your ruby version is 2.7, then use 2.7.0
.
echo 'export PATH="/usr/local/opt/ruby/bin:/usr/local/lib/ruby/gems/3.0.0/bin:$PATH"' >> ~/.zshrc
if you are using bash
Replace 3.0.0
with your ruby version. You can check your ruby version by ruby -v
. If your ruby version is 2.7, then use 2.7.0
.
echo 'export PATH="/usr/local/opt/ruby/bin:/usr/local/lib/ruby/gems/3.0.0/bin:$PATH"' >> ~/.bash_profile
More updates
For M1 Mac, we may need to do a few extra steps — update bundler, add webrick, and rebuild everything.
bundle update --bundler
bundle add webrick
bundle install --redownload
Check installation
Now, we can run our example blog. Navigate to your blog and then run the following commands:
- If you have not done local install
gem install bundler jekyll
- If you don’t have a blog, then create one using
jekyll new my-awesome-site
cd my-awesome-site
You can run the blog locally using the command:
bundle exec jekyll serve
Hope it works in your case! Enjoy your amazing M1 Mac!!
Originally published at https://www.earthinversion.com on October 10, 2021.