feedreader / pluto.starter

planet pluto quick starter kit - (auto-) build your own (static) planet news site from web feeds
Creative Commons Zero v1.0 Universal
12 stars 11 forks source link

error: undefined method `to_time' for nil:NilClass #1

Closed taniwallach closed 4 years ago

taniwallach commented 4 years ago

Running bundle exec pluto build planet.ini -t starter -o build after the initial install gave the error message:

error: undefined method `to_time' for nil:NilClass
taniwallach commented 4 years ago

Verbose error message from: bundle exec pluto --verbose build planet.ini -t starter -o build

*** error: undefined method `to_time' for nil:NilClass

Traceback (most recent call last):
    31: from /usr/local/bin/pluto:23:in `<main>'
    30: from /usr/local/bin/pluto:23:in `load'
    29: from /var/lib/gems/2.5.0/gems/pluto-1.3.4/bin/pluto:5:in `<top (required)>'
    28: from /var/lib/gems/2.5.0/gems/pluto-1.3.4/lib/pluto.rb:24:in `main'
    27: from /var/lib/gems/2.5.0/gems/activesupport-6.0.2.1/lib/active_support/dependencies.rb:325:in `require'
    26: from /var/lib/gems/2.5.0/gems/activesupport-6.0.2.1/lib/active_support/dependencies.rb:291:in `load_dependency'
    25: from /var/lib/gems/2.5.0/gems/activesupport-6.0.2.1/lib/active_support/dependencies.rb:325:in `block in require'
    24: from /var/lib/gems/2.5.0/gems/activesupport-6.0.2.1/lib/active_support/dependencies.rb:325:in `require'
    23: from /var/lib/gems/2.5.0/gems/pluto-1.3.4/lib/pluto/cli/main.rb:390:in `<top (required)>'
    22: from /var/lib/gems/2.5.0/gems/gli-2.19.0/lib/gli/app_support.rb:83:in `run'
    21: from /var/lib/gems/2.5.0/gems/gli-2.19.0/lib/gli/app_support.rb:309:in `call_command'
    20: from /var/lib/gems/2.5.0/gems/gli-2.19.0/lib/gli/app_support.rb:296:in `block in call_command'
    19: from /var/lib/gems/2.5.0/gems/gli-2.19.0/lib/gli/command_support.rb:131:in `execute'
    18: from /var/lib/gems/2.5.0/gems/pluto-1.3.4/lib/pluto/cli/main.rb:270:in `block (2 levels) in <top (required)>'
    17: from /var/lib/gems/2.5.0/gems/pluto-1.3.4/lib/pluto/cli/main.rb:270:in `each'
    16: from /var/lib/gems/2.5.0/gems/pluto-1.3.4/lib/pluto/cli/main.rb:290:in `block (3 levels) in <top (required)>'
    15: from /var/lib/gems/2.5.0/gems/pluto-merge-1.1.0/lib/pluto/merge/formatter.rb:35:in `run'
    14: from /var/lib/gems/2.5.0/gems/pluto-merge-1.1.0/lib/pluto/merge/formatter.rb:79:in `make_for'
    13: from /var/lib/gems/2.5.0/gems/pakman-1.1.0/lib/pakman/erb/templater.rb:25:in `merge_pak'
    12: from /var/lib/gems/2.5.0/gems/pakman-1.1.0/lib/pakman/manifest.rb:47:in `each'
    11: from /var/lib/gems/2.5.0/gems/pakman-1.1.0/lib/pakman/manifest.rb:47:in `each'
    10: from /var/lib/gems/2.5.0/gems/pakman-1.1.0/lib/pakman/manifest.rb:47:in `block in each'
     9: from /var/lib/gems/2.5.0/gems/pakman-1.1.0/lib/pakman/erb/templater.rb:45:in `block in merge_pak'
     8: from /var/lib/gems/2.5.0/gems/pakman-1.1.0/lib/pakman/erb/template.rb:23:in `render'
     7: from /usr/lib/ruby/2.5.0/erb.rb:876:in `result'
     6: from /usr/lib/ruby/2.5.0/erb.rb:876:in `eval'
     5: from (erb):54:in `make_for'
     4: from (erb):54:in `each_with_index'
     3: from /var/lib/gems/2.5.0/gems/activerecord-6.0.2.1/lib/active_record/relation/delegation.rb:85:in `each'
     2: from /var/lib/gems/2.5.0/gems/activerecord-6.0.2.1/lib/active_record/relation/delegation.rb:85:in `each'
     1: from (erb):61:in `block in make_for'
/var/lib/gems/2.5.0/gems/textutils-1.4.0/lib/textutils/helper/date_helper.rb:13:in `time_ago_in_words': undefined method `to_time' for nil:NilClass (NoMethodError)
taniwallach commented 4 years ago

If I delete the lines using time_ago_in_words from planet-starter/planet.starter.html.erb I then get an error:

*** error: undefined method `strftime' for nil:NilClass

Traceback (most recent call last):
    31: from /usr/local/bin/pluto:23:in `<main>'
    30: from /usr/local/bin/pluto:23:in `load'
    29: from /var/lib/gems/2.5.0/gems/pluto-1.3.4/bin/pluto:5:in `<top (required)>'
    28: from /var/lib/gems/2.5.0/gems/pluto-1.3.4/lib/pluto.rb:24:in `main'
    27: from /var/lib/gems/2.5.0/gems/activesupport-6.0.2.1/lib/active_support/dependencies.rb:325:in `require'
    26: from /var/lib/gems/2.5.0/gems/activesupport-6.0.2.1/lib/active_support/dependencies.rb:291:in `load_dependency'
    25: from /var/lib/gems/2.5.0/gems/activesupport-6.0.2.1/lib/active_support/dependencies.rb:325:in `block in require'
    24: from /var/lib/gems/2.5.0/gems/activesupport-6.0.2.1/lib/active_support/dependencies.rb:325:in `require'
    23: from /var/lib/gems/2.5.0/gems/pluto-1.3.4/lib/pluto/cli/main.rb:390:in `<top (required)>'
    22: from /var/lib/gems/2.5.0/gems/gli-2.19.0/lib/gli/app_support.rb:83:in `run'
    21: from /var/lib/gems/2.5.0/gems/gli-2.19.0/lib/gli/app_support.rb:309:in `call_command'
    20: from /var/lib/gems/2.5.0/gems/gli-2.19.0/lib/gli/app_support.rb:296:in `block in call_command'
    19: from /var/lib/gems/2.5.0/gems/gli-2.19.0/lib/gli/command_support.rb:131:in `execute'
    18: from /var/lib/gems/2.5.0/gems/pluto-1.3.4/lib/pluto/cli/main.rb:270:in `block (2 levels) in <top (required)>'
    17: from /var/lib/gems/2.5.0/gems/pluto-1.3.4/lib/pluto/cli/main.rb:270:in `each'
    16: from /var/lib/gems/2.5.0/gems/pluto-1.3.4/lib/pluto/cli/main.rb:290:in `block (3 levels) in <top (required)>'
    15: from /var/lib/gems/2.5.0/gems/pluto-merge-1.1.0/lib/pluto/merge/formatter.rb:35:in `run'
    14: from /var/lib/gems/2.5.0/gems/pluto-merge-1.1.0/lib/pluto/merge/formatter.rb:79:in `make_for'
    13: from /var/lib/gems/2.5.0/gems/pakman-1.1.0/lib/pakman/erb/templater.rb:25:in `merge_pak'
    12: from /var/lib/gems/2.5.0/gems/pakman-1.1.0/lib/pakman/manifest.rb:47:in `each'
    11: from /var/lib/gems/2.5.0/gems/pakman-1.1.0/lib/pakman/manifest.rb:47:in `each'
    10: from /var/lib/gems/2.5.0/gems/pakman-1.1.0/lib/pakman/manifest.rb:47:in `block in each'
     9: from /var/lib/gems/2.5.0/gems/pakman-1.1.0/lib/pakman/erb/templater.rb:45:in `block in merge_pak'
     8: from /var/lib/gems/2.5.0/gems/pakman-1.1.0/lib/pakman/erb/template.rb:23:in `render'
     7: from /usr/lib/ruby/2.5.0/erb.rb:876:in `result'
     6: from /usr/lib/ruby/2.5.0/erb.rb:876:in `eval'
     5: from (erb):77:in `make_for'
     4: from /var/lib/gems/2.5.0/gems/pluto-models-1.5.6/lib/pluto/models/utils.rb:16:in `each'
     3: from /var/lib/gems/2.5.0/gems/activerecord-6.0.2.1/lib/active_record/relation/delegation.rb:85:in `each'
     2: from /var/lib/gems/2.5.0/gems/activerecord-6.0.2.1/lib/active_record/relation/delegation.rb:85:in `each'
     1: from /var/lib/gems/2.5.0/gems/pluto-models-1.5.6/lib/pluto/models/utils.rb:38:in `block in each'
(erb):84:in `block in make_for': undefined method `strftime' for nil:NilClass (NoMethodError)

After also deleting the lines using strftime from planet-starter/planet.starter.html.erb the build process completes without any errors and output was created.

geraldb commented 4 years ago

Thanks for the details error report and trying to find the template variable that breaks everything. Sorry I was breaking things while improving the feed machinery. Most (atom) feeds do NOT have a published date (but only an updated date). item.published no longer falls back to item.updated (only item.updated falls back to item.published). Anyways, long story short: The fix is to change item.published to item.updated. I have updated the starter template in the repo. Please, update and retry: Thank you again for reporting.

PS: Thinking it through I guess it's too late or too strict (draconian) and I add the fallback back with the next update (will take some days, sorry). Anways, using item.updated is nevertheless the recommended best practice. In the future (with the next update) to avoid confusion what date to use I will add a new item.date to make it simpler / easier that is an alias for item.updated.

taniwallach commented 4 years ago

I confirm that manually replacing item.published by item.updated in planet-starter/planet.starter.html.erb solves the issue.

Thanks for the very prompt response. I'll leave the issue open until the long-term fix is made.

taniwallach commented 4 years ago

Fixed in commit https://github.com/feedreader/pluto.starter/commit/7b3b8c476b94671343f653e8967409ce7a75e1a5

geraldb commented 4 years ago

Thanks for reporting and closing - note: the pluto-models gem has the changes committed (to make the "old" published working again too) plus the new date attribute / variable - I try to get the pluto gems updated / published in the upcoming week. Cheers.