Rails 4.2.5.1: NoMethodError: undefined method `paths' for nil:NilClass
samstarling opened this issue · 23 comments
I'm getting the following error after upgrading from Rails 4.2.5 to 4.2.5.1.
Any ideas what might be wrong?
NoMethodError: undefined method `paths' for nil:NilClass
/Users/samstarling/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/requirejs-rails-1.0.0/lib/tasks/requirejs-rails_tasks.rake:55:in `block (2 levels) in <top (required)>'
/Users/samstarling/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/rake-10.5.0/lib/rake/task.rb:240:in `call'
/Users/samstarling/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/rake-10.5.0/lib/rake/task.rb:240:in `block in execute'
/Users/samstarling/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/rake-10.5.0/lib/rake/task.rb:235:in `each'
/Users/samstarling/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/rake-10.5.0/lib/rake/task.rb:235:in `execute'
/Users/samstarling/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/rake-10.5.0/lib/rake/task.rb:179:in `block in invoke_with_call_chain'
/Users/samstarling/.rbenv/versions/2.2.0/lib/ruby/2.2.0/monitor.rb:211:in `mon_synchronize'
/Users/samstarling/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/rake-10.5.0/lib/rake/task.rb:172:in `invoke_with_call_chain'
/Users/samstarling/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/rake-10.5.0/lib/rake/task.rb:201:in `block in invoke_prerequisites'
/Users/samstarling/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/rake-10.5.0/lib/rake/task.rb:199:in `each'
/Users/samstarling/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/rake-10.5.0/lib/rake/task.rb:199:in `invoke_prerequisites'
/Users/samstarling/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/rake-10.5.0/lib/rake/task.rb:178:in `block in invoke_with_call_chain'
/Users/samstarling/.rbenv/versions/2.2.0/lib/ruby/2.2.0/monitor.rb:211:in `mon_synchronize'
/Users/samstarling/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/rake-10.5.0/lib/rake/task.rb:172:in `invoke_with_call_chain'
/Users/samstarling/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/rake-10.5.0/lib/rake/task.rb:201:in `block in invoke_prerequisites'
/Users/samstarling/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/rake-10.5.0/lib/rake/task.rb:199:in `each'
/Users/samstarling/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/rake-10.5.0/lib/rake/task.rb:199:in `invoke_prerequisites'
/Users/samstarling/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/rake-10.5.0/lib/rake/task.rb:178:in `block in invoke_with_call_chain'
/Users/samstarling/.rbenv/versions/2.2.0/lib/ruby/2.2.0/monitor.rb:211:in `mon_synchronize'
/Users/samstarling/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/rake-10.5.0/lib/rake/task.rb:172:in `invoke_with_call_chain'
/Users/samstarling/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/rake-10.5.0/lib/rake/task.rb:201:in `block in invoke_prerequisites'
/Users/samstarling/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/rake-10.5.0/lib/rake/task.rb:199:in `each'
/Users/samstarling/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/rake-10.5.0/lib/rake/task.rb:199:in `invoke_prerequisites'
/Users/samstarling/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/rake-10.5.0/lib/rake/task.rb:178:in `block in invoke_with_call_chain'
/Users/samstarling/.rbenv/versions/2.2.0/lib/ruby/2.2.0/monitor.rb:211:in `mon_synchronize'
/Users/samstarling/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/rake-10.5.0/lib/rake/task.rb:172:in `invoke_with_call_chain'
/Users/samstarling/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/rake-10.5.0/lib/rake/task.rb:165:in `invoke'
/Users/samstarling/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/rake-10.5.0/lib/rake/application.rb:150:in `invoke_task'
/Users/samstarling/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/rake-10.5.0/lib/rake/application.rb:106:in `block (2 levels) in top_level'
/Users/samstarling/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/rake-10.5.0/lib/rake/application.rb:106:in `each'
/Users/samstarling/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/rake-10.5.0/lib/rake/application.rb:106:in `block in top_level'
/Users/samstarling/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/rake-10.5.0/lib/rake/application.rb:115:in `run_with_threads'
/Users/samstarling/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/rake-10.5.0/lib/rake/application.rb:100:in `top_level'
/Users/samstarling/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/rake-10.5.0/lib/rake/application.rb:78:in `block in run'
/Users/samstarling/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/rake-10.5.0/lib/rake/application.rb:176:in `standard_exception_handling'
/Users/samstarling/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/rake-10.5.0/lib/rake/application.rb:75:in `run'
/Users/samstarling/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/rake-10.5.0/bin/rake:33:in `<top (required)>'
/Users/samstarling/.rbenv/versions/2.2.0/bin/rake:23:in `load'
/Users/samstarling/.rbenv/versions/2.2.0/bin/rake:23:in `<main>'
Tasks: TOP => requirejs:precompile:all => requirejs:precompile:digestify_and_compress => requirejs:precompile:run_rjs => requirejs:setup
rake aborted!
Command failed with status (1): [/Users/samstarling/.rbenv/versions/2.2.0/b...]
/Users/samstarling/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/rake-10.5.0/lib/rake/file_utils.rb:66:in `block in create_shell_runner'
/Users/samstarling/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/rake-10.5.0/lib/rake/file_utils.rb:57:in `call'
/Users/samstarling/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/rake-10.5.0/lib/rake/file_utils.rb:57:in `sh'
/Users/samstarling/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/rake-10.5.0/lib/rake/file_utils_ext.rb:37:in `sh'
/Users/samstarling/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/rake-10.5.0/lib/rake/file_utils.rb:94:in `ruby'
/Users/samstarling/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/rake-10.5.0/lib/rake/file_utils_ext.rb:37:in `ruby'
/Users/samstarling/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/requirejs-rails-1.0.0/lib/tasks/requirejs-rails_tasks.rake:18:in `ruby_rake_task'
/Users/samstarling/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/requirejs-rails-1.0.0/lib/tasks/requirejs-rails_tasks.rake:83:in `block (3 levels) in <top (required)>'
/Users/samstarling/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/rake-10.5.0/lib/rake/task.rb:240:in `call'
/Users/samstarling/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/rake-10.5.0/lib/rake/task.rb:240:in `block in execute'
/Users/samstarling/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/rake-10.5.0/lib/rake/task.rb:235:in `each'
/Users/samstarling/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/rake-10.5.0/lib/rake/task.rb:235:in `execute'
/Users/samstarling/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/rake-10.5.0/lib/rake/task.rb:179:in `block in invoke_with_call_chain'
/Users/samstarling/.rbenv/versions/2.2.0/lib/ruby/2.2.0/monitor.rb:211:in `mon_synchronize'
/Users/samstarling/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/rake-10.5.0/lib/rake/task.rb:172:in `invoke_with_call_chain'
/Users/samstarling/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/rake-10.5.0/lib/rake/task.rb:201:in `block in invoke_prerequisites'
/Users/samstarling/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/rake-10.5.0/lib/rake/task.rb:199:in `each'
/Users/samstarling/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/rake-10.5.0/lib/rake/task.rb:199:in `invoke_prerequisites'
/Users/samstarling/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/rake-10.5.0/lib/rake/task.rb:178:in `block in invoke_with_call_chain'
/Users/samstarling/.rbenv/versions/2.2.0/lib/ruby/2.2.0/monitor.rb:211:in `mon_synchronize'
/Users/samstarling/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/rake-10.5.0/lib/rake/task.rb:172:in `invoke_with_call_chain'
/Users/samstarling/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/rake-10.5.0/lib/rake/task.rb:165:in `invoke'
/Users/samstarling/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/rake-10.5.0/lib/rake/application.rb:150:in `invoke_task'
/Users/samstarling/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/rake-10.5.0/lib/rake/application.rb:106:in `block (2 levels) in top_level'
/Users/samstarling/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/rake-10.5.0/lib/rake/application.rb:106:in `each'
/Users/samstarling/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/rake-10.5.0/lib/rake/application.rb:106:in `block in top_level'
/Users/samstarling/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/rake-10.5.0/lib/rake/application.rb:115:in `run_with_threads'
/Users/samstarling/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/rake-10.5.0/lib/rake/application.rb:100:in `top_level'
/Users/samstarling/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/rake-10.5.0/lib/rake/application.rb:78:in `block in run'
/Users/samstarling/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/rake-10.5.0/lib/rake/application.rb:176:in `standard_exception_handling'
/Users/samstarling/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/rake-10.5.0/lib/rake/application.rb:75:in `run'
/Users/samstarling/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/rake-10.5.0/bin/rake:33:in `<top (required)>'
/Users/samstarling/.rbenv/versions/2.2.0/bin/rake:23:in `load'
/Users/samstarling/.rbenv/versions/2.2.0/bin/rake:23:in `<main>'
Tasks: TOP => assets:precompile => requires:precompile:external
@samstarling I had a similar issue some time back, try downgrading your version of sprocket-rails
to 2.x
, that fixed it for me
@IceDragon200 You're right - downgrading sprockets-rails
to 2.3.3 fixed this.
This seems to be the issue. rails/sprockets-rails#237
Thanks all for the reports. I'm looking to have a fix out in the upcoming week.
I have the same issue... Hope this can get fixed!
I'm running still running into this problem, I upgraded Rails to 4.2.6 which depends on sprockets (>= 3.0.0). Is there a way to hotfix this so I can deploy my security updates?
When I try to downgrade sprockets-rails
to 2.3.3
I run into these kinds of errors:
Bundler could not find compatible versions for gem "tilt":
In snapshot (Gemfile.lock):
tilt (= 2.0.1)
In Gemfile:
haml was resolved to 4.0.7, which depends on
tilt
sass-rails (~> 5.0) was resolved to 5.0.4, which depends on
tilt (< 3, >= 1.1)
delayed_job_web was resolved to 1.2.10, which depends on
sinatra (>= 1.4.4) was resolved to 1.4.6, which depends on
tilt (< 3, >= 1.3)
sprockets (= 2.3.3) was resolved to 2.3.3, which depends on
tilt (!= 1.3.0, ~> 1.1)
Running `bundle update` will rebuild your snapshot from scratch, using only
the gems in your Gemfile, which may resolve the conflict.
I tried downgrading a lot of gems, but bundler can't seem to solve the dependency issues. @carsomyr are you working on a fix? I would love to help!
All, I've been very busy lately delivering a major feature. I'll try to look into this on Saturday.
No problem @carsomyr, if you need a hand let me know. For now I removed this Gem and switched to using plain require-js
, so the urgency is gone for me.
You can replace Raiils.application.assets
with Rails.application.assets_manifest.files.values.map{|v| v['logical_path']}
(ref. https://github.com/rails/sprockets-rails/blob/6f5a37cfc7e5e71e2a7e1d1c002448dc374f1324/lib/sprockets/railtie.rb#L142-L148)
@matfiz thanks for the comment. But what do you mean? Where should I replace this?
I got this result for the manifest files:
>> Rails.application.assets_manifest.files
=> {}
@jankeesvw have you checked in production env?
@matfiz no only in development mode, how do you overwrite this? Add something to an initializer?
The assets_manifest reads the Sprockets manifest file from compiled assets - these are available only in production. AFAIK you can emulate it in development by setting config.assets.compile = false
in development.rb
.
Thanks for the quick response @matfiz, can you give me an concrete example of how we can fix this error?
Hi @matfiz, would be great if you have some more information on your proposed solution! Thanks! ✨
I've just run into this issue as well. Is there any update on suggested resolutions?
Is there someone with a solution / work around?
@jankeesvw I switched my app to using modulejs
instead of requirejs
, following this pattern:
https://reinteractive.net/posts/172-a-better-way-to-modularise-your-js-in-rails
It has been working well for me, and fits more comfortably into the asset pipeline.
@ijdickinson that looks good! Did it require a lot of rewriting?
I would rather not rewrite the app, there is quite some JavaScript in my application.
@jankeesvw No, it was very straightforward. The signature for the modulejs require
function is almost the same as the requirejs require
, and then you need to rely on the asset pipeline to load the JavaScript manifest in the usual way - modulejs doesn't do any file management like requirejs does. Modulejs isn't nearly as capable as requirejs, so if you're relying on aliasing and those kinds of advanced features it won't help you.
We probably shouldn't continue this discussion in this issue thread - it's going a bit off-topic. Please feel free to pm me if you want more details!
For me this appeared to be a problem with a sprockets upgrade. We needed to upgrade to sprockets 3 and there were multiple errors related to asset precompile.
The cause of the actual error is essentially that it's trying to access:
Rails.application.assets.paths.dup
Unfortunately in sprockets along the way this no longer works. Instead of accessing application.assets.path, the valid location now appears to be application.config.assets.
Although this was able to get us further, there are many more sprockets problems. I'll see if I can clean things up a bit and test my changes against sprockets 2, but my company is now using:
https://github.com/MediaFactual/requirejs-rails/tree/rails5-1-0-0
or with bundler:
gem 'requirejs-rails', :git => 'https://github.com/MediaFactual/requirejs-rails.git', :branch => 'rails5-1-0-0'
If these changes appear to be stable on our systems, I'll submit a pull request.