Install Jekyll 4 in macOS

Jekyll 4

This is a fairly straightforward procedure, I just want to capture it here for my own future use.

Install Ruby Version 2.4.0 or Better

Your macOS comes with Ruby pre-installed, but unfortunately it’s not recent enough to support Jekyll 4.

In macOS Mojave I have the following ruby version:

greys@mcfly:~ $ ruby -v
ruby 2.3.7p456 (2018-03-28 revision 63024) [universal.x86_64-darwin18]

Now that Jekyll 4 is the default, you simply install jekyll gem and it will get you the latest version of the 4.x branch.

But Jekyll gem install would fail with one of the dependencies like this:

greys@mcfly:~/proj/gleb.reys.net $ sudo gem install jekyll
Password:
Fetching: public_suffix-4.0.1.gem (100%)
Successfully installed public_suffix-4.0.1
Fetching: addressable-2.7.0.gem (100%)
Successfully installed addressable-2.7.0
Fetching: colorator-1.1.0.gem (100%)
Successfully installed colorator-1.1.0
Fetching: http_parser.rb-0.6.0.gem (100%)
Building native extensions.  This could take a while…
Successfully installed http_parser.rb-0.6.0
Fetching: eventmachine-1.2.7.gem (100%)
Building native extensions.  This could take a while…
Successfully installed eventmachine-1.2.7
Fetching: em-websocket-0.5.1.gem (100%)
Successfully installed em-websocket-0.5.1
Fetching: concurrent-ruby-1.1.5.gem (100%)
Successfully installed concurrent-ruby-1.1.5
Fetching: i18n-1.7.0.gem (100%)
HEADS UP! i18n 1.1 changed fallbacks to exclude default locale.
But that may break your application.
Please check your Rails app for 'config.i18n.fallbacks = true'. If you're using I18n (>= 1.1.0) and Rails (< 5.2.2), this should be
'config.i18n.fallbacks = [I18n.default_locale]'.
If not, fallbacks will be broken in your app by I18n 1.1.x.
For more info see:
https://github.com/svenfuchs/i18n/releases/tag/v1.1.0
Successfully installed i18n-1.7.0
Fetching: ffi-1.11.1.gem (100%)
Building native extensions.  This could take a while…
Successfully installed ffi-1.11.1
Fetching: sassc-2.2.1.gem (100%)
Building native extensions.  This could take a while…
Successfully installed sassc-2.2.1
Fetching: jekyll-sass-converter-2.0.1.gem (100%)
ERROR:  Error installing jekyll:
    jekyll-sass-converter requires Ruby version >= 2.4.0.

Which means that we need to upgrade Ruby, easily done with brew.

Simply install latest Ruby with Homebrew:

greys@mcfly:~/proj/gleb.reys.net $ brew install ruby
...
greys@mcfly:~/proj/gleb.reys.net $ ruby -v
ruby 2.6.5p114 (2019-10-01 revision 67812) [x86_64-darwin18]

Install Jekyll 4 gem

Now let’s try installing Jekyll 4 again:

greys@mcfly:~/proj/gleb.reys.net $ sudo gem install jekyll
 Password:
 Jekyll 4.0 comes with some major changes, notably:
 Our link tag now comes with the relative_url filter incorporated into it.
 You should no longer prepend {{ site.baseurl }} to {% link foo.md %}
 For further details: https://github.com/jekyll/jekyll/pull/6727
 Our post_url tag now comes with the relative_url filter incorporated into it.
 You shouldn't prepend {{ site.baseurl }} to {% post_url 2019-03-27-hello %}
 For further details: https://github.com/jekyll/jekyll/pull/7589
 Support for deprecated configuration options has been removed. We will no longer
 output a warning and gracefully assign their values to the newer counterparts 
     internally.
 Successfully installed jekyll-4.0.0
 Parsing documentation for jekyll-4.0.0
 Done installing documentation for jekyll after 0 seconds
 1 gem installed

That’s it – Jekyll is ready for developing static websites!

See Also