Jekyll - getting an error when I have Paginate in my project - ruby

I'm running 3.1.2 on Windows
When I try to add 'Paginate' to my project, I'm getting an error in cmd
Deprecation: You appear to have pagination turned on, but you haven't
included the jekyll-paginate gem. Ensure you have gems:
[jekyll-paginate] in your configuration file.
I have jekyll-paginate (1.1.0) and paginate (4.0.0) installed and it's still giving this error.
Here is my _config.yml file:
paginate: 4
paginate_path: '/blog/page:num/'
And my index.html page
{% for post in paginator.posts limit: 4 %}
What should I check, to resolve this?

Jekyll guys have removed Paginate plugin from version 3.x as it did not play nicely with more core features. You can still enable it using any of these three options
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.
In your _config.yml file, add a new array with the key gems and the values of the gem names of the plugins you’d like to use. An example:
gems: [jekyll-coffeescript, jekyll-watch, jekyll-assets]
# This will require each of these gems automatically.
Then install your plugins using gem install jekyll-paginate-category jekyll-watch jekyll-assets
Add the relevant plugins to a Bundler group in your Gemfile. An example:
group :jekyll_plugins do
gem "my-jekyll-plugin"
gem "jekyll-paginate-category"
end
Now you need to install all plugins from your Bundler group by running single command bundle install
You can find more information on jekyll plugins page

Maybe the issue is that you have 2 versions of Jekyll, one installed through "apt" and another thru "gem". Try to remove the one installed with "apt" (or whatever command you're using) and update the other version using the bundler "bundle update". I have this error I've corrected by removing Jekyll I installed by "apt" command.
** Notes: I'm using Ubuntu.

Make sure you have the following in your _config.yml file.
gems: [jekyll-paginate]

Related

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

Can't install gem using Bundler's Rakefile install task when developing a custom gem

I'm developing a couple of private gems and I think I don't understand correctly the PATH/GEM_PATH and/or Bundler/RVM installation flow, would love if someone could chip in.
I have a repository with two gems (A & B for simplicity sake). I've developed the gems using the scaffolding + following the guidelines provided by this bundler tutorial.
Thanks to the Bundler project I have a few Rakefile tasks like rake build, rake install, rake install:local and rake release. Because of the private nature of these gems I can't release them to RubyGems (and we haven't looked into hosting our rubygems).
My machines are using RVM to manage ruby versions and Bundler version 1.15.1
What I want to do: Assuming a new machine/developer trying out the project, ideally we would cd into each of the subfolders (currently 2, gem A and gem B), run rake install and after that we should have the gems available system wide for the current user.
What is happening: The gems are built and work properly, but they are only available inside the subfolder of each gem i.e. gem A is only available inside the subfolder A and gem B is only available inside subfolder B.
What I've tried: So, after rake build/install/install:local a new .gem file is generated under pkg. I've tried to manually install the "compiled" file using gem install pkg/A.gem, gem install --local pkg/A.gem and gem install --local --user-install pkg/A.gem without success. (there are plenty of SO questions/answers about this)
I believe this has something to do with the PATH variables, but like I said before I don't fully understand the way they are managed. I get the following results from these commands:
# Our gem
> gem which A
/home/ubuntu/.rvm/gems/ruby-2.4.0/gems/A-0.1.8/lib/A.rb
# Pry, available globally
> gem which pry
/home/ubuntu/.rvm/gems/ruby-2.4.0/gems/pry-0.11.1/lib/pry.rb
I've been lost and frustrated for far too long now, any help is appreciated. Also open to hear suggestions of better private gem installation flows :)
Yes, it has something to do with your PATH variables. Your installation seems to be good.
I advise you to first affirm your gems installation path with:
echo $GEM_HOME
The double check your PATH to ensure its present and also confirm that the GEM home is also where the gem got installed into from the rake install
echo $PATH
If not, put it in your path and you should be fine with something like this:
echo PATH=$PATH:$GEM_HOME >> ~/.bashrc
source ~/.bashrc
Build your gem as per that guide you linked. You should end up with a gem file. Distribute this as you see fit (I use rsync/crontab to download newer gem versions but anything goes). User can install the gem as follows:
gem install --user-install /path/to/your/file.gem
This will install the gem in the user's ~/.gem/ruby/<version>/gems/<your-gem-name> directory.
Tried it with an empty gem (foodie, as in that example guide) and it works fine. But if you don't specify the --user-install parameter it will try to install in the system ruby dir (/usr/lib/ruby/gems...)

GitHub Pages not building

I'm trying to publish an article to my blog on GitHub pages after a few months of absence, and am getting the following error:
Gem::InstallError: public_suffix requires Ruby version >= 2.0.
Installing sass 3.4.20
An error occurred while installing public_suffix (1.5.2), and Bundler cannot
continue.
Make sure that gem install public_suffix -v '1.5.2' succeeds before bundling.
However according to GitHub the Ruby version on GH pages is already > 2.0. Is there some programmatic change that I need to make in my blog's codebase to get this up and running?
This is the corresponding Gemfile:
source 'https://rubygems.org'
# A simple Ruby Gem to bootstrap dependencies for setting up and
# maintaining a local Jekyll environment in sync with GitHub Pages
# https://github.com/github/pages-gem
gem 'github-pages'
Try deleting your gemfile.lock and pull down the last working gemfile.lock file from your GitHub pages repo. (or just checkout the file from an earlier, working commit)
Most of the weird errors stem from the errors with the Gemfile.lock file, which is used to keep track of the versions of each Ruby Gem. Sometimes when running bundle update gems are attempted to be upgraded, which may break compatibility with other gems, at least that's what has happened to me before. Often times running bundle update causes some gems to be downgraded. As a temporary workaround to just get Jekyll to build locally, just revert the file to an earlier version.

How to use gem from GitHub on Heroku?

I've forked the redis depository on github to https://github.com/lmirosevic/redis-rb
I added it to my Gemfile:
gem 'redis', :github => 'lmirosevic/redis-rb'
And I require the gem inside my Sinatra app:
require 'redis'
However it fails with the following error:
/app/vendor/ruby-2.0.0/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:45:in `require': cannot load such file -- redis (LoadError)
Any suggestions on what could be wrong? It seems like it should work!
EDIT
I should note that the bundler phase is fine. The problem seems to be in the require step.
Bundler gives me this output:
Using redis (3.0.4) from git://github.com/lmirosevic/redis-rb (at master)
I should also say that my directory structure is something like this. Not sure if this makes a difference.
/
.env
Gemfile
Gemfile.lock
Procfile
/lib
my_sinatra_app.rb
/config
...
You must have
require 'bundler/setup'
in your app or else you're not really using bundler: this is what ensures that the gem versions loaded are the ones in your gemfile and sets up load paths for anything not installed globally.
Calling Bunder.setup allows you to control what groups are used, but if just using the default group is fine then you don't need to do this.
If you aren't setting up bundler then your gemfile is used to install the required versions of the gems but then bundler is no longer used - your app will used whatever gems are installed, whether the versions match or not and you won't be able to use gems that aren't installed in the default gem load paths.

Manually adding a Ruby Gem

I am trying to install the mechanize gem that is supposed to work with 1.9 from here: http://github.com/kemiller/mechanize but I do not know how to add it manually.
I am using Windows, I could just copy the folder to the gems directory, but how do I initialize it?
I'm not sure I understand the problem. gem install mechanize doesn't work? It produces version 0.9.3 for me, which matches the gemspec of the library you linked to.
EDIT: you're on 1.9. I knew that. Disregard my hasty post, not familiar enough with Windows to offer any help on building the extensions.
I would use the bundler gem using the command gem install bundler. This will create a file called Gemfile in your project directory where you can put your dependencies for the specific project that you are working on. In the Gemfile, you will need to specify gem mechanize. If you want a specific version include ~> VERSION after. After, run the command bundle install. This will install the gem you want and use it in your project.

Resources