Update Jekyll and Ruby on macOS

So yeah, I always forget how to update my gems when I need to. I am not familiar with Ruby and only use it to power my blog. Two issues often occur:

  1. Gems get out of date and I just want to update to stay current and/or
  2. I get security alerts from GitHub and need to (have to) update to stay secure

The challenge? I never remember how to do it. So…to stop that I recently took a few notes 📝 while I fixed a GitHub security issue related to my blog. Below are some steps that I did while debugging and fixing issues. I plan to update this post over time as needed.

Similar to my write up on updating Git for macOS, this is meant to be notes and helpful information, not the gospel. Use discretion if/when using 😀.

TL;DR

  • bundle install installs what is currently in the Gemlock.file
    • If any errors happen when starting Jekyll, run the above command above first
  • Update specific gems with bundler (e.g. bundle update <GEMNAME>)
  • If you need to update Ruby run rvm install ruby --latest
  • Make sure dependencies align with the GitHub pages dependency list

Jekyll

Check Jekyll version

jekyll -v

Update Jekyll

bundle update jekyll

Run Jekyll

jekyll serve

Run Jekyll with drafts

jekyll serve --drafts

More command options are listed here


Ruby

Check Ruby version

ruby -v

Install the latest version of Ruby (using RVM)

rvm install ruby --latest

Install a specific version of Ruby (using RVM)

rvm install ruby-2.5.0

To see which version of Ruby is being used

which ruby

To view all rubies installed by RVM

rvm list rubies

To set the default version of Ruby

rvm --default use 2.5.0

Don’t forget to change 2.5.0 with the version number of the latest Ruby.

Ruby Bundler

Install the bundler

gem install bundler

Install a specific version of the bundler

gem install bundler:1.18.2

After updating Ruby you may need to update the bundler. To update:

bundle update --bundler

To install gems that have been previously installed based on the Gemfile.lock, run

bundle install

jekyll serve before bundle install

Note: Previously when Jekyll did not not work (see image above), I ran the bundle install command to address this.

To update all gems (Note: probably better to run bundle install as that uses the Gemfile.lock)

bundle update --all

To update a specific gem

bundle update nokogiri

Other Tools, Notes, and Miscellaneous:

Homebrew

First update the formulae and Homebrew

brew update

Find out what is out of date

brew outdated

Upgrade a specific formula

brew upgrade git

Ruby Gems

Gems are for Ruby. Gems are packages. Bundler installs ruby gems.

To update a specific gem. Note: seems better to use bundler for application specific updates

gem update <GEMNAME>

Additional Resources

Updated: