octopress / paginate

A simple paginator for Jekyll sites.
MIT License
105 stars 37 forks source link

Error: undefined method `[]' for true:TrueClass #9

Open taringamberini opened 9 years ago

taringamberini commented 9 years ago

Problem

Running rake generate I get the error:

## Generating Site with Jekyll
    write source/stylesheets/screen.css
Configuration file: /home/userX/projectY/octopress/_config.yml
            Source: source
       Destination: public
      Generating... 
jekyll 2.5.3 | Error:  undefined method `[]' for true:TrueClass

A more detailed log is:

.../octopress(git:source!?)$ jekyll build --trace
Configuration file: /home/userX/projectY/octopress/_config.yml
            Source: source
       Destination: public
      Generating... 
/home/userX/.rvm/gems/ruby-2.2.1/gems/octopress-paginate-1.1.2/lib/octopress-paginate.rb:132:in `collection': undefined method `[]' for true:TrueClass (NoMethodError)
    from /home/userX/.rvm/gems/ruby-2.2.1/gems/octopress-paginate-1.1.2/lib/octopress-paginate.rb:155:in `page_payload'
    from /home/userX/.rvm/gems/ruby-2.2.1/gems/octopress-paginate-1.1.2/lib/octopress-paginate/hooks.rb:16:in `merge_payload'
    from /home/userX/.rvm/gems/ruby-2.2.1/gems/octopress-hooks-2.6.1/lib/octopress-hooks.rb:380:in `block in merge_payload'
    from /home/userX/.rvm/gems/ruby-2.2.1/gems/octopress-hooks-2.6.1/lib/octopress-hooks.rb:379:in `each'
    from /home/userX/.rvm/gems/ruby-2.2.1/gems/octopress-hooks-2.6.1/lib/octopress-hooks.rb:379:in `merge_payload'
    from /home/userX/.rvm/gems/ruby-2.2.1/gems/octopress-hooks-2.6.1/lib/octopress-hooks.rb:350:in `do_layout'
    from /home/userX/.rvm/gems/ruby-2.2.1/gems/octopress-tag-helpers-1.0.8/lib/octopress-tag-helpers/hooks.rb:9:in `do_layout'
    from /home/userX/.rvm/gems/ruby-2.2.1/gems/jekyll-2.5.3/lib/jekyll/page.rb:122:in `render'
    from /home/userX/.rvm/gems/ruby-2.2.1/gems/jekyll-2.5.3/lib/jekyll/site.rb:298:in `block in render'
    from /home/userX/.rvm/gems/ruby-2.2.1/gems/jekyll-2.5.3/lib/jekyll/site.rb:297:in `each'
    from /home/userX/.rvm/gems/ruby-2.2.1/gems/jekyll-2.5.3/lib/jekyll/site.rb:297:in `render'
    from /home/userX/.rvm/gems/ruby-2.2.1/gems/octopress-hooks-2.6.1/lib/octopress-hooks.rb:197:in `render'
    from /home/userX/.rvm/gems/ruby-2.2.1/gems/jekyll-2.5.3/lib/jekyll/site.rb:51:in `process'
    from /home/userX/.rvm/gems/ruby-2.2.1/gems/jekyll-2.5.3/lib/jekyll/command.rb:28:in `process_site'
    from /home/userX/.rvm/gems/ruby-2.2.1/gems/jekyll-2.5.3/lib/jekyll/commands/build.rb:56:in `build'
    from /home/userX/.rvm/gems/ruby-2.2.1/gems/jekyll-2.5.3/lib/jekyll/commands/build.rb:34:in `process'
    from /home/userX/.rvm/gems/ruby-2.2.1/gems/jekyll-2.5.3/lib/jekyll/commands/build.rb:18:in `block (2 levels) in init_with_program'
    from /home/userX/.rvm/gems/ruby-2.2.1/gems/mercenary-0.3.5/lib/mercenary/command.rb:220:in `call'
    from /home/userX/.rvm/gems/ruby-2.2.1/gems/mercenary-0.3.5/lib/mercenary/command.rb:220:in `block in execute'
    from /home/userX/.rvm/gems/ruby-2.2.1/gems/mercenary-0.3.5/lib/mercenary/command.rb:220:in `each'
    from /home/userX/.rvm/gems/ruby-2.2.1/gems/mercenary-0.3.5/lib/mercenary/command.rb:220:in `execute'
    from /home/userX/.rvm/gems/ruby-2.2.1/gems/mercenary-0.3.5/lib/mercenary/program.rb:42:in `go'
    from /home/userX/.rvm/gems/ruby-2.2.1/gems/mercenary-0.3.5/lib/mercenary.rb:19:in `program'
    from /home/userX/.rvm/gems/ruby-2.2.1/gems/jekyll-2.5.3/bin/jekyll:20:in `<top (required)>'
    from /home/userX/.rvm/gems/ruby-2.2.1/bin/jekyll:23:in `load'
    from /home/userX/.rvm/gems/ruby-2.2.1/bin/jekyll:23:in `<main>'
    from /home/userX/.rvm/gems/ruby-2.2.1/bin/ruby_executable_hooks:15:in `eval'
    from /home/userX/.rvm/gems/ruby-2.2.1/bin/ruby_executable_hooks:15:in `<main>'

Cause

The problem arises when in source/_post the number of posts exceeds 10.

In order to determine if there were something wrong in a post I've tried combinations of different posts, but there's no problem if the number of posts is less then or equals to 10; as soon as I add the 11st post, no matter which one, the error appears.

My installation details

My rubies installations:

.../octopress(git:source!?)$ rvm list

rvm rubies

=* ruby-2.2.1 [ x86_64 ]

# => - current
# =* - current && default
#  * - default

My current ruby installations is 2.2.1p85:

.../octopress(git:source!?)$ ruby --version
ruby 2.2.1p85 (2015-02-26 revision 49769) [x86_64-linux]

My gems are:

.../octopress(git:source!?)$ bundle list
Gems included by the bundle:
  * RedCloth (4.2.9)
  * autoprefixer-rails (2.2.0.20140804)
  * blankslate (2.1.2.4)
  * bundler (1.10.6)
  * celluloid (0.16.0)
  * chunky_png (1.3.4)
  * classifier-reborn (2.0.3)
  * coffee-script (2.4.1)
  * coffee-script-source (1.9.1.1)
  * colorator (0.1)
  * compass (1.0.3)
  * compass-core (1.0.3)
  * compass-import-once (1.0.5)
  * execjs (2.5.2)
  * fast-stemmer (1.0.2)
  * ffi (1.9.10)
  * haml (4.0.6)
  * hitimes (1.2.2)
  * jekyll (2.5.3)
  * jekyll-coffeescript (1.0.1)
  * jekyll-gist (1.2.1)
  * jekyll-paginate (1.1.0)
  * jekyll-sass-converter (1.3.0)
  * jekyll-sitemap (0.8.1)
  * jekyll-watch (1.2.1)
  * json (1.8.3)
  * kramdown (1.8.0)
  * liquid (2.6.3)
  * listen (2.10.1)
  * mercenary (0.3.5)
  * multi_json (1.11.2)
  * octopress (3.0.11)
  * octopress-autoprefixer (1.0.1)
  * octopress-date-format (2.0.2)
  * octopress-deploy (1.3.0)
  * octopress-escape-code (2.0.6)
  * octopress-feeds (2.0.4)
  * octopress-filters (1.3.3)
  * octopress-hooks (2.6.1)
  * octopress-include-tag (1.1.3)
  * octopress-ink (1.2.0)
  * octopress-multilingual (1.2.0)
  * octopress-paginate (1.1.2)
  * octopress-return-tag (1.0.1)
  * octopress-tag-helpers (1.0.8)
  * parslet (1.5.0)
  * posix-spawn (0.3.11)
  * pygments.rb (0.6.3)
  * rack (1.6.4)
  * rack-protection (1.5.3)
  * rake (10.4.2)
  * rb-fsevent (0.9.5)
  * rb-inotify (0.9.5)
  * rdiscount (2.1.8)
  * redcarpet (3.3.2)
  * rubypants-unicode (0.2.5)
  * safe_yaml (1.0.4)
  * sass (3.4.16)
  * sass-globbing (1.0.0)
  * sinatra (1.4.6)
  * stringex (1.4.0)
  * tilt (2.0.1)
  * timers (4.0.1)
  * titlecase (0.1.1)
  * toml (0.1.2)
  * uglifier (2.7.1)
  * yajl-ruby (1.2.1)

My sources (with less then 11 posts) are on source branch, you can get them by running:

$ git clone https://github.com/taringamberini/taringamberini.github.io.git
$ cd taringamberini.github.io/
$ git checkout source

Thanks, Tarin

taringamberini commented 9 years ago

The problem is still present even installing ruby-1.9.3 the minimum ruby version required by the documentation.

In fact I've installed ruby 1.9.3

$ rvm install 1.9.3
Searching for binary rubies, this might take some time.
Found remote file https://rvm_io.global.ssl.fastly.net/binaries/debian/7/x86_64/ruby-1.9.3-p551.tar.bz2
Checking requirements for debian.
Requirements installation successful.
ruby-1.9.3-p551 - #configure
ruby-1.9.3-p551 - #download
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 13.2M  100 13.2M    0     0   704k      0  0:00:19  0:00:19 --:--:--  734k
ruby-1.9.3-p551 - #validate archive
ruby-1.9.3-p551 - #extract
ruby-1.9.3-p551 - #validate binary
ruby-1.9.3-p551 - #setup
ruby-1.9.3-p551 - #gemset created /home/userX/.rvm/gems/ruby-1.9.3-p551@global
ruby-1.9.3-p551 - #importing gemset /home/userX/.rvm/gemsets/global.gems..............................
ruby-1.9.3-p551 - #generating global wrappers........
ruby-1.9.3-p551 - #gemset created /home/userX/.rvm/gems/ruby-1.9.3-p551
ruby-1.9.3-p551 - #importing gemsetfile /home/userX/.rvm/gemsets/default.gems evaluated to empty gem list
ruby-1.9.3-p551 - #generating default wrappers........

I've set the just installed 1.9.3 as the current one used:

$ rvm use 1.9.3
Using /home/userX/.rvm/gems/ruby-1.9.3-p551
$ rvm list

rvm rubies

=> ruby-1.9.3-p551 [ x86_64 ]
 * ruby-2.2.1 [ x86_64 ]

# => - current
# =* - current && default
#  * - default

$ ruby --version
ruby 1.9.3p551 (2014-11-13 revision 48407) [x86_64-linux]

I've intalled the latest gems:

$ rvm rubygems latest
ruby-1.9.3-p551 - #downloading rubygems-2.4.8
ruby-1.9.3-p551 - #extracting rubygems-2.4.8.....
ruby-1.9.3-p551 - #removing old rubygems.........
ruby-1.9.3-p551 - #installing rubygems-2.4.8......................

I've changed directory to my octopress project and I've installed bundler:

$ cd /home/userX/projectY/octopress
/home/userX/projectY/octopress(git:source!?)$ gem install bundler
Fetching: bundler-1.10.6.gem (100%)
Successfully installed bundler-1.10.6
Installing ri documentation for bundler-1.10.6
1 gem installed

I've installed the dependencies:

/home/userX/projectY/octopress(git:source!?)$ bundle install
Fetching gem metadata from https://rubygems.org/..........
Fetching version metadata from https://rubygems.org/...
Fetching dependency metadata from https://rubygems.org/..
Installing rake 10.4.2
Installing RedCloth 4.2.9 with native extensions
Installing execjs 2.5.2
Installing autoprefixer-rails 2.2.0.20140804
Installing blankslate 2.1.2.4
Installing hitimes 1.2.2 with native extensions
Installing timers 4.0.1
Installing celluloid 0.16.0
Installing chunky_png 1.3.4
Installing fast-stemmer 1.0.2 with native extensions
Installing classifier-reborn 2.0.3
Installing coffee-script-source 1.9.1.1
Installing coffee-script 2.4.1
Installing colorator 0.1
Installing multi_json 1.11.2
Installing sass 3.4.16
Installing compass-core 1.0.3
Installing compass-import-once 1.0.5
Installing rb-fsevent 0.9.5
Installing ffi 1.9.10 with native extensions
Installing rb-inotify 0.9.5
Installing compass 1.0.3
Installing tilt 2.0.1
Installing haml 4.0.6
Installing jekyll-coffeescript 1.0.1
Installing jekyll-gist 1.2.1
Installing jekyll-paginate 1.1.0
Installing jekyll-sass-converter 1.3.0
Installing listen 2.10.1
Installing jekyll-watch 1.2.1
Installing kramdown 1.8.0
Installing liquid 2.6.3
Installing mercenary 0.3.5
Installing posix-spawn 0.3.11 with native extensions
Installing yajl-ruby 1.2.1 with native extensions
Installing pygments.rb 0.6.3
Installing redcarpet 3.3.2 with native extensions
Installing safe_yaml 1.0.4
Installing parslet 1.5.0
Installing toml 0.1.2
Installing jekyll 2.5.3
Installing jekyll-sitemap 0.8.1
Installing json 1.8.3 with native extensions
Installing octopress-deploy 1.3.0
Installing octopress-hooks 2.6.1
Installing octopress-escape-code 2.0.6
Installing titlecase 0.1.1
Installing octopress 3.0.11
Installing octopress-autoprefixer 1.0.1
Installing octopress-date-format 2.0.2
Installing rubypants-unicode 0.2.5
Installing octopress-filters 1.3.3
Installing octopress-tag-helpers 1.0.8
Installing octopress-include-tag 1.1.3
Installing uglifier 2.7.1
Installing octopress-ink 1.2.0
Installing octopress-return-tag 1.0.1
Installing octopress-feeds 2.0.4
Installing octopress-multilingual 1.2.0
Installing octopress-paginate 1.1.2
Installing rack 1.6.4
Installing rack-protection 1.5.3
Installing rdiscount 2.1.8 with native extensions
Installing sass-globbing 1.0.0
Installing sinatra 1.4.6
Installing stringex 1.4.0
Using bundler 1.10.6
Bundle complete! 16 Gemfile dependencies, 67 gems now installed.
Use `bundle show [gemname]` to see where a bundled gem is installed.
Post-install message from compass:
    Compass is charityware. If you love it, please donate on our behalf at http://umdf.org/compass Thanks!
Post-install message from haml:

HEADS UP! Haml 4.0 has many improvements, but also has changes that may break
your application:

* Support for Ruby 1.8.6 dropped
* Support for Rails 2 dropped
* Sass filter now always outputs <style> tags
* Data attributes are now hyphenated, not underscored
* html2haml utility moved to the html2haml gem
* Textile and Maruku filters moved to the haml-contrib gem

For more info see:

http://rubydoc.info/github/haml/haml/file/CHANGELOG.md

/home/userX/projectY/octopress(git:source!?)$ 

Finally I've tried to generate my site:

/home/userX/projectY/octopress(git:source!?)$ jekyll build --trace
Configuration file: /home/userX/projectY/octopress/_config.yml
            Source: source
       Destination: public
      Generating... 
/home/userX/.rvm/gems/ruby-1.9.3-p551/gems/octopress-paginate-1.1.2/lib/octopress-paginate.rb:132:in `collection': undefined method `[]' for true:TrueClass (NoMethodError)
    from /home/userX/.rvm/gems/ruby-1.9.3-p551/gems/octopress-paginate-1.1.2/lib/octopress-paginate.rb:155:in `page_payload'
    from /home/userX/.rvm/gems/ruby-1.9.3-p551/gems/octopress-paginate-1.1.2/lib/octopress-paginate/hooks.rb:16:in `merge_payload'
    from /home/userX/.rvm/gems/ruby-1.9.3-p551/gems/octopress-hooks-2.6.1/lib/octopress-hooks.rb:380:in `block in merge_payload'
    from /home/userX/.rvm/gems/ruby-1.9.3-p551/gems/octopress-hooks-2.6.1/lib/octopress-hooks.rb:379:in `each'
    from /home/userX/.rvm/gems/ruby-1.9.3-p551/gems/octopress-hooks-2.6.1/lib/octopress-hooks.rb:379:in `merge_payload'
    from /home/userX/.rvm/gems/ruby-1.9.3-p551/gems/octopress-hooks-2.6.1/lib/octopress-hooks.rb:350:in `do_layout'
    from /home/userX/.rvm/gems/ruby-1.9.3-p551/gems/octopress-tag-helpers-1.0.8/lib/octopress-tag-helpers/hooks.rb:9:in `do_layout'
    from /home/userX/.rvm/gems/ruby-1.9.3-p551/gems/jekyll-2.5.3/lib/jekyll/page.rb:122:in `render'
    from /home/userX/.rvm/gems/ruby-1.9.3-p551/gems/jekyll-2.5.3/lib/jekyll/site.rb:298:in `block in render'
    from /home/userX/.rvm/gems/ruby-1.9.3-p551/gems/jekyll-2.5.3/lib/jekyll/site.rb:297:in `each'
    from /home/userX/.rvm/gems/ruby-1.9.3-p551/gems/jekyll-2.5.3/lib/jekyll/site.rb:297:in `render'
    from /home/userX/.rvm/gems/ruby-1.9.3-p551/gems/octopress-hooks-2.6.1/lib/octopress-hooks.rb:197:in `render'
    from /home/userX/.rvm/gems/ruby-1.9.3-p551/gems/jekyll-2.5.3/lib/jekyll/site.rb:51:in `process'
    from /home/userX/.rvm/gems/ruby-1.9.3-p551/gems/jekyll-2.5.3/lib/jekyll/command.rb:28:in `process_site'
    from /home/userX/.rvm/gems/ruby-1.9.3-p551/gems/jekyll-2.5.3/lib/jekyll/commands/build.rb:56:in `build'
    from /home/userX/.rvm/gems/ruby-1.9.3-p551/gems/jekyll-2.5.3/lib/jekyll/commands/build.rb:34:in `process'
    from /home/userX/.rvm/gems/ruby-1.9.3-p551/gems/jekyll-2.5.3/lib/jekyll/commands/build.rb:18:in `block (2 levels) in init_with_program'
    from /home/userX/.rvm/gems/ruby-1.9.3-p551/gems/mercenary-0.3.5/lib/mercenary/command.rb:220:in `call'
    from /home/userX/.rvm/gems/ruby-1.9.3-p551/gems/mercenary-0.3.5/lib/mercenary/command.rb:220:in `block in execute'
    from /home/userX/.rvm/gems/ruby-1.9.3-p551/gems/mercenary-0.3.5/lib/mercenary/command.rb:220:in `each'
    from /home/userX/.rvm/gems/ruby-1.9.3-p551/gems/mercenary-0.3.5/lib/mercenary/command.rb:220:in `execute'
    from /home/userX/.rvm/gems/ruby-1.9.3-p551/gems/mercenary-0.3.5/lib/mercenary/program.rb:42:in `go'
    from /home/userX/.rvm/gems/ruby-1.9.3-p551/gems/mercenary-0.3.5/lib/mercenary.rb:19:in `program'
    from /home/userX/.rvm/gems/ruby-1.9.3-p551/gems/jekyll-2.5.3/bin/jekyll:20:in `<top (required)>'
    from /home/userX/.rvm/gems/ruby-1.9.3-p551/bin/jekyll:23:in `load'
    from /home/userX/.rvm/gems/ruby-1.9.3-p551/bin/jekyll:23:in `<main>'
    from /home/userX/.rvm/gems/ruby-1.9.3-p551/bin/ruby_executable_hooks:15:in `eval'
    from /home/userX/.rvm/gems/ruby-1.9.3-p551/bin/ruby_executable_hooks:15:in `<main>'

The error issued is still present.

Thanks, Tarin

taringamberini commented 9 years ago

If I change the index.html from:

---
layout: default
lang: it
paginate: true
---

to:

---
layout: default
lang: it
paginate:
  collection:   posts
---

the original issued error seems not happen, in fact I get the different error:

/home/userX/projectY/octopress(git:source!?)$ jekyll build --trace
Configuration file: /home/userX/projectY/octopress/_config.yml
            Source: source
       Destination: public
      Generating... 
/var/lib/gems/1.9.1/gems/octopress-paginate-1.1.2/lib/octopress-paginate.rb:173:in `items': undefined method `-' for nil:NilClass (NoMethodError)
    from /var/lib/gems/1.9.1/gems/octopress-paginate-1.1.2/lib/octopress-paginate.rb:157:in `page_payload'
    from /var/lib/gems/1.9.1/gems/octopress-paginate-1.1.2/lib/octopress-paginate/hooks.rb:16:in `merge_payload'
    from /var/lib/gems/1.9.1/gems/octopress-hooks-2.6.1/lib/octopress-hooks.rb:380:in `block in merge_payload'
    from /var/lib/gems/1.9.1/gems/octopress-hooks-2.6.1/lib/octopress-hooks.rb:379:in `each'
    from /var/lib/gems/1.9.1/gems/octopress-hooks-2.6.1/lib/octopress-hooks.rb:379:in `merge_payload'
    from /var/lib/gems/1.9.1/gems/octopress-hooks-2.6.1/lib/octopress-hooks.rb:350:in `do_layout'
    from /var/lib/gems/1.9.1/gems/octopress-tag-helpers-1.0.8/lib/octopress-tag-helpers/hooks.rb:9:in `do_layout'
    from /var/lib/gems/1.9.1/gems/jekyll-2.5.3/lib/jekyll/page.rb:122:in `render'
    from /var/lib/gems/1.9.1/gems/jekyll-2.5.3/lib/jekyll/site.rb:298:in `block in render'
    from /var/lib/gems/1.9.1/gems/jekyll-2.5.3/lib/jekyll/site.rb:297:in `each'
    from /var/lib/gems/1.9.1/gems/jekyll-2.5.3/lib/jekyll/site.rb:297:in `render'
    from /var/lib/gems/1.9.1/gems/octopress-hooks-2.6.1/lib/octopress-hooks.rb:197:in `render'
    from /var/lib/gems/1.9.1/gems/jekyll-2.5.3/lib/jekyll/site.rb:51:in `process'
    from /var/lib/gems/1.9.1/gems/jekyll-2.5.3/lib/jekyll/command.rb:28:in `process_site'
    from /var/lib/gems/1.9.1/gems/jekyll-2.5.3/lib/jekyll/commands/build.rb:56:in `build'
    from /var/lib/gems/1.9.1/gems/jekyll-2.5.3/lib/jekyll/commands/build.rb:34:in `process'
    from /var/lib/gems/1.9.1/gems/jekyll-2.5.3/lib/jekyll/commands/build.rb:18:in `block (2 levels) in init_with_program'
    from /var/lib/gems/1.9.1/gems/mercenary-0.3.5/lib/mercenary/command.rb:220:in `call'
    from /var/lib/gems/1.9.1/gems/mercenary-0.3.5/lib/mercenary/command.rb:220:in `block in execute'
    from /var/lib/gems/1.9.1/gems/mercenary-0.3.5/lib/mercenary/command.rb:220:in `each'
    from /var/lib/gems/1.9.1/gems/mercenary-0.3.5/lib/mercenary/command.rb:220:in `execute'
    from /var/lib/gems/1.9.1/gems/mercenary-0.3.5/lib/mercenary/program.rb:42:in `go'
    from /var/lib/gems/1.9.1/gems/mercenary-0.3.5/lib/mercenary.rb:19:in `program'
    from /var/lib/gems/1.9.1/gems/jekyll-2.5.3/bin/jekyll:20:in `<top (required)>'
    from /usr/local/bin/jekyll:23:in `load'
    from /usr/local/bin/jekyll:23:in `<main>'

which happens on line 173 after (but I'm not sure it's actually after) the line 132 of the original issued error.

In order to reproduce the error issued you can get my sources (with less then 11 posts) by running:

$ git clone https://github.com/taringamberini/taringamberini.github.io.git
$ cd taringamberini.github.io/
$ git checkout source

Then add 5 posts (resulting in 11 posts) in source/_posts/ and run rake generate.

I'm really stuck on this problem: I can't post more then 10 posts!

Please there anybody out there who can help me? Tarin

taringamberini commented 9 years ago

I can't believe it, but in the end I've had the upper hand on this problem: great!

Solution

The Installation documentation says:

add the gem to your Jekyll configuration.

gems:
  - octopress-paginate

but the solution that worked for me needs of a further modification to the Jekyll configuration file (_config.yml), which consists in removing the two lines (of course if they exist):

paginate: 10          # Posts per page on the blog index
paginate_path: "posts/:num"  # Directory base for pagination URLs eg. /posts/2/