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

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

Closed
taniwallach opened this issue Feb 12, 2020 · 6 comments
Closed

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

taniwallach opened this issue Feb 12, 2020 · 6 comments

Comments

@taniwallach
Copy link

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
Copy link
Author

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
Copy link
Author

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
Copy link
Member

geraldb commented Feb 13, 2020

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
Copy link
Author

taniwallach commented Feb 13, 2020

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
Copy link
Author

Fixed in commit 7b3b8c4

@geraldb
Copy link
Member

geraldb commented Feb 14, 2020

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.

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