Install Jekyll CMS on Ubuntu 18.10 in 3 steps THE RIGHT WAY

Jekyll meets Ubuntu
Image: Jekyll meets Ubuntu (License: CC-BY-SA Marcelo Canina)
Published:
Last modified:

Overview

Guide to install Jekyll on Ubuntu focusing in having the latest Jekyll version and without interfering with the native Ubuntu package manager (i.e.: apt1 / snap2).

For this we are going to use the Jekyll gem avoiding the usage of the distro packages.

The RubyGems software allows you to easily download, install, and use ruby software packages on your system. The software package is called a “gem” which contains a packaged Ruby application or library.

The steps to follow are:

  1. install the required system packages using Ubuntu’s apt tool
  2. configure paths/shell variables
  3. install Jekyll gem and Bundler

1. Install packages

We start installing the required dependencies to use Ruby Gems in our environment by install the following packages: sudo apt-get install ruby-full build-essential zlib1g-dev

This will provide:

  • ruby-full: “Ruby full installation (default version)”
  • build-essential: “This package contains an informational list of packages which are considered essential for building Debian packages.”
  • zlib1g-dev: “compression library - zlib is a library implementing the deflate compression method found in gzip and PKZIP.”

Now we need to install ruby-bundler to manage Ruby application dependencies.


$ sudo apt install ruby-bundler
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following additional packages will be installed:
  fonts-lato javascript-common libjs-jquery libruby2.5 rake ruby ruby-did-you-mean ruby-minitest ruby-molinillo ruby-net-http-persistent
  ruby-net-telnet ruby-power-assert ruby-test-unit ruby-thor ruby-xmlrpc ruby2.5 rubygems-integration
Suggested packages:
  apache2 | lighttpd | httpd ri ruby-dev bundler
The following NEW packages will be installed:
  fonts-lato javascript-common libjs-jquery libruby2.5 rake ruby ruby-bundler ruby-did-you-mean ruby-minitest ruby-molinillo
  ruby-net-http-persistent ruby-net-telnet ruby-power-assert ruby-test-unit ruby-thor ruby-xmlrpc ruby2.5 rubygems-integration
0 upgraded, 18 newly installed, 0 to remove and 0 not upgraded.
Need to get 6.514 kB of archives.
After this operation, 30,0 MB of additional disk space will be used.
Do you want to continue? [Y/n] Y
Get:1 http://uy.archive.ubuntu.com/ubuntu cosmic/main amd64 fonts-lato all 2.0-2 [2.698 kB]
Get:2 http://uy.archive.ubuntu.com/ubuntu cosmic/main amd64 javascript-common all 11 [6.066 B]
Get:3 http://uy.archive.ubuntu.com/ubuntu cosmic/main amd64 libjs-jquery all 3.2.1-1 [152 kB]
Get:4 http://uy.archive.ubuntu.com/ubuntu cosmic/main amd64 rubygems-integration all 1.11 [4.994 B]
Get:5 http://uy.archive.ubuntu.com/ubuntu cosmic-updates/main amd64 ruby2.5 amd64 2.5.1-5ubuntu4.1 [48,7 kB]
Get:6 http://uy.archive.ubuntu.com/ubuntu cosmic/main amd64 ruby amd64 1:2.5.1 [5.712 B]
Get:7 http://uy.archive.ubuntu.com/ubuntu cosmic/main amd64 rake all 12.3.1-3 [44,9 kB]
Get:8 http://uy.archive.ubuntu.com/ubuntu cosmic/main amd64 ruby-did-you-mean all 1.2.1-1 [9.828 B]
Get:9 http://uy.archive.ubuntu.com/ubuntu cosmic/main amd64 ruby-minitest all 5.11.3-1 [39,4 kB]
Get:10 http://uy.archive.ubuntu.com/ubuntu cosmic/main amd64 ruby-net-telnet all 0.1.1-2 [12,6 kB]
Get:11 http://uy.archive.ubuntu.com/ubuntu cosmic/main amd64 ruby-power-assert all 1.1.1-1 [11,0 kB]
Get:12 http://uy.archive.ubuntu.com/ubuntu cosmic/main amd64 ruby-test-unit all 3.2.8-1 [61,4 kB]
Get:13 http://uy.archive.ubuntu.com/ubuntu cosmic/main amd64 ruby-xmlrpc all 0.3.0-2 [23,8 kB]
Get:14 http://uy.archive.ubuntu.com/ubuntu cosmic-updates/main amd64 libruby2.5 amd64 2.5.1-5ubuntu4.1 [3.080 kB]
Get:15 http://uy.archive.ubuntu.com/ubuntu cosmic/universe amd64 ruby-molinillo all 0.6.4-1 [19,8 kB]
Get:16 http://uy.archive.ubuntu.com/ubuntu cosmic/universe amd64 ruby-net-http-persistent all 2.9.4-1 [15,9 kB]
Get:17 http://uy.archive.ubuntu.com/ubuntu cosmic/universe amd64 ruby-thor all 0.19.4-1 [43,9 kB]
Get:18 http://uy.archive.ubuntu.com/ubuntu cosmic/universe amd64 ruby-bundler all 1.16.1-3 [237 kB]
Fetched 6.514 kB in 3s (2.057 kB/s)    
Selecting previously unselected package fonts-lato.
(Reading database ... 174906 files and directories currently installed.)
Preparing to unpack .../00-fonts-lato_2.0-2_all.deb ...
Unpacking fonts-lato (2.0-2) ...
Selecting previously unselected package javascript-common.
Preparing to unpack .../01-javascript-common_11_all.deb ...
Unpacking javascript-common (11) ...
Selecting previously unselected package libjs-jquery.
Preparing to unpack .../02-libjs-jquery_3.2.1-1_all.deb ...
Unpacking libjs-jquery (3.2.1-1) ...
Selecting previously unselected package rubygems-integration.
Preparing to unpack .../03-rubygems-integration_1.11_all.deb ...
Unpacking rubygems-integration (1.11) ...
Selecting previously unselected package ruby2.5.
Preparing to unpack .../04-ruby2.5_2.5.1-5ubuntu4.1_amd64.deb ...
Unpacking ruby2.5 (2.5.1-5ubuntu4.1) ...
Selecting previously unselected package ruby.
Preparing to unpack .../05-ruby_1%3a2.5.1_amd64.deb ...
Unpacking ruby (1:2.5.1) ...
Selecting previously unselected package rake.
Preparing to unpack .../06-rake_12.3.1-3_all.deb ...
Unpacking rake (12.3.1-3) ...
Selecting previously unselected package ruby-did-you-mean.
Preparing to unpack .../07-ruby-did-you-mean_1.2.1-1_all.deb ...
Unpacking ruby-did-you-mean (1.2.1-1) ...
Selecting previously unselected package ruby-minitest.
Preparing to unpack .../08-ruby-minitest_5.11.3-1_all.deb ...
Unpacking ruby-minitest (5.11.3-1) ...
Selecting previously unselected package ruby-net-telnet.
Preparing to unpack .../09-ruby-net-telnet_0.1.1-2_all.deb ...
Unpacking ruby-net-telnet (0.1.1-2) ...
Selecting previously unselected package ruby-power-assert.
Preparing to unpack .../10-ruby-power-assert_1.1.1-1_all.deb ...
Unpacking ruby-power-assert (1.1.1-1) ...
Selecting previously unselected package ruby-test-unit.
Preparing to unpack .../11-ruby-test-unit_3.2.8-1_all.deb ...
Unpacking ruby-test-unit (3.2.8-1) ...
Selecting previously unselected package ruby-xmlrpc.
Preparing to unpack .../12-ruby-xmlrpc_0.3.0-2_all.deb ...
Unpacking ruby-xmlrpc (0.3.0-2) ...
Selecting previously unselected package libruby2.5:amd64.
Preparing to unpack .../13-libruby2.5_2.5.1-5ubuntu4.1_amd64.deb ...
Unpacking libruby2.5:amd64 (2.5.1-5ubuntu4.1) ...
Selecting previously unselected package ruby-molinillo.
Preparing to unpack .../14-ruby-molinillo_0.6.4-1_all.deb ...
Unpacking ruby-molinillo (0.6.4-1) ...
Selecting previously unselected package ruby-net-http-persistent.
Preparing to unpack .../15-ruby-net-http-persistent_2.9.4-1_all.deb ...
Unpacking ruby-net-http-persistent (2.9.4-1) ...
Selecting previously unselected package ruby-thor.
Preparing to unpack .../16-ruby-thor_0.19.4-1_all.deb ...
Unpacking ruby-thor (0.19.4-1) ...
Selecting previously unselected package ruby-bundler.
Preparing to unpack .../17-ruby-bundler_1.16.1-3_all.deb ...
Unpacking ruby-bundler (1.16.1-3) ...
Setting up libjs-jquery (3.2.1-1) ...
Setting up ruby-xmlrpc (0.3.0-2) ...
Setting up fonts-lato (2.0-2) ...
Setting up ruby-did-you-mean (1.2.1-1) ...
Processing triggers for libc-bin (2.28-0ubuntu1) ...
Setting up ruby-net-telnet (0.1.1-2) ...
Setting up rubygems-integration (1.11) ...
Processing triggers for man-db (2.8.4-2) ...
Setting up javascript-common (11) ...
Setting up ruby-minitest (5.11.3-1) ...
Processing triggers for fontconfig (2.13.0-5ubuntu3) ...
Setting up ruby-power-assert (1.1.1-1) ...
Setting up ruby-test-unit (3.2.8-1) ...
Setting up libruby2.5:amd64 (2.5.1-5ubuntu4.1) ...
Setting up ruby2.5 (2.5.1-5ubuntu4.1) ...
Setting up ruby (1:2.5.1) ...
Setting up ruby-thor (0.19.4-1) ...
Setting up ruby-net-http-persistent (2.9.4-1) ...
Setting up rake (12.3.1-3) ...
Setting up ruby-molinillo (0.6.4-1) ...
Setting up ruby-bundler (1.16.1-3) ...
Processing triggers for libc-bin (2.28-0ubuntu1) ...

2. Configure Ruby Gems

Now we have the RubyGems environment in our system, we can check its setup using gem environment:


$ gem environment
RubyGems Environment:
  - RUBYGEMS VERSION: 2.7.6
  - RUBY VERSION: 2.5.1 (2018-03-29 patchlevel 57) [x86_64-linux-gnu]
  - INSTALLATION DIRECTORY: /var/lib/gems/2.5.0
  - USER INSTALLATION DIRECTORY: /home/marcanuy/.gem/ruby/2.5.0
  - RUBY EXECUTABLE: /usr/bin/ruby2.5
  - EXECUTABLE DIRECTORY: /usr/local/bin
  - SPEC CACHE DIRECTORY: /home/marcanuy/.gem/specs
  - SYSTEM CONFIGURATION DIRECTORY: /etc
  - RUBYGEMS PLATFORMS:
    - ruby
    - x86_64-linux
  - GEM PATHS:
     - /var/lib/gems/2.5.0
     - /home/marcanuy/.gem/ruby/2.5.0
     - /usr/lib/x86_64-linux-gnu/rubygems-integration/2.5.0
     - /usr/share/rubygems-integration/2.5.0
     - /usr/share/rubygems-integration/all
  - GEM CONFIGURATION:
     - :update_sources => true
     - :verbose => true
     - :backtrace => false
     - :bulk_threshold => 1000
  - REMOTE SOURCES:
     - https://rubygems.org/
  - SHELL PATH:
     - /home/marcanuy/local/bin
     - /home/marcanuy/.local/bin
     - /usr/local/sbin
     - /usr/local/bin
     - /usr/sbin
     - /usr/bin
     - /sbin
     - /bin
     - /usr/games
     - /usr/local/games
     - /snap/bin

The problem is that as it can be seen with the GEM PATHS environment variable, our gems will be installed at a system wide location /var/lib/gems/2.5.0 using root user privileges.

To avoid this, we set up a gem installation directory for our user account.

In our ~/.bashrc or ~/.profile, we add the following environment variables:

# ...

########
# RUBY #
########
# Avoid installing Ruby Gems as the root user
# Install Ruby Gems to ~/gems
export GEM_HOME="$HOME/gems"
export PATH="$HOME/gems/bin:$PATH"

And load the new configuration: source ~/.bashrc or source ~/.profile depending on which you used.

To check everything works right: gem environment should display the new configuration:


$ gem environment
RubyGems Environment:
  - RUBYGEMS VERSION: 2.7.6
  - RUBY VERSION: 2.5.1 (2018-03-29 patchlevel 57) [x86_64-linux-gnu]
  - INSTALLATION DIRECTORY: /home/marcanuy/gems
  - USER INSTALLATION DIRECTORY: /home/marcanuy/.gem/ruby/2.5.0
  - RUBY EXECUTABLE: /usr/bin/ruby2.5
  - EXECUTABLE DIRECTORY: /home/marcanuy/gems/bin
  - SPEC CACHE DIRECTORY: /home/marcanuy/.gem/specs
  - SYSTEM CONFIGURATION DIRECTORY: /etc
  - RUBYGEMS PLATFORMS:
    - ruby
    - x86_64-linux
  - GEM PATHS:
     - /home/marcanuy/gems
     - /home/marcanuy/.gem/ruby/2.5.0
     - /var/lib/gems/2.5.0
     - /usr/lib/x86_64-linux-gnu/rubygems-integration/2.5.0
     - /usr/share/rubygems-integration/2.5.0
     - /usr/share/rubygems-integration/all
  - GEM CONFIGURATION:
     - :update_sources => true
     - :verbose => true
     - :backtrace => false
     - :bulk_threshold => 1000
  - REMOTE SOURCES:
     - https://rubygems.org/
  - SHELL PATH:
     - /home/marcanuy/gems/bin
     - /home/marcanuy/local/bin
     - /home/marcanuy/.local/bin
     - /home/marcanuy/local/bin
     - /home/marcanuy/.local/bin
     - /usr/local/sbin
     - /usr/local/bin
     - /usr/sbin
     - /usr/bin
     - /sbin
     - /bin
     - /usr/games
     - /usr/local/games
     - /snap/bin

3. Install Jekyll

Finally we use the Jekyll package from the RubyGems repository, that we are sure it will contain the latest Jekyll version available, in contrast with the Ubuntu packages repository which would probably be many versions behind.


$ gem search --details --exact jekyll
*** REMOTE GEMS ***

jekyll (3.8.5)
    Author: Tom Preston-Werner
    Homepage: https://github.com/jekyll/jekyll

    A simple, blog aware, static site generator.
$ apt show jekyll
Package: jekyll
Version: 3.1.6+dfsg-3
Priority: optional
Section: universe/ruby
Origin: Ubuntu
Maintainer: Ubuntu Developers ubuntu-devel-discuss@lists.ubuntu.com
Original-Maintainer: Debian Ruby Extras Maintainers pkg-ruby-extras-maintainers@lists.alioth.debian.org
Bugs: https://bugs.launchpad.net/ubuntu/+filebug
Installed-Size: 423 kB
Depends: ruby | ruby-interpreter, ruby-classifier-reborn, ruby-colorator, ruby-jekyll-coffeescript (>= 1.0.1-2~), ruby-jekyll-feed, ruby-jekyll-gist, ruby-jekyll-paginate, ruby-jekyll-sass-converter, ruby-jekyll-watch, ruby-kramdown, ruby-launchy-shim, ruby-liquid, ruby-mercenary, ruby-mime-types, ruby-pygments.rb, ruby-rdiscount, ruby-redcarpet, ruby-rouge, ruby-safe-yaml, ruby-toml (>= 0.1.2-2~), xdg-utils
Recommends: ruby-mysql, ruby-sequel, ruby-sequel-pg
Homepage: http://github.com/mojombo/jekyll
Ruby-Versions: all
Download-Size: 82,9 kB
APT-Sources: http://uy.archive.ubuntu.com/ubuntu cosmic/universe amd64 Packages
Description: Simple, blog aware, static site generator
 Jekyll is a simple, blog aware, static site generator. It takes a
 template directory (representing the raw form of a website), runs it
 through Textile or Markdown and Liquid converters, and spits out a
 complete, static website suitable for serving with Apache or your
 favorite web server.
 .
 This is also the engine behind GitHub Pages(http://pages.github.com),
 which you can use to host your project's page or blog right here from
 GitHub.

That shows us that, at the moment of writing this, gem version is: 3.8.5 while the apt version is: 3.1.6+dfsg-3.

We proceed to install the Jekyll gem and bundler to make it possible to work with different Jekyll instances at the same time gem install jekyll bundler


$ gem install jekyll bundler
Fetching: jekyll-3.8.5.gem (100%)
Successfully installed jekyll-3.8.5
Parsing documentation for jekyll-3.8.5
Installing ri documentation for jekyll-3.8.5
Done installing documentation for jekyll after 5 seconds
Fetching: bundler-2.0.1.gem (100%)
Successfully installed bundler-2.0.1
Parsing documentation for bundler-2.0.1
Installing ri documentation for bundler-2.0.1
Done installing documentation for bundler after 11 seconds
2 gems installed

Summary

This is the full list of the commands used:

sudo apt-get install ruby-full build-essential zlib1g-dev
sudo apt install ruby-bundler

# check gem env 
gem environment

# added to ~/.bashrc` or `~/.profile
export GEM_HOME="$HOME/gems"
export PATH="$HOME/gems/bin:$PATH"

# use above vars
source ~/.bashrc #or source ~/.profile

# check new environment
gem environment

# obtain Jekyll gem info
gem search --details --exact jekyll

# install Jekyll
gem install jekyll bundler

Conclusion

This is a pretty straightforward procedure to install any gem in Ubuntu, having installed the latest Jekyll available, minimizing the risks of interfering with the native package manager and reducing risks without using root privileges.

Now you have the latest Jekyll version available:


$ jekyll --version
jekyll 3.8.5

References


  1. apt: “Advanced Package Tool, or APT, is a free-software user interface that works with core libraries to handle the installation and removal of software on Debian, Ubuntu, and related Linux distributions.” https://en.wikipedia.org/wiki/APT_(Debian) ↩︎

  2. snap: “A universal app store for Linux” https://snapcraft.io/ ↩︎

Uruguay
Marcelo Canina
I'm Marcelo Canina, a developer from Uruguay. I build websites and web-based applications from the ground up and share what I learn here.
comments powered by Disqus


How to install the latest Jekyll version on Ubuntu minimizing risks.

Clutter-free software concepts.
Translations English Español

Except as otherwise noted, the content of this page is licensed under CC BY-NC-ND 4.0 . Terms and Policy.

Powered by SimpleIT Hugo Theme

·