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

[4.0.1] undefined method `+' for nil:NilClass #683

Closed
afuno opened this issue Jun 5, 2020 · 13 comments
Closed

[4.0.1] undefined method `+' for nil:NilClass #683

afuno opened this issue Jun 5, 2020 · 13 comments

Comments

@afuno
Copy link

afuno commented Jun 5, 2020

Rails 6.0.3.1, Ruby 2.6.6.


After today's update deployment began to fall:

[4/4] Building fresh packages...
Done in 4.47s.
I, [2020-06-05T08:24:43.028785 #2084]  INFO -- : Writing /tmp/build/public/assets/active_admin-312e30985f3b0561c5db85eaba9b50b1d2c6fcbcff0e0cd5ae0862f13ef86223796473.css
I, [2020-06-05T08:24:43.029586 #2084]  INFO -- : Writing /tmp/build/public/assets/active_admin-312e30985f3b0561c5db85eaba9b50b1d2c6fcbcff0e0cd5ae0862f13ef86223796473.css.gz
I, [2020-06-05T08:24:43.030653 #2084]  INFO -- : Writing /tmp/build/public/assets/manifest-312e3075a11da44c802486bc6f65640aa48a730f0f684c5c07a42ba3cd1735eb3fb070.js
I, [2020-06-05T08:24:43.031240 #2084]  INFO -- : Writing /tmp/build/public/assets/manifest-312e3075a11da44c802486bc6f65640aa48a730f0f684c5c07a42ba3cd1735eb3fb070.js.gz
rake aborted!
NoMethodError: undefined method `+' for nil:NilClass
/tmp/build/vendor/bundle/ruby/2.6.0/gems/sprockets-4.0.1/lib/sprockets/asset.rb:138:in `etag'
/tmp/build/vendor/bundle/ruby/2.6.0/gems/sprockets-4.0.1/lib/sprockets/asset.rb:67:in `block in digest_path'
/tmp/build/vendor/bundle/ruby/2.6.0/gems/sprockets-4.0.1/lib/sprockets/asset.rb:67:in `sub'
/tmp/build/vendor/bundle/ruby/2.6.0/gems/sprockets-4.0.1/lib/sprockets/asset.rb:67:in `digest_path'
/tmp/build/vendor/bundle/ruby/2.6.0/gems/sprockets-4.0.1/lib/sprockets/manifest.rb:175:in `block in compile'
/tmp/build/vendor/bundle/ruby/2.6.0/gems/sprockets-4.0.1/lib/sprockets/manifest.rb:173:in `each'
/tmp/build/vendor/bundle/ruby/2.6.0/gems/sprockets-4.0.1/lib/sprockets/manifest.rb:173:in `compile'
/tmp/build/vendor/bundle/ruby/2.6.0/gems/sprockets-rails-3.2.1/lib/sprockets/rails/task.rb:68:in `block (3 levels) in define'
/tmp/build/vendor/bundle/ruby/2.6.0/gems/sprockets-4.0.1/lib/rake/sprocketstask.rb:148:in `with_logger'
/tmp/build/vendor/bundle/ruby/2.6.0/gems/sprockets-rails-3.2.1/lib/sprockets/rails/task.rb:67:in `block (2 levels) in define'
/tmp/build/vendor/bundle/ruby/2.6.0/gems/rake-13.0.1/exe/rake:27:in `<top (required)>'
Tasks: TOP => assets:precompile
(See full trace by running task with --trace)

New assets (active_admin, manifest) were compiled due to an update.

I rolled back to version 4.0.0 - everything was successfully deployed with it.

Related issue: #682

@afuno afuno changed the title undefined method `+' for nil:NilClass [4.0.1] undefined method `+' for nil:NilClass Jun 5, 2020
@alliedarmour
Copy link

alliedarmour commented Jun 5, 2020

Same problem here!

In my case the problem comes from the manifest.json.erb file which I use to let my application run as a PWA.

That line is throwing the error:

"src": "<%= asset_path('icon_small.png') %>",

Rails: 6.0.3.1
Ruby: 2.6.5

@thorpj
Copy link

thorpj commented Jun 5, 2020

Was about to post an issue myself, instead I'll add the info here:

Rails: 5.2.4.3
Ruby: 2.5.1p57
Host: Ubuntu Server 18.04.4

After running:

bundle update
RAILS_ENV=production RAILS_SERVE_STATIC_FILES=off rails assets:precompile

A NoMethodError was raised for sprockets-4.0.1/lib/sprockets/asset.rb:138 in 'etag'
NoMethodError: undefined method '+' for nil:NilClass
Full error: https://gist.github.com/thorpj/3fb472d2a57afbb88bb0d347d9b508c8

The relevant method in assets.rb:

def etag                                                                                                                                                                                                                                                                         
    DigestUtils.pack_hexdigest(environment_version + digest)                                                                                                                                                                                                                     
end 
  • Sprockets went from 4.0.0 to 4.0.1 in that bundle update.
  • I had also just pushed some updates to this rails server. The changes were very minor and no changes were made to my CSS or JS. I call assets:precompile every time I update this server,

image

@Eric-Guo
Copy link

Eric-Guo commented Jun 5, 2020

Caused by #678 and if change config/initializers/assets.rb, at least resolved at my project.

-Rails.application.config.assets.version = '1.0'
+Rails.application.config.assets.version = 'v1.0'

@maltesa
Copy link

maltesa commented Jun 5, 2020

Caused by #678 and if change config/initializers/assets.rb, at least resolved at my project.

-Rails.application.config.assets.version = '1.0'
+Rails.application.config.assets.version = 'v1.0'

That solved the issue for me. Thanks a lot @Eric-Guo

@jeffreycastro
Copy link

Caused by #678 and if change config/initializers/assets.rb, at least resolved at my project.

-Rails.application.config.assets.version = '1.0'
+Rails.application.config.assets.version = 'v1.0'

This worked for me as well.
But does anyone know when we need to change the version? I dont want to wait for Heroku deploy to fail first before updating this value.

@afuno
Copy link
Author

afuno commented Jun 5, 2020

Caused by #678 and if change config/initializers/assets.rb, at least resolved at my project.

-Rails.application.config.assets.version = '1.0'
+Rails.application.config.assets.version = 'v1.0'

That solved the issue for me. Thanks a lot @Eric-Guo

This should not be a solution.
Thousands of projects have to change this line? No.
The solution must be inside this library.

@rafaelfranca
Copy link
Member

Could you try the master branch to see if it is fixed? I'll release 4.0.2 when it is confirmed

@thibaudgg
Copy link

4.0.2 works for me, thanks for the fix. 👍

@markets
Copy link

markets commented Jun 5, 2020

@rafaelfranca just tried master branch and it seems resolved for me too. Thanks!

@matteeyah
Copy link
Contributor

matteeyah commented Jun 5, 2020

I created a PR to make master green again to unblock the 4.0.2 release that has thix fix - #685

@andrewhood125
Copy link

andrewhood125 commented Jun 5, 2020

gem "sprockets", github: 'rails/sprockets' # shouldn't be needed anymore

$ bundle update

For those following along. Thanks for fixing this so quickly!

@rafaelfranca
Copy link
Member

4.0.2 was released

@afuno
Copy link
Author

afuno commented Jun 5, 2020

Successfully. Thanks.

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