algolia / jekyll-algolia

Add fast and relevant search to your Jekyll site
https://community.algolia.com/jekyll-algolia/
MIT License
214 stars 35 forks source link

TypeError: no implicit conversion of nil into Hash after upgrading Gemfile #121

Closed nfrankel closed 5 years ago

nfrankel commented 5 years ago

I want to report a bug:

I've recently updated my Jekyll site Gemfile with the latest versions, and I've stumbled upon an issue with the plugin.

What is the current behavior?

bundle exec jekyll algolia --trace

bundler: failed to load command: jekyll (/Users/nico/.rbenv/versions/2.5.1/bin/jekyll)
TypeError: no implicit conversion of nil into Hash
  /Users/nico/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/jekyll-3.8.5/lib/jekyll/utils.rb:318:in `merge!'
  /Users/nico/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/jekyll-3.8.5/lib/jekyll/utils.rb:318:in `merge_values'
  /Users/nico/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/jekyll-3.8.5/lib/jekyll/utils.rb:50:in `deep_merge_hashes!'
  /Users/nico/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/jekyll-3.8.5/lib/jekyll/utils.rb:37:in `deep_merge_hashes'
  /Users/nico/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/jekyll-archives-2.2.1/lib/jekyll-archives.rb:27:in `initialize'
  /Users/nico/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/jekyll-3.8.5/lib/jekyll/site.rb:295:in `new'
  /Users/nico/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/jekyll-3.8.5/lib/jekyll/site.rb:295:in `block in instantiate_subclasses'
  /Users/nico/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/jekyll-3.8.5/lib/jekyll/site.rb:294:in `map'
  /Users/nico/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/jekyll-3.8.5/lib/jekyll/site.rb:294:in `instantiate_subclasses'
  /Users/nico/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/jekyll-3.8.5/lib/jekyll/site.rb:117:in `setup'
  /Users/nico/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/jekyll-3.8.5/lib/jekyll/site.rb:32:in `initialize'
  /Users/nico/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/jekyll-algolia-1.4.11/lib/jekyll-algolia.rb:36:in `new'
  /Users/nico/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/jekyll-algolia-1.4.11/lib/jekyll-algolia.rb:36:in `init'
  /Users/nico/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/jekyll-algolia-1.4.11/lib/jekyll/commands/algolia.rb:31:in `block (2 levels) in init_with_program'
  /Users/nico/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/mercenary-0.3.6/lib/mercenary/command.rb:220:in `block in execute'
  /Users/nico/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/mercenary-0.3.6/lib/mercenary/command.rb:220:in `each'
  /Users/nico/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/mercenary-0.3.6/lib/mercenary/command.rb:220:in `execute'
  /Users/nico/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/mercenary-0.3.6/lib/mercenary/program.rb:42:in `go'
  /Users/nico/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/mercenary-0.3.6/lib/mercenary.rb:19:in `program'
  /Users/nico/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/jekyll-3.8.5/exe/jekyll:15:in `<top (required)>'
  /Users/nico/.rbenv/versions/2.5.1/bin/jekyll:23:in `load'
  /Users/nico/.rbenv/versions/2.5.1/bin/jekyll:23:in `<top (required)>'

What is your expected behavior?

Algolia runs fine, as before.

Git repository to reproduce the issue:

git@gitlab.com:nfrankel/nfrankel.gitlab.io.git

You should already have access to it

Ruby version used:

2.5.1

Jekyll version used:

jekyll 3.8.5

mkiser commented 5 years ago

Having the same issue here.

rakow commented 5 years ago

Downgrading jekyll-archives to version 2.1.1 fixes this problem. Maybe it is not an issue with the algolia plugin itself.

borisschapira commented 5 years ago

Same issue here. It looks like the error comes from https://github.com/algolia/jekyll-algolia/blob/develop/lib/jekyll/algolia/configurator.rb#L258. If "nil" is replaced by "{}", this error disappears. Unfortunately, in my case, another takes its place.

ashmaroli commented 5 years ago

If anyone here is interested in submitting a patch, IMO, the best-practice solution is to delete the key rather than resetting..

--- a/lib/jekyll/algolia/configurator.rb
+++ b/lib/jekyll/algolia/configurator.rb
@@ -256,10 +256,10 @@ module Jekyll
       def self.disable_other_plugins(config)
         # Disable archive pages from jekyll-archives
-        config['jekyll-archives'] = nil
+        config.delete('jekyll-archives')

         # Disable pagination from jekyll-paginate
-        config['paginate'] = nil
+        config.delete('paginate')

         # Disable pagination for jekyll-paginate-v2
         config['pagination'] = {} unless config['pagination'].is_a?(Hash)
@@ -269,8 +269,8 @@ module Jekyll
         config['autopages']['enabled'] = false

         # Disable tags from jekyll-tagging
-        config['tag_page_dir'] = nil
-        config['tag_page_layout'] = nil
+        config.delete('tag_page_dir')
+        config.delete('tag_page_layout')

         config
       end
nhoizey commented 5 years ago

Any news on this?

I can't index my site anymore either… 😥

redox commented 5 years ago

@pixelastic any chance you want to help?

nhoizey commented 5 years ago

I must say @pixelastic has always been really helpful! 😅

Is there anything I can do (more detailed execution traces maybe) to help dig into this issue?

ashmaroli commented 5 years ago

Guys, you can always point your Gemfile to a working branch. For example, to point to the PR that hopefully resolves this issue:

gem 'jekyll-algolia', github: 'algolia/jekyll-algolia', ref: 'refs/pull/126/head'
nhoizey commented 5 years ago

@ashmaroli OMG, it works indeed, sorry I didn't check before! 👍