Install Ruby 3 and Jekyll on Apple Silicon
If you would like to start your journey with Jekyll but need the latest version of Ruby to run your gems, you will need to install Ruby in a slightly tricky way. Unfortunately, MacOS, by default, has an old and unsupported version of Ruby (2.6.6). To update it, you will need to take a few steps (a simple installation of Ruby is not sufficient).
Prerequirements
Before we start we need to install few tools
- Xcode - Apple IDE
xcode-select --install
- Homebrew - package manager for MacOS
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
rbenv
is a tool that helps managing multiple Ruby versions, it allows for quick switch between versions. ruby-build simplifies installation of any Ruby version.brew install rbenv ruby-build
Initialize rbenv
First we need to initialize rbenv
rbenv init
And configure autorun in your shell
a. If you are using zsh
echo 'eval "$(rbenv init - zsh)"' >> ~/.zshrc
b. For bash users
echo 'eval "$(rbenv init - bash)"' >> ~/.bash_profile
At this moment you can verify if everything works as expected by running rbenv-doctor
curl -fsSL https://github.com/rbenv/rbenv-installer/raw/main/bin/rbenv-doctor | bash
Install Ruby
You can check what versions of Ruby are available by running
rbenv install -l
Install selected version of Ruby (3.2.2 is lates one for me)
rbenv install 3.2.2
When instalation is completed you can set version that will be used globally
rbenv global 3.2.2
To verify installation check Ruby version
ruby -v
Install Jekyll
Now when we have installed Ruby we can proceed with Jekyll installation.
Best option to install Jekyll is to do user-install and install jekyll in user directory.
gem install --user-install bundler jekyll
When installation finish you can try to use it on jekyll projects (try some from jekyll themes).
To start jekyll run command
bundle exec jekyll serve
At first You can get errors related to required gems not found, to fix that just install missing gems using command
gem install GEM_NAME
or use bundler
bundle init
Done!