0
votes

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

1
I've updated my question, but short answer - I'm using the template language Liquid to try use the library code: {% file_exists {{ fb_img_default }} %} - james
According to the page you linked, you don't have to do anything. "In your site source root, make a _plugins directory. Place your plugins here. Any file ending in *.rb inside this directory will be loaded before Jekyll generates your site." If your thing is not recognized in liquid templates, must be it's not a proper plugin (doesn't register itself correcly or something) - Sergio Tulentsev
Thanks @SergioTulentsev your idea about "According to the page you linked, you don't have to do anything" lead me in the right direction. Thank you :) - james

1 Answers

1
votes

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."