shigeya / jekyll-category-archive-plugin

Jekyll plugin for category archive
80 stars 40 forks source link

Getting an error when using plugin #9

Closed eberkund closed 9 years ago

eberkund commented 9 years ago

Hi, when I follow the instructions and copy the 2 files into my Jekyll site I am getting this when I try to generate (using --trace):

/Users/erik/chessground/_plugins/category_archive_plugin.rb:82:in 'initialize': undefined method '[]' for nil:NilClass (NoMethodError) from /Users/erik/chessground/_plugins/category_archive_plugin.rb:32:in 'new' from /Users/erik/chessground/_plugins/category_archive_plugin.rb:32:in 'block in generate' from /Users/erik/chessground/_plugins/category_archive_plugin.rb:31:in 'each' from /Users/erik/chessground/_plugins/category_archive_plugin.rb:31:in 'generate' from /Users/erik/.rvm/gems/ruby-head/gems/jekyll-2.5.2/lib/jekyll/site.rb:280:in 'block in generate' from /Users/erik/.rvm/gems/ruby-head/gems/jekyll-2.5.2/lib/jekyll/site.rb:279:in 'each' from /Users/erik/.rvm/gems/ruby-head/gems/jekyll-2.5.2/lib/jekyll/site.rb:279:in 'generate' from /Users/erik/.rvm/gems/ruby-head/gems/jekyll-2.5.2/lib/jekyll/site.rb:50:in 'process' from /Users/erik/.rvm/gems/ruby-head/gems/jekyll-2.5.2/lib/jekyll/command.rb:28:in 'process_site' from /Users/erik/.rvm/gems/ruby-head/gems/jekyll-2.5.2/lib/jekyll/commands/build.rb:56:in 'build' from /Users/erik/.rvm/gems/ruby-head/gems/jekyll-2.5.2/lib/jekyll/commands/build.rb:34:in 'process' from /Users/erik/.rvm/gems/ruby-head/gems/jekyll-2.5.2/lib/jekyll/commands/serve.rb:26:in 'block (2 levels) in init_with_program' from /Users/erik/.rvm/gems/ruby-head/gems/mercenary-0.3.5/lib/mercenary/command.rb:220:in 'call' from /Users/erik/.rvm/gems/ruby-head/gems/mercenary-0.3.5/lib/mercenary/command.rb:220:in 'block in execute' from /Users/erik/.rvm/gems/ruby-head/gems/mercenary-0.3.5/lib/mercenary/command.rb:220:in 'each' from /Users/erik/.rvm/gems/ruby-head/gems/mercenary-0.3.5/lib/mercenary/command.rb:220:in 'execute' from /Users/erik/.rvm/gems/ruby-head/gems/mercenary-0.3.5/lib/mercenary/program.rb:42:in 'go' from /Users/erik/.rvm/gems/ruby-head/gems/mercenary-0.3.5/lib/mercenary.rb:19:in 'program' from /Users/erik/.rvm/gems/ruby-head/gems/jekyll-2.5.2/bin/jekyll:20:in '<top (required)>' from /Users/erik/.rvm/gems/ruby-head/bin/jekyll:23:in 'load' from /Users/erik/.rvm/gems/ruby-head/bin/jekyll:23:in '<main>' from /Users/erik/.rvm/gems/ruby-head/bin/ruby_executable_hooks:15:in 'eval' from /Users/erik/.rvm/gems/ruby-head/bin/ruby_executable_hooks:15:in '<main>'

shigeya commented 9 years ago

Hi. This report does not provide enough information thus I can't help. Please provide version of the gems you're using. you can list current gems by running gem list.

eberkund commented 9 years ago

The result of gem list gives me:

*** LOCAL GEMS *** bigdecimal (1.2.5) blankslate (2.1.2.4) bundler (1.7.9) bundler-unload (1.0.2) celluloid (0.16.0) classifier-reborn (2.0.2) coffee-script (2.3.0) coffee-script-source (1.8.0) colorator (0.1) execjs (2.2.2) executable-hooks (1.3.2) fast-stemmer (1.0.2) ffi (1.9.6) gem-wrappers (1.2.7) hitimes (1.2.2) io-console (0.4.2) jekyll (2.5.2) jekyll-coffeescript (1.0.1) jekyll-gist (1.1.0) jekyll-paginate (1.1.0) jekyll-sass-converter (1.3.0) jekyll-watch (1.2.0) json (1.8.1) kramdown (1.5.0) liquid (2.6.1) listen (2.8.3) mercenary (0.3.5) parslet (1.5.0) posix-spawn (0.3.9) psych (2.0.8) pygments.rb (0.6.0) rake (10.4.2) rb-fsevent (0.9.4) rb-inotify (0.9.5) rdoc (4.2.0) redcarpet (3.2.2) rubygems-bundler (1.4.4) rvm (1.11.3.9) safe_yaml (1.0.4) sass (3.4.9) timers (4.0.1) toml (0.1.2) yajl-ruby (1.1.0)

Also, if I comment out line 32, I no longer get the error and Jekyll is able to generate. site.pages << CategoryArchivePage.new(site, CategoryArchiveUtil.archive_base(site), category, list)

Let me know if there is anymore info you need, thanks!

shigeya commented 9 years ago

Thanks. At very least, I haven't tested latest Jekyll thus will check on that, also look into other areas..

eberkund commented 9 years ago

Which versions have you tested it with? I could make sure it works with that version, just to confirm that there is not some other issue with my system that is causing the problem

shigeya commented 9 years ago

Long ago, thus it's not worth it. Also, I think it's not Jekyll's version specific issue. Anyway, will let you know whether it's version specific or not quickly..

shigeya commented 9 years ago

One of my site build succeeded without problem. The other has issue (but different error). Will look into the issue. please wait.

shigeya commented 9 years ago

I have updated all gems to latest. It was not the issue of category plugin (there was other issue). If you don't provide --trace option, what does jekyll emit?

eberkund commented 9 years ago

Just this:

Generating... jekyll 2.4.0 | Error: undefined method '[]' for nil:NilClass

shigeya commented 9 years ago

Doesn't it provide where it cause the error? (just checking) And also assuming you're using latest Category plugin (latest Jekyll only work with latest plugin)

eberkund commented 9 years ago

Yeah, I downloaded it straight from GitHub and no it is just that unless I put the --trace parameter then it says the line number

breakhearts commented 9 years ago

I meet the same problem, and i use windows version ruby and jekyii, does the platform relate to the problem?

eberkund commented 9 years ago

It shouldn't matter that you're using Windows, although the version of Jekyll and Ruby probably makes a difference.

breakhearts commented 9 years ago

I found the problem, you must set category_archive in _config.yml, or code in
"if site.config['category_archive']['slugify']" will crash

eberkund commented 9 years ago

@breakhearts, can you elaborate on that?

breakhearts commented 9 years ago

when i review the code here Users/erik/chessground/_plugins/category_archive_plugin.rb:82:in 'initialize': undefined method '[]' for nil:NilClass (NoMethodError) , i found the code "if site.config['category_archive']['slugify']" when category_archive not set in _config.yml, site.config['category_archive'] is Nil, then "if site.config['category_archive']['slugify']" will report error, after i set that, this error disappeared, but i fall into another problem, still can not finish build

eberkund commented 9 years ago

Ah, I have fixed the issue by adding:

category_archive: path: /

to my _config.yml file. I think that this should be the new default value instead of the "null string" because that does not work and causes the site no to generate.

shigeya commented 9 years ago

Ah, I now understand what have happened. One of the pull request I have merged haven't checked existence of category_archive key. try to fix now.

shigeya commented 9 years ago

Pushed 18ee57e5eed1a8e78f2a16d94989e748a3dc435b. Please try if you can... But since the patch has incorporated on Dec 12, it might not fix @eberkund's issue (directly)

eberkund commented 9 years ago

Yes, that fixed the issue. It now works without needing anything extra in _config.yml

shigeya commented 9 years ago

Thank you