Search code examples
rubyjekyllgithub-pagesjekyll-theme

Bundler Issues - Unresolved Specs


I've just started using Jekyll with GitHub Pages and I've been running into some issues. I've been hoping to be able to use this theme, although it is quite outdated. I've cloned the repo onto my PC and ran bundle install to get things started.

Just to be clear, I don't have a web development background. I'm actually an Android developer hoping to create my own blog about Android dev (plus anything else that comes to mind). Therefore, I'm not totally clear on what a lot of these commands do, such as bundle install or why it's necessary to run it in this case.

With that in mind, I went ahead and tried to jekyll serveand was shown the following message:

WARN: Unresolved specs during Gem::Specification.reset:
      rouge (< 4, >= 1.7)
WARN: Clearing out unresolved specs.
Please report a bug if this causes problems.
/home/mike/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/bundler-1.16.1/lib/bundler/runtime.rb:313:in `check_for_activated_spec!': You have already activated public_suffix 3.0.2, but your Gemfile requires public_suffix 2.0.5. Prepending `bundle exec` to your command may solve this. (Gem::LoadError)
    from /home/mike/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/bundler-1.16.1/lib/bundler/runtime.rb:31:in `block in setup'
    from /home/mike/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/bundler-1.16.1/lib/bundler/runtime.rb:26:in `map'
    from /home/mike/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/bundler-1.16.1/lib/bundler/runtime.rb:26:in `setup'
    from /home/mike/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/bundler-1.16.1/lib/bundler.rb:107:in `setup'
    from /home/mike/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/jekyll-3.7.3/lib/jekyll/plugin_manager.rb:50:in `require_from_bundler'
    from /home/mike/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/jekyll-3.7.3/exe/jekyll:11:in `<top (required)>'
    from /home/mike/.rbenv/versions/2.3.1/bin/jekyll:23:in `load'
    from /home/mike/.rbenv/versions/2.3.1/bin/jekyll:23:in `<main>

If I use bundle exec jekyll serve, I have my local server and can preview the theme just fine. However, why do I need to prepend 'bundle exec' in order to get things to work? Is there any concern of being shown these messages? And is there any way that I can correct them?

In addition, is there any way that I can make corrections so that all I need to do is jekyll serve, other than creating an alias? Any clarification and support on this is greatly appreciated!

If it helps at all, here is what the Gemfile looks like:

source "https://rubygems.org"
ruby RUBY_VERSION

# Hello! This is where you manage which Jekyll version is used to run.
# When you want to use a different version, change it below, save the
# file and run `bundle install`. Run Jekyll with `bundle exec`, like so:
#
#     bundle exec jekyll serve
#
# This will help ensure the proper Jekyll version is running.
# Happy Jekylling!
# gem "jekyll", "3.7.3"

# This is the default theme for new Jekyll sites. You may change this to anything you like.
# gem "minima"

# If you want to use GitHub Pages, remove the "gem "jekyll"" above and
# uncomment the line below. To upgrade, run `bundle update github-pages`.
gem "github-pages", group: :jekyll_plugins

# If you have any plugins, put them here!
# group :jekyll_plugins do
#   gem "jekyll-github-metadata", "~> 1.0"
# end

Solution

  • bundle exec assures that a ruby program that will be run inside it will use gems specified by Gemfile for the project you're in. It helps when you have multiple version of gems installed - chooses proper versions instead of the default/newest ones.

    In your case the error message says You have already activated public_suffix 3.0.2, but your Gemfile requires public_suffix 2.0.5. You have a newer version of a gem installed, but you need an older one. That's why jekyll serve cannot start without prepending with bundle exec.

    You can separate your gems using gemsets to avoid this issue. As you just need to use jekyll, I'd recommend though to use an alias though. It's easier and I think there is no need to do anything fancy here.