Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

undefined method `to_i' for date in jekyll 4.0 #157

Open
guoyunhe opened this issue Apr 28, 2020 · 1 comment
Open

undefined method `to_i' for date in jekyll 4.0 #157

guoyunhe opened this issue Apr 28, 2020 · 1 comment

Comments

@guoyunhe
Copy link

guoyunhe commented Apr 28, 2020

  • I updated to the latest Jekyll (or) if on GitHub Pages to the latest github-pages
  • I ran jekyll doctor to check my configuration
  • I read the contributing document at https://jekyllrb.com/docs/contributing/

My Environment

Software Version(s)
Operating System openSUSE Tumbleweed
jekyll 4.0.0
github-pages No

Expected Behaviour

Should compile

Current Behavior

Compile error:

Configuration file: /home/guo/git/suse/jekyll-theme/_config.yml
            Source: /home/guo/git/suse/jekyll-theme
       Destination: /home/guo/git/suse/jekyll-theme/_site
 Incremental build: disabled. Enable with --incremental
      Generating... 
Traceback (most recent call last):
        33: from /home/guo/git/suse/jekyll-theme/vendor/bundle/ruby/2.6.0/bin/jekyll:23:in `<main>'
        32: from /home/guo/git/suse/jekyll-theme/vendor/bundle/ruby/2.6.0/bin/jekyll:23:in `load'
        31: from /home/guo/git/suse/jekyll-theme/vendor/bundle/ruby/2.6.0/gems/jekyll-4.0.0/exe/jekyll:15:in `<top (required)>'
        30: from /home/guo/git/suse/jekyll-theme/vendor/bundle/ruby/2.6.0/gems/mercenary-0.3.6/lib/mercenary.rb:19:in `program'
        29: from /home/guo/git/suse/jekyll-theme/vendor/bundle/ruby/2.6.0/gems/mercenary-0.3.6/lib/mercenary/program.rb:42:in `go'
        28: from /home/guo/git/suse/jekyll-theme/vendor/bundle/ruby/2.6.0/gems/mercenary-0.3.6/lib/mercenary/command.rb:220:in `execute'
        27: from /home/guo/git/suse/jekyll-theme/vendor/bundle/ruby/2.6.0/gems/mercenary-0.3.6/lib/mercenary/command.rb:220:in `each'
        26: from /home/guo/git/suse/jekyll-theme/vendor/bundle/ruby/2.6.0/gems/mercenary-0.3.6/lib/mercenary/command.rb:220:in `block in execute'
        25: from /home/guo/git/suse/jekyll-theme/vendor/bundle/ruby/2.6.0/gems/jekyll-4.0.0/lib/jekyll/commands/build.rb:18:in `block (2 levels) in init_with_program'
        24: from /home/guo/git/suse/jekyll-theme/vendor/bundle/ruby/2.6.0/gems/jekyll-4.0.0/lib/jekyll/command.rb:89:in `process_with_graceful_fail'
        23: from /home/guo/git/suse/jekyll-theme/vendor/bundle/ruby/2.6.0/gems/jekyll-4.0.0/lib/jekyll/command.rb:89:in `each'
        22: from /home/guo/git/suse/jekyll-theme/vendor/bundle/ruby/2.6.0/gems/jekyll-4.0.0/lib/jekyll/command.rb:89:in `block in process_with_graceful_fail'
        21: from /home/guo/git/suse/jekyll-theme/vendor/bundle/ruby/2.6.0/gems/jekyll-4.0.0/lib/jekyll/commands/build.rb:36:in `process'
        20: from /home/guo/git/suse/jekyll-theme/vendor/bundle/ruby/2.6.0/gems/jekyll-4.0.0/lib/jekyll/commands/build.rb:65:in `build'
        19: from /home/guo/git/suse/jekyll-theme/vendor/bundle/ruby/2.6.0/gems/jekyll-4.0.0/lib/jekyll/command.rb:28:in `process_site'
        18: from /home/guo/git/suse/jekyll-theme/vendor/bundle/ruby/2.6.0/gems/jekyll-4.0.0/lib/jekyll/site.rb:76:in `process'
        17: from /home/guo/git/suse/jekyll-theme/vendor/bundle/ruby/2.6.0/gems/jekyll-4.0.0/lib/jekyll/site.rb:202:in `render'
        16: from /home/guo/git/suse/jekyll-theme/vendor/bundle/ruby/2.6.0/gems/jekyll-4.0.0/lib/jekyll/site.rb:515:in `render_pages'
        15: from /home/guo/git/suse/jekyll-theme/vendor/bundle/ruby/2.6.0/gems/jekyll-4.0.0/lib/jekyll/site.rb:515:in `each'
        14: from /home/guo/git/suse/jekyll-theme/vendor/bundle/ruby/2.6.0/gems/jekyll-4.0.0/lib/jekyll/site.rb:516:in `block in render_pages'
        13: from /home/guo/git/suse/jekyll-theme/vendor/bundle/ruby/2.6.0/gems/jekyll-4.0.0/lib/jekyll/site.rb:523:in `render_regenerated'
        12: from /home/guo/git/suse/jekyll-theme/vendor/bundle/ruby/2.6.0/gems/jekyll-4.0.0/lib/jekyll/renderer.rb:61:in `run'
        11: from /home/guo/git/suse/jekyll-theme/vendor/bundle/ruby/2.6.0/gems/jekyll-4.0.0/lib/jekyll/page.rb:179:in `trigger_hooks'
        10: from /home/guo/git/suse/jekyll-theme/vendor/bundle/ruby/2.6.0/gems/jekyll-4.0.0/lib/jekyll/hooks.rb:101:in `trigger'
         9: from /home/guo/git/suse/jekyll-theme/vendor/bundle/ruby/2.6.0/gems/jekyll-4.0.0/lib/jekyll/hooks.rb:101:in `each'
         8: from /home/guo/git/suse/jekyll-theme/vendor/bundle/ruby/2.6.0/gems/jekyll-4.0.0/lib/jekyll/hooks.rb:102:in `block in trigger'
         7: from /home/guo/git/suse/jekyll-theme/vendor/bundle/ruby/2.6.0/bundler/gems/jekyll-locale-dc5c46cadd09/lib/jekyll-locale.rb:45:in `block in <top (required)>'
         6: from /home/guo/git/suse/jekyll-theme/vendor/bundle/ruby/2.6.0/bundler/gems/jekyll-locale-dc5c46cadd09/lib/jekyll/locale/mixins/support.rb:16:in `hreflangs'
         5: from /home/guo/git/suse/jekyll-theme/vendor/bundle/ruby/2.6.0/bundler/gems/jekyll-locale-dc5c46cadd09/lib/jekyll/locale/mixins/support.rb:30:in `sibling_data'
         4: from /home/guo/git/suse/jekyll-theme/vendor/bundle/ruby/2.6.0/bundler/gems/jekyll-locale-dc5c46cadd09/lib/jekyll/locale/mixins/support.rb:30:in `map'
         3: from /home/guo/git/suse/jekyll-theme/vendor/bundle/ruby/2.6.0/bundler/gems/jekyll-locale-dc5c46cadd09/lib/jekyll/locale/mixins/support.rb:31:in `block in sibling_data'
         2: from /home/guo/git/suse/jekyll-theme/vendor/bundle/ruby/2.6.0/bundler/gems/jekyll-locale-dc5c46cadd09/lib/jekyll/locale/mixins/support.rb:24:in `publish?'
         1: from /home/guo/git/suse/jekyll-theme/vendor/bundle/ruby/2.6.0/gems/jekyll-4.0.0/lib/jekyll/publisher.rb:10:in `publish?'
/home/guo/git/suse/jekyll-theme/vendor/bundle/ruby/2.6.0/gems/jekyll-4.0.0/lib/jekyll/publisher.rb:14:in `hidden_in_the_future?': undefined method `to_i' for #<Date: 2018-01-01 ((2458120j,0s,0n),+0s,2299161j)> (NoMethodError)
Did you mean?  to_s

Code Sample

I am working on this branch https://github.com/openSUSE/jekyll-theme/tree/l10n-feat

bundle exec jekyll serve --trace

Turning off year, month and day archives solved the issue:

jekyll-archives:
  enabled:
    - tags
    - categories
``
@guoyunhe guoyunhe changed the title undefined method `to_i' for date undefined method `to_i' for date in jekyll 4.0 Apr 28, 2020
@ashmaroli
Copy link
Member

At first glance, this issue seems to occur only when you use jekyll-archives and jekyll-locale plugins together. (Let us know if otherwise)..
Regardless, the cause would be because of:

@date ||= begin
args = @title.values.map(&:to_i)
Date.new(*args)
end

Jekyll's documents tend to have an instance of Time as their date attributes.
The fix for this would be to use Time.new(*args) in the code above.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants