Installing Ruby and Jekyll on MacOS

 

Created on: 6/16/19
Last update: 6/16/19

Here is a short note of Jekyll installation based on the official documentation 1.

Installing the Latest Ruby

Ruby is preinstalled on MacOS and it is not recommended to upgrade or uninstall libraries coming with the system. Here is the solution to safely install and use the latest Ruby without touching the MacOS default Ruby.

Install package:

brew install ruby

Add to environment path:

echo 'export PATH="/usr/local/opt/ruby/bin:$PATH"' >> ~/.bash_profile

Open a new terminal window and verify:

$ which ruby
/usr/local/opt/ruby/bin/ruby
$ ruby -v
ruby 2.6.3p62 (2019-04-16 revision 67580) [x86_64-darwin18]

(Optional) For compilers to find ruby you may need to set:

export LDFLAGS="-L/usr/local/opt/ruby/lib"
export CPPFLAGS="-I/usr/local/opt/ruby/include"

(Optional) For pkg-config to find ruby you may need to set:

export PKG_CONFIG_PATH="/usr/local/opt/ruby/lib/pkgconfig"

Installing Jekyll

Install Jekyll using gem:

gem install --user-install bundler jekyll

Verify:

$ gem list

*** LOCAL GEMS ***

addressable (2.6.0)
bundler (2.0.2)
colorator (1.1.0)
concurrent-ruby (1.1.5)
did_you_mean (1.3.0)
em-websocket (0.5.1)
eventmachine (1.2.7)
ffi (1.11.1)
forwardable-extended (2.6.0)
http_parser.rb (0.6.0)
i18n (0.9.5)
jekyll (3.8.5)
jekyll-sass-converter (1.5.2)
jekyll-watch (2.2.1)
kramdown (1.17.0)
liquid (4.0.3)
listen (3.1.5)
mercenary (0.3.6)
minitest (5.11.3)
net-telnet (0.2.0)
pathutil (0.16.2)
power_assert (1.1.3)
public_suffix (3.1.0)
rake (12.3.2)
rb-fsevent (0.10.3)
rb-inotify (0.10.0)
rouge (3.4.1)
ruby_dep (1.5.0)
safe_yaml (1.0.5)
sass (3.7.4)
sass-listen (4.0.0)
test-unit (3.2.9)
xmlrpc (0.3.0)

Hosting Jekyll Server

Navigate to the directory of Jekyll project and install required gems:

bundle install

Host Jekyll server on localhost:

bundle exec jekyll serve

References

Should Gemfile.lock be included in .gitignore?