Search code examples
rubyjekyllbundler

Loading local libaries in jekyll (Liquid template library + ruby bundler)


My question is: How do I load local libaries in ruby and with bundler + jekyll?

I'm trying to load a bunch of local libraries. For example: project_root/_plugins/fileexists.rb

I've tried following https://jekyllrb.com/docs/plugins/ but that solution assumes you have a library that can be installed from the global Gem repository.

The plugins I'm trying to load are here https://github.com/nicnocquee/appolo/tree/master/_plugins

The error I'm getting when doing 'bundle exec jekyll serve':

Dependency Error: Yikes! It looks like you don't have fileexists or one of its dependencies installed. In order to use Jekyll as currently configured, you'll need to install this gem. The full error message from Ruby is: 'cannot load such file -- fileexists' If you run into trouble, you can find helpful resources at https://jekyllrb.com/help/!

To complicate the matter, I'm using the Liquid template library. (Though this shouldnt be a Liquid problem because I get the error when doing bundle exec jekyll serve. I think..)

{% file_exists {{ fb_img_default }} %}

The code for the template is here: https://github.com/nicnocquee/appolo/blob/master/_includes/head.html#L25

My _config.yml file for jekyll: https://pastebin.com/SphuLcVt The Gemfile: https://pastebin.com/3ptcBx5m

Thanks in advance for ideas about how to proceed!

Library version

bundle --version Bundler version 1.16.0

ruby --version ruby 2.3.3p222 (2016-11-21) [x86_64-linux-gnu]

gem --version 2.5.2


Solution

  • Ok, I figured this out.

    I removed:

    plugins:
     - fileexists
    

    From _config.yml

    And removed:

    gem 'fileexists', :path => '/home/test/xxx.github.io/_plugins/fileexists'
    gem 'github-pages'
    

    from Gemfile

    The clue that github-pages packet was the problem: https://github.com/jekyll/jekyll/issues/5990#issuecomment-308231021

    Short answer: "No custom plugins will load when using github-pages because of their whitelist."