How to setup Jekyll with Apple M1
I've been workshopping an idea for another blog that I'd like to work on for the personal side of my life and my journey through Fatherhood. For this blog, I wanted to try out some new things, both on the blogging framework I use, as well as how I host and maintain the backing infrastructure. This short blog post will cover my experience with getting my hands dirty setting up Jekyll on my MacBook with an M1 chip.
For starters, Jekyll's website has the following for directions to bootstrap a new Jekyll blog:
1gem install bundler jekyll
2jekyll new my-awesome-site
So first things first, I ran those commands and was feeling pretty good after the first one. However when trying to create my Jekyll project, I ran into a scary OS stacktrace. Now, knowing a bit about M1 processors, I decided to do a bit of research on Ruby (the language Jekyll's written in) and M1 chips. From there I found Ruby did support M1 chips, but my particular installation of Ruby did not. So from there, I tried a quick re-install of Ruby with RVM with the following commands:
1curl -sSL https://get.rvm.io | bash -s stable --ruby
2source /Users/andrew/.rvm/scripts/rvm
3rvm install 3.0.0
At that point, I got rid of the scary OS messages, but my gem install was still running into issues with native modules. I know from experience that running xcode-select --install
will fix a lot of things related to programming and native modules on a MacBook, so I gave that a try. That led me to do a system update, which got me to the next step.
The next issue I had to deal with was a seamingly missing OpenSSL native module:
1In file included from binder.cpp:20:
2./project.h:119:10: fatal error: 'openssl/ssl.h' file not found
3#include <openssl/ssl.h>
4 ^~~~~~~~~~~~~~~
51 error generated.
6make: *** [binder.o] Error 1
7
8make failed, exit code 2
So being a MacBook guy, I gave Homebrew a try by running brew install openssl
. That did a thing, but when trying to install the gems again, I got the same error. After running brew info openssl
, I found that it had a few notes on exporting some environment variables to make OpenSSL available to compilers. So I added the following to my ~/.zshrc
:
1export PATH="/opt/homebrew/opt/openssl@3/bin:$PATH"
2export LDFLAGS="-L/opt/homebrew/opt/openssl@3/lib"
3export CPPFLAGS="-I/opt/homebrew/opt/openssl@3/include"
4export PKG_CONFIG_PATH="/opt/homebrew/opt/openssl@3/lib/pkgconfig"
Note: Your paths may be different, but they should also be shown in the output of brew info openssl
From here, the gem installation worked! And so did creating my new Jekyll project! My luck ran out however when I tried to run my Jekyll project for the first time. At that point I got the following error:
1cannot load such file -- webrick
After even more research, I found that Ruby 3.0 has some issues with my version of Jekyll (see this GitHub issue). Luckily, the solution is well documented in GitHub as well, which was to simply run the following:
1bundle add webrick
Once that was done, I was finally greeted with my first view of my future Jekyll blog!
I hope this helps anyone making the same journey learning Jekyll as me. Happy coding!