jwhitley / requirejs-rails

RequireJS support for your Rails 3 or 4 application
MIT License
592 stars 201 forks source link

Problem with 0.9.4 and rake precompile #188

Closed AgtLucas closed 10 years ago

AgtLucas commented 10 years ago

Howdy guys,

I'm struggling with rake assets:precompile using requirejs-rails 0.9.4, but with 0.9.3 version everything works fine.

My setup:

OS X 10.9.4
Ruby version: 2.1.2p95
Rails version: 4.1.6 (was 4.1.4 until yesterday)
# config/requirejs.yml
waitSeconds: 5

paths:
  delta: 'delta'
  application: 'application'

  jquery: 'jquery/jquery'
  jquery_ujs: 'jquery_ujs'
  turbolinks: 'turbolinks'

shim:

  jquery:
    exports: 'jquery'
  jquery_ujs:
    deps: ['jquery']

modules:
  - name: 'application'
wrap: true

Error's log:

** Invoke assets:precompile (first_time)
** Invoke assets:environment (first_time)
** Execute assets:environment
** Invoke environment (first_time)
** Execute environment
** Invoke requirejs:precompile:external (first_time)
** Invoke requirejs:test_node (first_time)
** Execute requirejs:test_node
** Execute requirejs:precompile:external
/Users/AgtLucas/.rvm/rubies/ruby-2.1.2/bin/ruby /Users/AgtLucas/.rvm/gems/ruby-2.1.2/bin/rake requirejs:precompile:all RAILS_ENV=production RAILS_GROUPS=assets --trace
** Invoke requirejs:precompile:all (first_time)
** Invoke requirejs:precompile:prepare_source (first_time)
** Invoke requirejs:setup (first_time)
** Invoke assets:environment (first_time)
** Execute assets:environment
** Invoke environment (first_time)
** Execute environment
** Execute requirejs:setup
** Invoke requirejs:clean (first_time)
** Invoke requirejs:setup
** Execute requirejs:clean
** Execute requirejs:precompile:prepare_source
rake aborted!
NoMethodError: undefined method `mtime' for nil:NilClass
/Users/AgtLucas/.rvm/gems/ruby-2.1.2/gems/sprockets-2.11.0/lib/sprockets/asset.rb:43:in `initialize'
/Users/AgtLucas/.rvm/gems/ruby-2.1.2/gems/sprockets-2.11.0/lib/sprockets/bundled_asset.rb:14:in `initialize'
/Users/AgtLucas/.rvm/gems/ruby-2.1.2/gems/sprockets-2.11.0/lib/sprockets/base.rb:377:in `new'
/Users/AgtLucas/.rvm/gems/ruby-2.1.2/gems/sprockets-2.11.0/lib/sprockets/base.rb:377:in `build_asset'
/Users/AgtLucas/.rvm/gems/ruby-2.1.2/gems/sprockets-2.11.0/lib/sprockets/index.rb:94:in `block in build_asset'
/Users/AgtLucas/.rvm/gems/ruby-2.1.2/gems/sprockets-2.11.0/lib/sprockets/caching.rb:51:in `cache_asset'
/Users/AgtLucas/.rvm/gems/ruby-2.1.2/gems/sprockets-2.11.0/lib/sprockets/index.rb:93:in `build_asset'
/Users/AgtLucas/.rvm/gems/ruby-2.1.2/gems/sprockets-2.11.0/lib/sprockets/base.rb:287:in `find_asset'
/Users/AgtLucas/.rvm/gems/ruby-2.1.2/gems/sprockets-2.11.0/lib/sprockets/index.rb:61:in `find_asset'
/Users/AgtLucas/.rvm/gems/ruby-2.1.2/gems/sprockets-2.11.0/lib/sprockets/environment.rb:75:in `find_asset'
/Users/AgtLucas/.rvm/gems/ruby-2.1.2/bundler/gems/requirejs-rails-c46bd8f631e5/lib/tasks/requirejs-rails_tasks.rake:112:in `block (4 levels) in <top (required)>'
/Users/AgtLucas/.rvm/gems/ruby-2.1.2/gems/sprockets-2.11.0/lib/sprockets/base.rb:341:in `block in each_logical_path'
/Users/AgtLucas/.rvm/gems/ruby-2.1.2/gems/sprockets-2.11.0/lib/sprockets/base.rb:324:in `block (2 levels) in each_file'
/Users/AgtLucas/.rvm/gems/ruby-2.1.2/gems/sprockets-2.11.0/lib/sprockets/base.rb:314:in `each'
/Users/AgtLucas/.rvm/gems/ruby-2.1.2/gems/sprockets-2.11.0/lib/sprockets/base.rb:314:in `each_entry'
/Users/AgtLucas/.rvm/gems/ruby-2.1.2/gems/sprockets-2.11.0/lib/sprockets/base.rb:322:in `block in each_file'
/Users/AgtLucas/.rvm/gems/ruby-2.1.2/gems/sprockets-2.11.0/lib/sprockets/base.rb:321:in `each'
/Users/AgtLucas/.rvm/gems/ruby-2.1.2/gems/sprockets-2.11.0/lib/sprockets/base.rb:321:in `each_file'
/Users/AgtLucas/.rvm/gems/ruby-2.1.2/gems/sprockets-2.11.0/lib/sprockets/base.rb:335:in `each_logical_path'
/Users/AgtLucas/.rvm/gems/ruby-2.1.2/bundler/gems/requirejs-rails-c46bd8f631e5/lib/tasks/requirejs-rails_tasks.rake:105:in `block (3 levels) in <top (required)>'
/Users/AgtLucas/.rvm/gems/ruby-2.1.2/gems/rake-10.3.2/lib/rake/task.rb:240:in `call'
/Users/AgtLucas/.rvm/gems/ruby-2.1.2/gems/rake-10.3.2/lib/rake/task.rb:240:in `block in execute'
/Users/AgtLucas/.rvm/gems/ruby-2.1.2/gems/rake-10.3.2/lib/rake/task.rb:235:in `each'
/Users/AgtLucas/.rvm/gems/ruby-2.1.2/gems/rake-10.3.2/lib/rake/task.rb:235:in `execute'
/Users/AgtLucas/.rvm/gems/ruby-2.1.2/gems/rake-10.3.2/lib/rake/task.rb:179:in `block in invoke_with_call_chain'
/Users/AgtLucas/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/monitor.rb:211:in `mon_synchronize'
/Users/AgtLucas/.rvm/gems/ruby-2.1.2/gems/rake-10.3.2/lib/rake/task.rb:172:in `invoke_with_call_chain'
/Users/AgtLucas/.rvm/gems/ruby-2.1.2/gems/rake-10.3.2/lib/rake/task.rb:201:in `block in invoke_prerequisites'
/Users/AgtLucas/.rvm/gems/ruby-2.1.2/gems/rake-10.3.2/lib/rake/task.rb:199:in `each'
/Users/AgtLucas/.rvm/gems/ruby-2.1.2/gems/rake-10.3.2/lib/rake/task.rb:199:in `invoke_prerequisites'
/Users/AgtLucas/.rvm/gems/ruby-2.1.2/gems/rake-10.3.2/lib/rake/task.rb:178:in `block in invoke_with_call_chain'
/Users/AgtLucas/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/monitor.rb:211:in `mon_synchronize'
/Users/AgtLucas/.rvm/gems/ruby-2.1.2/gems/rake-10.3.2/lib/rake/task.rb:172:in `invoke_with_call_chain'
/Users/AgtLucas/.rvm/gems/ruby-2.1.2/gems/rake-10.3.2/lib/rake/task.rb:165:in `invoke'
/Users/AgtLucas/.rvm/gems/ruby-2.1.2/gems/rake-10.3.2/lib/rake/application.rb:150:in `invoke_task'
/Users/AgtLucas/.rvm/gems/ruby-2.1.2/gems/rake-10.3.2/lib/rake/application.rb:106:in `block (2 levels) in top_level'
/Users/AgtLucas/.rvm/gems/ruby-2.1.2/gems/rake-10.3.2/lib/rake/application.rb:106:in `each'
/Users/AgtLucas/.rvm/gems/ruby-2.1.2/gems/rake-10.3.2/lib/rake/application.rb:106:in `block in top_level'
/Users/AgtLucas/.rvm/gems/ruby-2.1.2/gems/rake-10.3.2/lib/rake/application.rb:115:in `run_with_threads'
/Users/AgtLucas/.rvm/gems/ruby-2.1.2/gems/rake-10.3.2/lib/rake/application.rb:100:in `top_level'
/Users/AgtLucas/.rvm/gems/ruby-2.1.2/gems/rake-10.3.2/lib/rake/application.rb:78:in `block in run'
/Users/AgtLucas/.rvm/gems/ruby-2.1.2/gems/rake-10.3.2/lib/rake/application.rb:176:in `standard_exception_handling'
/Users/AgtLucas/.rvm/gems/ruby-2.1.2/gems/rake-10.3.2/lib/rake/application.rb:75:in `run'
/Users/AgtLucas/.rvm/gems/ruby-2.1.2/gems/rake-10.3.2/bin/rake:33:in `<top (required)>'
/Users/AgtLucas/.rvm/gems/ruby-2.1.2/bin/rake:23:in `load'
/Users/AgtLucas/.rvm/gems/ruby-2.1.2/bin/rake:23:in `<main>'
Tasks: TOP => requirejs:precompile:all => requirejs:precompile:prepare_source
rake aborted!
Command failed with status (1): [/Users/AgtLucas/.rvm/rubies/ruby-2.1.2/bin...]
/Users/AgtLucas/.rvm/gems/ruby-2.1.2/gems/rake-10.3.2/lib/rake/file_utils.rb:54:in `block in create_shell_runner'
/Users/AgtLucas/.rvm/gems/ruby-2.1.2/gems/rake-10.3.2/lib/rake/file_utils.rb:45:in `call'
/Users/AgtLucas/.rvm/gems/ruby-2.1.2/gems/rake-10.3.2/lib/rake/file_utils.rb:45:in `sh'
/Users/AgtLucas/.rvm/gems/ruby-2.1.2/gems/rake-10.3.2/lib/rake/file_utils_ext.rb:37:in `sh'
/Users/AgtLucas/.rvm/gems/ruby-2.1.2/gems/rake-10.3.2/lib/rake/file_utils.rb:82:in `ruby'
/Users/AgtLucas/.rvm/gems/ruby-2.1.2/gems/rake-10.3.2/lib/rake/file_utils_ext.rb:37:in `ruby'
/Users/AgtLucas/.rvm/gems/ruby-2.1.2/bundler/gems/requirejs-rails-c46bd8f631e5/lib/tasks/requirejs-rails_tasks.rake:19:in `ruby_rake_task'
/Users/AgtLucas/.rvm/gems/ruby-2.1.2/bundler/gems/requirejs-rails-c46bd8f631e5/lib/tasks/requirejs-rails_tasks.rake:86:in `block (3 levels) in <top (required)>'
/Users/AgtLucas/.rvm/gems/ruby-2.1.2/gems/rake-10.3.2/lib/rake/task.rb:240:in `call'
/Users/AgtLucas/.rvm/gems/ruby-2.1.2/gems/rake-10.3.2/lib/rake/task.rb:240:in `block in execute'
/Users/AgtLucas/.rvm/gems/ruby-2.1.2/gems/rake-10.3.2/lib/rake/task.rb:235:in `each'
/Users/AgtLucas/.rvm/gems/ruby-2.1.2/gems/rake-10.3.2/lib/rake/task.rb:235:in `execute'
/Users/AgtLucas/.rvm/gems/ruby-2.1.2/gems/rake-10.3.2/lib/rake/task.rb:179:in `block in invoke_with_call_chain'
/Users/AgtLucas/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/monitor.rb:211:in `mon_synchronize'
/Users/AgtLucas/.rvm/gems/ruby-2.1.2/gems/rake-10.3.2/lib/rake/task.rb:172:in `invoke_with_call_chain'
/Users/AgtLucas/.rvm/gems/ruby-2.1.2/gems/rake-10.3.2/lib/rake/task.rb:201:in `block in invoke_prerequisites'
/Users/AgtLucas/.rvm/gems/ruby-2.1.2/gems/rake-10.3.2/lib/rake/task.rb:199:in `each'
/Users/AgtLucas/.rvm/gems/ruby-2.1.2/gems/rake-10.3.2/lib/rake/task.rb:199:in `invoke_prerequisites'
/Users/AgtLucas/.rvm/gems/ruby-2.1.2/gems/rake-10.3.2/lib/rake/task.rb:178:in `block in invoke_with_call_chain'
/Users/AgtLucas/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/monitor.rb:211:in `mon_synchronize'
/Users/AgtLucas/.rvm/gems/ruby-2.1.2/gems/rake-10.3.2/lib/rake/task.rb:172:in `invoke_with_call_chain'
/Users/AgtLucas/.rvm/gems/ruby-2.1.2/gems/rake-10.3.2/lib/rake/task.rb:165:in `invoke'
/Users/AgtLucas/.rvm/gems/ruby-2.1.2/gems/rake-10.3.2/lib/rake/application.rb:150:in `invoke_task'
/Users/AgtLucas/.rvm/gems/ruby-2.1.2/gems/rake-10.3.2/lib/rake/application.rb:106:in `block (2 levels) in top_level'
/Users/AgtLucas/.rvm/gems/ruby-2.1.2/gems/rake-10.3.2/lib/rake/application.rb:106:in `each'
/Users/AgtLucas/.rvm/gems/ruby-2.1.2/gems/rake-10.3.2/lib/rake/application.rb:106:in `block in top_level'
/Users/AgtLucas/.rvm/gems/ruby-2.1.2/gems/rake-10.3.2/lib/rake/application.rb:115:in `run_with_threads'
/Users/AgtLucas/.rvm/gems/ruby-2.1.2/gems/rake-10.3.2/lib/rake/application.rb:100:in `top_level'
/Users/AgtLucas/.rvm/gems/ruby-2.1.2/gems/rake-10.3.2/lib/rake/application.rb:78:in `block in run'
/Users/AgtLucas/.rvm/gems/ruby-2.1.2/gems/rake-10.3.2/lib/rake/application.rb:176:in `standard_exception_handling'
/Users/AgtLucas/.rvm/gems/ruby-2.1.2/gems/rake-10.3.2/lib/rake/application.rb:75:in `run'
/Users/AgtLucas/.rvm/gems/ruby-2.1.2/gems/rake-10.3.2/bin/rake:33:in `<top (required)>'
/Users/AgtLucas/.rvm/gems/ruby-2.1.2/bin/rake:23:in `load'
/Users/AgtLucas/.rvm/gems/ruby-2.1.2/bin/rake:23:in `<main>'
/Users/AgtLucas/.rvm/gems/ruby-2.1.2/bin/ruby_executable_hooks:15:in `eval'
/Users/AgtLucas/.rvm/gems/ruby-2.1.2/bin/ruby_executable_hooks:15:in `<main>'
Tasks: TOP => assets:precompile => requirejs:precompile:external

Also, I've forked this Gem and updated RequireJS version to the last one (2.1.15), but the problem persist. I really wanna use the last version of this Gem instead of 0.9.3 version.

Could this be a problem with RequireJS?

Any ideas?

Thanks!

carsomyr commented 10 years ago

@AgtLucas Could you puts the logical asset being looked up? FYI, that's one of the lines in your backtrace. Once you've identified the failing asset, would you mind creating a Rails test app that I can clone?

AgtLucas commented 10 years ago

@carsomyr Sorry dude, but I do not understand what do you mean with puts the logical asset being looked up. :confused: Could you explain a little more for me?

I'll provide the repo so you can clone it. :)

Thanks!

carsomyr commented 10 years ago

@AgtLucas I meant edit the file linked to. You'll be able to see it in your backtrace. Add a puts line before it and print out the logical path being looked up.

Also try clearing your tmp directory.

AgtLucas commented 10 years ago

@carsomyr Ok!

So, first of all, I've cleaned tmp but no joy.

But here's the odd thing: I guess the problem it's with some asset, I'm using Rails Assets in this project, but I'm not using in this demo project, which work well with 0.9.4.

So, adding a puts in that line and then ran rake I was able to see the ScrollReveal.js on the terminal. So, I've removed rails-assets-scrollReveal.js from Gemfile, run bundle update and then shot the rake command, now I was able to see which I guess it's jQuery library, not quite sure because I can't scroll too much the logs...

Almost there, I guess...

Thanks!

AgtLucas commented 10 years ago

@carsomyr

Found it!

I've removed everything about Rails Assets and 0.9.4 works as a charm.

But now, how can I use 0.9.4 with Rails Assets? Should I stick with 0.9.3?

Thanks!

carsomyr commented 10 years ago

@AgtLucas Could you insert a puts here and tell me what the local variable pathname is (for the failing rails-asset-created asset, of course)?

carsomyr commented 10 years ago

@AgtLucas Also, I doubt that rails-assets is the problem here. You can install all the rails-assets-prefixed gems you want, and it shouldn't affect compilation. Am I wrong about this? Can you isolate the problem to just whether the Gemfile contains rails-assets-your_gem_name?

AgtLucas commented 10 years ago

@carsomyr I guess that rails-assets is really the problem, because I've removed all the assets installed through Rails Assets and 0.9.4 works very well.

I'll try what you've said about Sprockets.

Thanks!

carsomyr commented 10 years ago

@AgtLucas Just to be clear, it's the mere inclusion of one of rails-asset's autogenerated gems in the Gemfile that causes the problem?

AgtLucas commented 10 years ago

@carsomyr Yep and whatever the Gem.

carsomyr commented 10 years ago

@AgtLucas That's strange, because I read rails-assets's source code. The Rails engine portion of autogenerated gems are blank, and that means there aren't strange manipulations. I also tried installing Angular.js as an autogenerated gem, and precompilation went fine.

Do add that puts to Sprockets when you get a chance. You'll be able to see it print out the pathname that it supposedly think exists (but doesn't, causing the mtime on NilClass problem).

AgtLucas commented 10 years ago

@carsomyr That's really strange! :worried: Are you using Rails 4.1.6 too?

carsomyr commented 10 years ago

@AgtLucas I'd also recommend updating Sprockets to 2.12.2.

AgtLucas commented 10 years ago

@carsomyr Ahhhhh, when I read that, I really tought that will solve the problem, but no joy, unfortunately. :confused:

Here's the test app: https://github.com/agtlucas/soloh

carsomyr commented 10 years ago

@AgtLucas Could you get your soloh example project to fail? That would go a long ways towards solving your issue.

carsomyr commented 10 years ago

@AgtLucas I've found the problem, and it's on your side. If you provide a bower.json file in the retreat-hell gem, it should point to a valid CSS file. As it turns out, hell.css doesn't exist. I'm closing this issue for now. Let me know if it's something else.

AgtLucas commented 10 years ago

@carsomyr Ah, shame of me, now it's working! :)

Thank you so much!