Saturday, November 5, 2016

Setting up Jekyll on Ubuntu 16.04

I recently set up Jekyll 3 on Ubuntu 16.04. The procedure is simple, works on Ubuntu 14.04, and perhaps also works on other versions of Ubuntu and other Linux distributions.


  1. Create a directory for your Jekyll site. For instance, let us call it "mysite".
    
           mkdir mysite
        
  2. Go to the site directory, and create a file called "Gemfile". The file defines Ruby applications dependencies. Since Jekyll is a Ruby application. This file defines the dependencies for Jekyll. It is quite simple, and the following shell command will create the file with sufficient content.
    
           cd mysite
           echo "source 'https://rubygems.org'" > Gemfile
           echo "gem 'execjs'" >> Gemfile
           echo "gem 'therubyracer'" >> Gemfile
           echo "gem 'github-pages', group: :jekyll_plugins" >> Gemfile
        
  3. Now install Ruby and other necessary packages.
    
           sudo apt-get install ruby ruby-dev ruby-bundler zlib1g-dev build-essential
        


  4. Finally, install Jekyll and its dependencies. On the site directory where Gemfile is, do the following,
    
           bundle install
        
  5. To build the Jekyll site, do the following on the site directory,
    
           bundle exec jekyll build
        
  6. You can serve the site by the following command,
    
           bundle exec jekyll serve --host=127.0.0.1 --port=4000
        

2 comments:

  1. I get an error performing step 4...

    Had a look at some places like here: http://stackoverflow.com/questions/34512560/cannot-install-therubyracer-in-ubuntu-14-04

    and here: http://stackoverflow.com/questions/35741536/trouble-installing-therubyracer-gem-due-to-compiler-issue-on-mac

    and here: http://stackoverflow.com/questions/34613215/gem-therubyracer-does-not-install-even-if-libv8-is-installed

    Still running into problems..

    ORIGINAL ERROR::

    Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

    current directory:
    /tmp/bundler20161112-7491-po5kaktherubyracer-0.12.2/gems/therubyracer-0.12.2/ext/v8
    /usr/bin/ruby2.3 -r ./siteconf20161112-7491-1elozhg.rb extconf.rb
    --with-v8-dir=/usr/local/opt/v8-315
    checking for main() in -lpthread... yes
    creating Makefile

    To see why this extension failed to compile, please check the mkmf.log which can be
    found here:

    /tmp/bundler20161112-7491-po5kaktherubyracer-0.12.2/extensions/x86_64-linux/2.3.0/therubyracer-0.12.2/mkmf.log

    current directory:
    /tmp/bundler20161112-7491-po5kaktherubyracer-0.12.2/gems/therubyracer-0.12.2/ext/v8
    make "DESTDIR=" clean

    current directory:
    /tmp/bundler20161112-7491-po5kaktherubyracer-0.12.2/gems/therubyracer-0.12.2/ext/v8
    make "DESTDIR="
    compiling accessor.cc
    g++: error: unrecognized command line option ‘-Wdate-time’
    g++: error: unrecognized command line option ‘-fstack-protector-strong’
    Makefile:207: recipe for target 'accessor.o' failed
    make: *** [accessor.o] Error 1

    make failed, exit code 2

    Gem files will remain installed in
    /tmp/bundler20161112-7491-po5kaktherubyracer-0.12.2/gems/therubyracer-0.12.2 for
    inspection.
    Results logged to
    /tmp/bundler20161112-7491-po5kaktherubyracer-0.12.2/extensions/x86_64-linux/2.3.0/therubyracer-0.12.2/gem_make.out

    An error occurred while installing therubyracer (0.12.2), and Bundler
    cannot continue.
    Make sure that `gem install therubyracer -v '0.12.2'` succeeds before bundling.


    Any help would be appreciated.
    Thanks in advance.

    ReplyDelete
    Replies
    1. Please do the following before you do "bundle install",

      sudo apt-get update
      sudo apt-get upgrade

      Delete