algolia / algoliasearch-jekyll

⚠ DEPRECATED Use jekyll-algolia instead.
https://community.algolia.com/jekyll-algolia/
MIT License
125 stars 12 forks source link

Unable to index, the task says it can find Jekyll #36

Closed nhoizey closed 6 years ago

nhoizey commented 8 years ago

When I run this command:

ALGOLIA_API_KEY='abcdefgh…' bundle exec jekyll algolia push --config _config.yml,_config_credentials.yml

I get the attached console messages: algolia.txt

The Youtube and Vimeo lines come from another plugin, when building the site.

The interesting part starts with these lines:

Indexing 1000 items
bundler: failed to load command: jekyll (/usr/local/bin/jekyll)
SystemStackError: stack level too deep
  /usr/local/lib/ruby/gems/2.3.0/gems/activesupport-5.0.0/lib/active_support/core_ext/object/json.rb:161:in `initialize_dup'
  /usr/local/lib/ruby/gems/2.3.0/gems/activesupport-5.0.0/lib/active_support/core_ext/object/json.rb:161:in `dup'
…

Then, almost 1000 lines later:

…
  /usr/local/lib/ruby/gems/2.3.0/gems/activesupport-5.0.0/lib/active_support/json/encoding.rb:33:in `encode'
  /usr/local/lib/ruby/gems/2.3.0/gems/activesupport-5.0.0/lib/active_support/json/encoding.rb:20:in `encode'
  /usr/local/lib/ruby/gems/2.3.0/gems/activesupport-5.0.0/lib/active_support/core_ext/object/json.rb:37:in `to_json'
  /usr/local/lib/ruby/gems/2.3.0/gems/algoliasearch-1.10.0/lib/algolia/index.rb:548:in `batch'
  /usr/local/lib/ruby/gems/2.3.0/gems/algoliasearch-1.10.0/lib/algolia/index.rb:64:in `add_objects'
  /usr/local/lib/ruby/gems/2.3.0/gems/algoliasearch-1.10.0/lib/algolia/index.rb:72:in `add_objects!'
  /usr/local/lib/ruby/gems/2.3.0/gems/algoliasearch-jekyll-0.8.0/lib/push.rb:170:in `block in batch_add_items'
  /usr/local/lib/ruby/gems/2.3.0/gems/algoliasearch-jekyll-0.8.0/lib/push.rb:167:in `each'
  /usr/local/lib/ruby/gems/2.3.0/gems/algoliasearch-jekyll-0.8.0/lib/push.rb:167:in `each_slice'
  /usr/local/lib/ruby/gems/2.3.0/gems/algoliasearch-jekyll-0.8.0/lib/push.rb:167:in `batch_add_items'
  /usr/local/lib/ruby/gems/2.3.0/gems/algoliasearch-jekyll-0.8.0/lib/push.rb:187:in `push'
  /usr/local/lib/ruby/gems/2.3.0/gems/algoliasearch-jekyll-0.8.0/lib/push.rb:96:in `write'
  /usr/local/lib/ruby/gems/2.3.0/gems/jekyll-3.1.6/lib/jekyll/site.rb:61:in `process'
  /usr/local/lib/ruby/gems/2.3.0/gems/algoliasearch-jekyll-0.8.0/lib/algoliasearch-jekyll.rb:33:in `block (3 levels) in init_with_program'
  /usr/local/lib/ruby/gems/2.3.0/gems/mercenary-0.3.6/lib/mercenary/command.rb:220:in `block in execute'
  /usr/local/lib/ruby/gems/2.3.0/gems/mercenary-0.3.6/lib/mercenary/command.rb:220:in `each'
  /usr/local/lib/ruby/gems/2.3.0/gems/mercenary-0.3.6/lib/mercenary/command.rb:220:in `execute'
  /usr/local/lib/ruby/gems/2.3.0/gems/mercenary-0.3.6/lib/mercenary/program.rb:42:in `go'
  /usr/local/lib/ruby/gems/2.3.0/gems/mercenary-0.3.6/lib/mercenary.rb:19:in `program'
  /usr/local/lib/ruby/gems/2.3.0/gems/jekyll-3.1.6/bin/jekyll:13:in `<top (required)>'
  /usr/local/bin/jekyll:22:in `load'
  /usr/local/bin/jekyll:22:in `<top (required)>'

I can run bundle exec jekyll build to build the site, so I don't understand why the algolia task is not able to run jekyll.

pixelastic commented 8 years ago

I never had this "stack level too deep" command before.

When you run bundle exec jekyll algolia push, the plugin actually override the internal .write method used by the build command, and runs a build. Instead of writing HTML files on disk, it pushes to an Algolia index. Here it seems that the jekyll the plugin tries to overwrite is not the same jekyll that was originally used...

Would you have a branch with the issue where I could have a look?

nhoizey commented 8 years ago

It is current master on https://github.com/nhoizey/nicolas-hoizey.com

Be careful, there are 150 Mb posts data… ;-)

nhoizey commented 7 years ago

Exactly one year later (nice coincidence), I still got the issue.

I'm now using Jekyll 3.5.1 and algoliasearch-jekyll 0.8.1

Full Gemfile.lock here.

redox commented 7 years ago

I'll let @pixelastic come back from vacation and handle that later this month :)

nhoizey commented 7 years ago

@redox no problem… ;-)

nhoizey commented 7 years ago

Still got the issue with Jekyll 3.6.2 and algoliasearch-jekyll 0.9.0

nhoizey commented 7 years ago

More than one year ago, I used this Rake task to index my Jekyll site: https://github.com/nhoizey/nicolas-hoizey.com/blob/jekyll2/Rakefile

If I try it now, it looks like it doesn't load the plugins to generate the site, which obviously leads to an error:

$ rake site:index
Configuration file: ./_config.yml
  Liquid Exception: Liquid syntax error (line 5): Unknown tag 'cloudinary' in […]/nicolas-hoizey.com/_posts/2001/01/01-phpmychat-copieusement-cite-en-exemple-dans-le-magazine-allemand-pc-online/2001-01-01-phpmychat-copieusement-cite-en-exemple-dans-le-magazine-allemand-pc-online.md
rake aborted!
Liquid::SyntaxError: Liquid syntax error (line 5): Unknown tag 'cloudinary'
/Users/nhoizey/.rvm/gems/ruby-2.4.0/gems/liquid-4.0.0/lib/liquid/document.rb:23:in `unknown_tag'
/Users/nhoizey/.rvm/gems/ruby-2.4.0/gems/liquid-4.0.0/lib/liquid/document.rb:11:in `block in parse'
/Users/nhoizey/.rvm/gems/ruby-2.4.0/gems/liquid-4.0.0/lib/liquid/block_body.rb:33:in `parse'
/Users/nhoizey/.rvm/gems/ruby-2.4.0/gems/liquid-4.0.0/lib/liquid/document.rb:10:in `parse'
/Users/nhoizey/.rvm/gems/ruby-2.4.0/gems/liquid-4.0.0/lib/liquid/document.rb:5:in `parse'
/Users/nhoizey/.rvm/gems/ruby-2.4.0/gems/liquid-4.0.0/lib/liquid/template.rb:132:in `parse'
/Users/nhoizey/.rvm/gems/ruby-2.4.0/gems/liquid-4.0.0/lib/liquid/template.rb:116:in `parse'
/Users/nhoizey/.rvm/gems/ruby-2.4.0/gems/jekyll-3.6.2/lib/jekyll/liquid_renderer/file.rb:13:in `block in parse'
/Users/nhoizey/.rvm/gems/ruby-2.4.0/gems/jekyll-3.6.2/lib/jekyll/liquid_renderer/file.rb:49:in `measure_time'
/Users/nhoizey/.rvm/gems/ruby-2.4.0/gems/jekyll-3.6.2/lib/jekyll/liquid_renderer/file.rb:12:in `parse'
/Users/nhoizey/.rvm/gems/ruby-2.4.0/gems/jekyll-3.6.2/lib/jekyll/renderer.rb:118:in `render_liquid'
/Users/nhoizey/.rvm/gems/ruby-2.4.0/gems/jekyll-3.6.2/lib/jekyll/renderer.rb:76:in `render_document'
/Users/nhoizey/.rvm/gems/ruby-2.4.0/gems/jekyll-3.6.2/lib/jekyll/renderer.rb:62:in `run'
/Users/nhoizey/.rvm/gems/ruby-2.4.0/gems/jekyll-3.6.2/lib/jekyll/site.rb:455:in `block (2 levels) in render_docs'
/Users/nhoizey/.rvm/gems/ruby-2.4.0/gems/jekyll-3.6.2/lib/jekyll/site.rb:453:in `each'
/Users/nhoizey/.rvm/gems/ruby-2.4.0/gems/jekyll-3.6.2/lib/jekyll/site.rb:453:in `block in render_docs'
/Users/nhoizey/.rvm/gems/ruby-2.4.0/gems/jekyll-3.6.2/lib/jekyll/site.rb:452:in `each_value'
/Users/nhoizey/.rvm/gems/ruby-2.4.0/gems/jekyll-3.6.2/lib/jekyll/site.rb:452:in `render_docs'
/Users/nhoizey/.rvm/gems/ruby-2.4.0/gems/jekyll-3.6.2/lib/jekyll/site.rb:192:in `render'
/Users/nhoizey/.rvm/gems/ruby-2.4.0/gems/jekyll-3.6.2/lib/jekyll/site.rb:73:in `process'
[…]/nicolas-hoizey.com/Rakefile:15:in `block (2 levels) in <top (required)>'
/Users/nhoizey/.rvm/gems/ruby-2.4.0/gems/rake-12.2.1/exe/rake:27:in `<top (required)>'
Tasks: TOP => site:index => site:generate
(See full trace by running task with --trace)

Any idea why it doesn't load the plugins?

nhoizey commented 7 years ago

It looks like Rake wants the plugins to be listed in _config.yml.

But I use bundler exec jekyll build to build the site, and the :jekyll_plugins group in my Gemfile is enough.

Any way to tell Rake to load plugins that are listed here?

It also means I have to install plugins with gem in addition to bundle

What a mess… :-/

DirtyF commented 7 years ago

@nhoizey FWIW this is how jekyll require the gems from Bundler: https://github.com/jekyll/jekyll/blob/73419cb374be1b8f45818a23116cf71db93549ce/lib/jekyll/plugin_manager.rb#L51

nhoizey commented 7 years ago

@DirtyF yes, I know, but it looks like Rake doesn't know it and requires me to add the plugins list in _config.yml. But even with that, I get an error:

bundle exec rake site:index
Configuration file: ./_config.yml
  Dependency Error: Yikes! It looks like you don't have jekyll-tagging 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 -- jekyll-tagging' If you run into trouble, you can find helpful resources at https://jekyllrb.com/help/!
rake aborted!
Jekyll::Errors::MissingDependencyException: jekyll-tagging
/Users/nhoizey/.rvm/gems/ruby-2.4.0/gems/jekyll-3.6.2/lib/jekyll/external.rb:68:in `rescue in block in require_with_graceful_fail'
/Users/nhoizey/.rvm/gems/ruby-2.4.0/gems/jekyll-3.6.2/lib/jekyll/external.rb:56:in `block in require_with_graceful_fail'
/Users/nhoizey/.rvm/gems/ruby-2.4.0/gems/jekyll-3.6.2/lib/jekyll/external.rb:55:in `each'
/Users/nhoizey/.rvm/gems/ruby-2.4.0/gems/jekyll-3.6.2/lib/jekyll/external.rb:55:in `require_with_graceful_fail'
/Users/nhoizey/.rvm/gems/ruby-2.4.0/gems/jekyll-3.6.2/lib/jekyll/plugin_manager.rb:30:in `require_gems'
/Users/nhoizey/.rvm/gems/ruby-2.4.0/gems/jekyll-3.6.2/lib/jekyll/plugin_manager.rb:22:in `conscientious_require'
/Users/nhoizey/.rvm/gems/ruby-2.4.0/gems/jekyll-3.6.2/lib/jekyll/site.rb:113:in `setup'
/Users/nhoizey/.rvm/gems/ruby-2.4.0/gems/jekyll-3.6.2/lib/jekyll/site.rb:34:in `initialize'
/Users/nhoizey/Dropbox/Personnel/Devs/nicolas-hoizey.com/Rakefile:11:in `new'
/Users/nhoizey/Dropbox/Personnel/Devs/nicolas-hoizey.com/Rakefile:11:in `block in <top (required)>'
/Users/nhoizey/Dropbox/Personnel/Devs/nicolas-hoizey.com/Rakefile:7:in `<top (required)>'
/Users/nhoizey/.rvm/gems/ruby-2.4.0/gems/rake-12.2.1/exe/rake:27:in `<top (required)>'
/Users/nhoizey/.rvm/gems/ruby-2.4.0@global/gems/bundler-1.15.4/lib/bundler/cli/exec.rb:74:in `load'
/Users/nhoizey/.rvm/gems/ruby-2.4.0@global/gems/bundler-1.15.4/lib/bundler/cli/exec.rb:74:in `kernel_load'
/Users/nhoizey/.rvm/gems/ruby-2.4.0@global/gems/bundler-1.15.4/lib/bundler/cli/exec.rb:27:in `run'
/Users/nhoizey/.rvm/gems/ruby-2.4.0@global/gems/bundler-1.15.4/lib/bundler/cli.rb:362:in `exec'
/Users/nhoizey/.rvm/gems/ruby-2.4.0@global/gems/bundler-1.15.4/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
/Users/nhoizey/.rvm/gems/ruby-2.4.0@global/gems/bundler-1.15.4/lib/bundler/vendor/thor/lib/thor/invocation.rb:126:in `invoke_command'
/Users/nhoizey/.rvm/gems/ruby-2.4.0@global/gems/bundler-1.15.4/lib/bundler/vendor/thor/lib/thor.rb:387:in `dispatch'
/Users/nhoizey/.rvm/gems/ruby-2.4.0@global/gems/bundler-1.15.4/lib/bundler/cli.rb:22:in `dispatch'
/Users/nhoizey/.rvm/gems/ruby-2.4.0@global/gems/bundler-1.15.4/lib/bundler/vendor/thor/lib/thor/base.rb:466:in `start'
/Users/nhoizey/.rvm/gems/ruby-2.4.0@global/gems/bundler-1.15.4/lib/bundler/cli.rb:13:in `start'
/Users/nhoizey/.rvm/gems/ruby-2.4.0@global/gems/bundler-1.15.4/exe/bundle:30:in `block in <top (required)>'
/Users/nhoizey/.rvm/gems/ruby-2.4.0@global/gems/bundler-1.15.4/lib/bundler/friendly_errors.rb:121:in `with_friendly_errors'
/Users/nhoizey/.rvm/gems/ruby-2.4.0@global/gems/bundler-1.15.4/exe/bundle:22:in `<top (required)>'
/Users/nhoizey/.rvm/gems/ruby-2.4.0/bin/bundle:22:in `load'
/Users/nhoizey/.rvm/gems/ruby-2.4.0/bin/bundle:22:in `<main>'
/Users/nhoizey/.rvm/gems/ruby-2.4.0/bin/ruby_executable_hooks:15:in `eval'
/Users/nhoizey/.rvm/gems/ruby-2.4.0/bin/ruby_executable_hooks:15:in `<main>'

Caused by:
LoadError: cannot load such file -- jekyll-tagging
/Users/nhoizey/.rvm/gems/ruby-2.4.0/gems/jekyll-3.6.2/lib/jekyll/external.rb:58:in `require'
/Users/nhoizey/.rvm/gems/ruby-2.4.0/gems/jekyll-3.6.2/lib/jekyll/external.rb:58:in `block in require_with_graceful_fail'
/Users/nhoizey/.rvm/gems/ruby-2.4.0/gems/jekyll-3.6.2/lib/jekyll/external.rb:55:in `each'
/Users/nhoizey/.rvm/gems/ruby-2.4.0/gems/jekyll-3.6.2/lib/jekyll/external.rb:55:in `require_with_graceful_fail'
/Users/nhoizey/.rvm/gems/ruby-2.4.0/gems/jekyll-3.6.2/lib/jekyll/plugin_manager.rb:30:in `require_gems'
/Users/nhoizey/.rvm/gems/ruby-2.4.0/gems/jekyll-3.6.2/lib/jekyll/plugin_manager.rb:22:in `conscientious_require'
/Users/nhoizey/.rvm/gems/ruby-2.4.0/gems/jekyll-3.6.2/lib/jekyll/site.rb:113:in `setup'
/Users/nhoizey/.rvm/gems/ruby-2.4.0/gems/jekyll-3.6.2/lib/jekyll/site.rb:34:in `initialize'
/Users/nhoizey/Dropbox/Personnel/Devs/nicolas-hoizey.com/Rakefile:11:in `new'
/Users/nhoizey/Dropbox/Personnel/Devs/nicolas-hoizey.com/Rakefile:11:in `block in <top (required)>'
/Users/nhoizey/Dropbox/Personnel/Devs/nicolas-hoizey.com/Rakefile:7:in `<top (required)>'
/Users/nhoizey/.rvm/gems/ruby-2.4.0/gems/rake-12.2.1/exe/rake:27:in `<top (required)>'
/Users/nhoizey/.rvm/gems/ruby-2.4.0@global/gems/bundler-1.15.4/lib/bundler/cli/exec.rb:74:in `load'
/Users/nhoizey/.rvm/gems/ruby-2.4.0@global/gems/bundler-1.15.4/lib/bundler/cli/exec.rb:74:in `kernel_load'
/Users/nhoizey/.rvm/gems/ruby-2.4.0@global/gems/bundler-1.15.4/lib/bundler/cli/exec.rb:27:in `run'
/Users/nhoizey/.rvm/gems/ruby-2.4.0@global/gems/bundler-1.15.4/lib/bundler/cli.rb:362:in `exec'
/Users/nhoizey/.rvm/gems/ruby-2.4.0@global/gems/bundler-1.15.4/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
/Users/nhoizey/.rvm/gems/ruby-2.4.0@global/gems/bundler-1.15.4/lib/bundler/vendor/thor/lib/thor/invocation.rb:126:in `invoke_command'
/Users/nhoizey/.rvm/gems/ruby-2.4.0@global/gems/bundler-1.15.4/lib/bundler/vendor/thor/lib/thor.rb:387:in `dispatch'
/Users/nhoizey/.rvm/gems/ruby-2.4.0@global/gems/bundler-1.15.4/lib/bundler/cli.rb:22:in `dispatch'
/Users/nhoizey/.rvm/gems/ruby-2.4.0@global/gems/bundler-1.15.4/lib/bundler/vendor/thor/lib/thor/base.rb:466:in `start'
/Users/nhoizey/.rvm/gems/ruby-2.4.0@global/gems/bundler-1.15.4/lib/bundler/cli.rb:13:in `start'
/Users/nhoizey/.rvm/gems/ruby-2.4.0@global/gems/bundler-1.15.4/exe/bundle:30:in `block in <top (required)>'
/Users/nhoizey/.rvm/gems/ruby-2.4.0@global/gems/bundler-1.15.4/lib/bundler/friendly_errors.rb:121:in `with_friendly_errors'
/Users/nhoizey/.rvm/gems/ruby-2.4.0@global/gems/bundler-1.15.4/exe/bundle:22:in `<top (required)>'
/Users/nhoizey/.rvm/gems/ruby-2.4.0/bin/bundle:22:in `load'
/Users/nhoizey/.rvm/gems/ruby-2.4.0/bin/bundle:22:in `<main>'
/Users/nhoizey/.rvm/gems/ruby-2.4.0/bin/ruby_executable_hooks:15:in `eval'
/Users/nhoizey/.rvm/gems/ruby-2.4.0/bin/ruby_executable_hooks:15:in `<main>'
(See full trace by running task with --trace)
pixelastic commented 7 years ago

Just a bump to let you know I've seen the issue and will try to repro it and see how it can be fixed. From where I stand today, I have no idea what is going on. Is the repo you linked earlier the one where I can still reproduce the issue?

nhoizey commented 6 years ago

Yes, still the same repo.

pixelastic commented 6 years ago

@nhoizey I've tried pulling your repo but it's git that does not want to play nicely with me this time

error: unable to create file _comments/2006-07-06-open-xml-translator-clever-age-realise-pour-microsoft-corp-un-plugin-permettant-a-word-2007-d-utiliser-le-format-opendocument-odf-d-openoffice_2006-07-08-153409.yml (File name too long)

Seems like I'm hitting a filepath restriction on Linux. I'm gonna exclude those files from my local clone for now :)

nhoizey commented 6 years ago

@pixelastic that's strange, it works well on macOS. Anyway, this post title is way to long… ;-)

pixelastic commented 6 years ago

Could you try with jekyll-algolia?

I have changed the way dependencies are loaded. Previously I had my .gemspec depending on the Gemfile. Now I have the Gemfile depending on the .gemspec.

As I mentionned in another issue, I managed to fork your repo and run jekyll algolia on it without issue. I don't see any Rakefile in the current repo. Am I missing something?

With the new plugin and version of Jekyll you should be able to simply define the plugin in your Gemfile and have it picked up by Jekyll like this:

source 'https://rubygems.org'

gem 'jekyll'

group :jekyll_plugins do
  gem 'jekyll-algolia'
end

Running bundle install will get you all the dependencies, and running jekyll help should automatically pick up the jekyll-algolia and display it in the list of available commands.

To be able to use my gems defined in Gemfile from within my Rakefile, I usually put this at the top of my Rakefile:

require 'rubygems'
require 'bundler'
begin
  Bundler.setup(:default, :development)
rescue Bundler::BundlerError => e
  warn e.message
  warn 'Run `bundle install` to install missing gems'
  exit e.status_code
end
require 'rake'

# The rest of your Rakefile

Hope that helps!

pixelastic commented 6 years ago

I'm closing this for now. Feel free to re-open it if you have similar issues with jekyll-algolia.