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

Unable to precompile bower projects with source maps or gzip'ed files. #58

Closed
faun opened this issue Jan 6, 2014 · 5 comments
Closed

Comments

@faun
Copy link

faun commented Jan 6, 2014

When running rake assets:precompile a project with source maps, bower-rails chokes.

After running

rm vendor/assets/bower_components/**/*.js.{gzip,map}

Everything compiles just fine.

See https://github.com/faun/bower-rails-bug for an example of this bug in action.

Here's a stack trace:

$ RAILS_ENV=production rake assets:precompile --trace
** Invoke assets:precompile (first_time)
** Execute assets:precompile
/Users/faun/.rvm/rubies/ruby-2.0.0-p353/bin/ruby /Users/faun/.rvm/gems/ruby-2.0.0-p353@bower-rails-bug/bin/rake assets:precompile:all RAILS_ENV=production RAILS_GROUPS=assets --trace
** Invoke assets:precompile:all (first_time)
** Execute assets:precompile:all
** Invoke assets:precompile:primary (first_time)
** Invoke assets:environment (first_time)
** Execute assets:environment
** Invoke environment (first_time)
** Execute environment
** Invoke tmp:cache:clear (first_time)
** Execute tmp:cache:clear
** Execute assets:precompile:primary
rake aborted!
Unexpected token: punc (:) (line: 2, col: 9, pos: 11)

Error
    at new JS_Parse_Error (/private/var/folders/6d/rpsxr3p90qscdq0b4jnbpcrh0000gp/T/execjs20140106-81957-1kw1yt6.js:2357:10748)
    at js_error (/private/var/folders/6d/rpsxr3p90qscdq0b4jnbpcrh0000gp/T/execjs20140106-81957-1kw1yt6.js:2357:10967)
    at croak (/private/var/folders/6d/rpsxr3p90qscdq0b4jnbpcrh0000gp/T/execjs20140106-81957-1kw1yt6.js:2357:19192)
    at token_error (/private/var/folders/6d/rpsxr3p90qscdq0b4jnbpcrh0000gp/T/execjs20140106-81957-1kw1yt6.js:2357:19329)
    at unexpected (/private/var/folders/6d/rpsxr3p90qscdq0b4jnbpcrh0000gp/T/execjs20140106-81957-1kw1yt6.js:2357:19417)
    at semicolon (/private/var/folders/6d/rpsxr3p90qscdq0b4jnbpcrh0000gp/T/execjs20140106-81957-1kw1yt6.js:2357:19890)
    at simple_statement (/private/var/folders/6d/rpsxr3p90qscdq0b4jnbpcrh0000gp/T/execjs20140106-81957-1kw1yt6.js:2357:22663)
    at /private/var/folders/6d/rpsxr3p90qscdq0b4jnbpcrh0000gp/T/execjs20140106-81957-1kw1yt6.js:2357:20380
    at /private/var/folders/6d/rpsxr3p90qscdq0b4jnbpcrh0000gp/T/execjs20140106-81957-1kw1yt6.js:2357:20063
    at block_ (/private/var/folders/6d/rpsxr3p90qscdq0b4jnbpcrh0000gp/T/execjs20140106-81957-1kw1yt6.js:2357:24682)
  (in /Users/faun/src/bower-rails-bug/vendor/assets/bower_components/angular-resource/angular-resource.min.js.map)/Users/faun/.rvm/gems/ruby-2.0.0-p353@bower-rails-bug/gems/execjs-2.0.2/lib/execjs/external_runtime.rb:68:in `extract_result'
/Users/faun/.rvm/gems/ruby-2.0.0-p353@bower-rails-bug/gems/execjs-2.0.2/lib/execjs/external_runtime.rb:28:in `block in exec'
/Users/faun/.rvm/gems/ruby-2.0.0-p353@bower-rails-bug/gems/execjs-2.0.2/lib/execjs/external_runtime.rb:41:in `compile_to_tempfile'
/Users/faun/.rvm/gems/ruby-2.0.0-p353@bower-rails-bug/gems/execjs-2.0.2/lib/execjs/external_runtime.rb:27:in `exec'
/Users/faun/.rvm/gems/ruby-2.0.0-p353@bower-rails-bug/gems/uglifier-2.4.0/lib/uglifier.rb:184:in `really_compile'
/Users/faun/.rvm/gems/ruby-2.0.0-p353@bower-rails-bug/gems/uglifier-2.4.0/lib/uglifier.rb:108:in `compile'
/Users/faun/.rvm/gems/ruby-2.0.0-p353@bower-rails-bug/gems/actionpack-3.2.16/lib/sprockets/compressors.rb:74:in `compress'
/Users/faun/.rvm/gems/ruby-2.0.0-p353@bower-rails-bug/gems/sprockets-2.2.2/lib/sprockets/processing.rb:265:in `block in js_compressor='
/Users/faun/.rvm/gems/ruby-2.0.0-p353@bower-rails-bug/gems/sprockets-2.2.2/lib/sprockets/processor.rb:29:in `call'
/Users/faun/.rvm/gems/ruby-2.0.0-p353@bower-rails-bug/gems/sprockets-2.2.2/lib/sprockets/processor.rb:29:in `evaluate'
/Users/faun/.rvm/gems/ruby-2.0.0-p353@bower-rails-bug/gems/tilt-1.4.1/lib/tilt/template.rb:103:in `render'
/Users/faun/.rvm/gems/ruby-2.0.0-p353@bower-rails-bug/gems/sprockets-2.2.2/lib/sprockets/context.rb:193:in `block in evaluate'
/Users/faun/.rvm/gems/ruby-2.0.0-p353@bower-rails-bug/gems/sprockets-2.2.2/lib/sprockets/context.rb:190:in `each'
/Users/faun/.rvm/gems/ruby-2.0.0-p353@bower-rails-bug/gems/sprockets-2.2.2/lib/sprockets/context.rb:190:in `evaluate'
/Users/faun/.rvm/gems/ruby-2.0.0-p353@bower-rails-bug/gems/sprockets-2.2.2/lib/sprockets/bundled_asset.rb:26:in `initialize'
/Users/faun/.rvm/gems/ruby-2.0.0-p353@bower-rails-bug/gems/sprockets-2.2.2/lib/sprockets/base.rb:252:in `new'
/Users/faun/.rvm/gems/ruby-2.0.0-p353@bower-rails-bug/gems/sprockets-2.2.2/lib/sprockets/base.rb:252:in `build_asset'
/Users/faun/.rvm/gems/ruby-2.0.0-p353@bower-rails-bug/gems/sprockets-2.2.2/lib/sprockets/index.rb:93:in `block in build_asset'
/Users/faun/.rvm/gems/ruby-2.0.0-p353@bower-rails-bug/gems/sprockets-2.2.2/lib/sprockets/caching.rb:19:in `cache_asset'
/Users/faun/.rvm/gems/ruby-2.0.0-p353@bower-rails-bug/gems/sprockets-2.2.2/lib/sprockets/index.rb:92:in `build_asset'
/Users/faun/.rvm/gems/ruby-2.0.0-p353@bower-rails-bug/gems/sprockets-2.2.2/lib/sprockets/base.rb:169:in `find_asset'
/Users/faun/.rvm/gems/ruby-2.0.0-p353@bower-rails-bug/gems/sprockets-2.2.2/lib/sprockets/index.rb:60:in `find_asset'
/Users/faun/.rvm/gems/ruby-2.0.0-p353@bower-rails-bug/gems/actionpack-3.2.16/lib/sprockets/static_compiler.rb:19:in `block in compile'
/Users/faun/.rvm/gems/ruby-2.0.0-p353@bower-rails-bug/gems/sprockets-2.2.2/lib/sprockets/base.rb:219:in `block in each_logical_path'
/Users/faun/.rvm/gems/ruby-2.0.0-p353@bower-rails-bug/gems/sprockets-2.2.2/lib/sprockets/base.rb:206:in `block (2 levels) in each_file'
/Users/faun/.rvm/gems/ruby-2.0.0-p353@bower-rails-bug/gems/sprockets-2.2.2/lib/sprockets/base.rb:196:in `each'
/Users/faun/.rvm/gems/ruby-2.0.0-p353@bower-rails-bug/gems/sprockets-2.2.2/lib/sprockets/base.rb:196:in `each_entry'
/Users/faun/.rvm/gems/ruby-2.0.0-p353@bower-rails-bug/gems/sprockets-2.2.2/lib/sprockets/base.rb:204:in `block in each_file'
/Users/faun/.rvm/gems/ruby-2.0.0-p353@bower-rails-bug/gems/sprockets-2.2.2/lib/sprockets/base.rb:203:in `each'
/Users/faun/.rvm/gems/ruby-2.0.0-p353@bower-rails-bug/gems/sprockets-2.2.2/lib/sprockets/base.rb:203:in `each_file'
/Users/faun/.rvm/gems/ruby-2.0.0-p353@bower-rails-bug/gems/sprockets-2.2.2/lib/sprockets/base.rb:217:in `each_logical_path'
/Users/faun/.rvm/gems/ruby-2.0.0-p353@bower-rails-bug/gems/actionpack-3.2.16/lib/sprockets/static_compiler.rb:18:in `compile'
/Users/faun/.rvm/gems/ruby-2.0.0-p353@bower-rails-bug/gems/actionpack-3.2.16/lib/sprockets/assets.rake:56:in `internal_precompile'
/Users/faun/.rvm/gems/ruby-2.0.0-p353@bower-rails-bug/gems/actionpack-3.2.16/lib/sprockets/assets.rake:70:in `block (3 levels) in <top (required)>'
/Users/faun/.rvm/gems/ruby-2.0.0-p353@bower-rails-bug/gems/rake-10.1.1/lib/rake/task.rb:236:in `call'
/Users/faun/.rvm/gems/ruby-2.0.0-p353@bower-rails-bug/gems/rake-10.1.1/lib/rake/task.rb:236:in `block in execute'
/Users/faun/.rvm/gems/ruby-2.0.0-p353@bower-rails-bug/gems/rake-10.1.1/lib/rake/task.rb:231:in `each'
/Users/faun/.rvm/gems/ruby-2.0.0-p353@bower-rails-bug/gems/rake-10.1.1/lib/rake/task.rb:231:in `execute'
/Users/faun/.rvm/gems/ruby-2.0.0-p353@bower-rails-bug/gems/rake-10.1.1/lib/rake/task.rb:175:in `block in invoke_with_call_chain'
/Users/faun/.rvm/rubies/ruby-2.0.0-p353/lib/ruby/2.0.0/monitor.rb:211:in `mon_synchronize'
/Users/faun/.rvm/gems/ruby-2.0.0-p353@bower-rails-bug/gems/rake-10.1.1/lib/rake/task.rb:168:in `invoke_with_call_chain'
/Users/faun/.rvm/gems/ruby-2.0.0-p353@bower-rails-bug/gems/rake-10.1.1/lib/rake/task.rb:161:in `invoke'
/Users/faun/.rvm/gems/ruby-2.0.0-p353@bower-rails-bug/gems/actionpack-3.2.16/lib/sprockets/assets.rake:60:in `block (3 levels) in <top (required)>'
/Users/faun/.rvm/gems/ruby-2.0.0-p353@bower-rails-bug/gems/rake-10.1.1/lib/rake/task.rb:236:in `call'
/Users/faun/.rvm/gems/ruby-2.0.0-p353@bower-rails-bug/gems/rake-10.1.1/lib/rake/task.rb:236:in `block in execute'
/Users/faun/.rvm/gems/ruby-2.0.0-p353@bower-rails-bug/gems/rake-10.1.1/lib/rake/task.rb:231:in `each'
/Users/faun/.rvm/gems/ruby-2.0.0-p353@bower-rails-bug/gems/rake-10.1.1/lib/rake/task.rb:231:in `execute'
/Users/faun/.rvm/gems/ruby-2.0.0-p353@bower-rails-bug/gems/rake-10.1.1/lib/rake/task.rb:175:in `block in invoke_with_call_chain'
/Users/faun/.rvm/rubies/ruby-2.0.0-p353/lib/ruby/2.0.0/monitor.rb:211:in `mon_synchronize'
/Users/faun/.rvm/gems/ruby-2.0.0-p353@bower-rails-bug/gems/rake-10.1.1/lib/rake/task.rb:168:in `invoke_with_call_chain'
/Users/faun/.rvm/gems/ruby-2.0.0-p353@bower-rails-bug/gems/rake-10.1.1/lib/rake/task.rb:161:in `invoke'
/Users/faun/.rvm/gems/ruby-2.0.0-p353@bower-rails-bug/gems/rake-10.1.1/lib/rake/application.rb:149:in `invoke_task'
/Users/faun/.rvm/gems/ruby-2.0.0-p353@bower-rails-bug/gems/rake-10.1.1/lib/rake/application.rb:106:in `block (2 levels) in top_level'
/Users/faun/.rvm/gems/ruby-2.0.0-p353@bower-rails-bug/gems/rake-10.1.1/lib/rake/application.rb:106:in `each'
/Users/faun/.rvm/gems/ruby-2.0.0-p353@bower-rails-bug/gems/rake-10.1.1/lib/rake/application.rb:106:in `block in top_level'
/Users/faun/.rvm/gems/ruby-2.0.0-p353@bower-rails-bug/gems/rake-10.1.1/lib/rake/application.rb:115:in `run_with_threads'
/Users/faun/.rvm/gems/ruby-2.0.0-p353@bower-rails-bug/gems/rake-10.1.1/lib/rake/application.rb:100:in `top_level'
/Users/faun/.rvm/gems/ruby-2.0.0-p353@bower-rails-bug/gems/rake-10.1.1/lib/rake/application.rb:78:in `block in run'
/Users/faun/.rvm/gems/ruby-2.0.0-p353@bower-rails-bug/gems/rake-10.1.1/lib/rake/application.rb:165:in `standard_exception_handling'
/Users/faun/.rvm/gems/ruby-2.0.0-p353@bower-rails-bug/gems/rake-10.1.1/lib/rake/application.rb:75:in `run'
/Users/faun/.rvm/gems/ruby-2.0.0-p353@bower-rails-bug/gems/rake-10.1.1/bin/rake:33:in `<top (required)>'
/Users/faun/.rvm/gems/ruby-2.0.0-p353@bower-rails-bug/bin/rake:23:in `load'
/Users/faun/.rvm/gems/ruby-2.0.0-p353@bower-rails-bug/bin/rake:23:in `<main>'
Tasks: TOP => assets:precompile:primary
rake aborted!
Command failed with status (1): [/Users/faun/.rvm/rubies/ruby-2.0.0-p353/bi...]
/Users/faun/.rvm/gems/ruby-2.0.0-p353@bower-rails-bug/gems/rake-10.1.1/lib/rake/file_utils.rb:54:in `block in create_shell_runner'
/Users/faun/.rvm/gems/ruby-2.0.0-p353@bower-rails-bug/gems/rake-10.1.1/lib/rake/file_utils.rb:45:in `call'
/Users/faun/.rvm/gems/ruby-2.0.0-p353@bower-rails-bug/gems/rake-10.1.1/lib/rake/file_utils.rb:45:in `sh'
/Users/faun/.rvm/gems/ruby-2.0.0-p353@bower-rails-bug/gems/rake-10.1.1/lib/rake/file_utils_ext.rb:37:in `sh'
/Users/faun/.rvm/gems/ruby-2.0.0-p353@bower-rails-bug/gems/rake-10.1.1/lib/rake/file_utils.rb:82:in `ruby'
/Users/faun/.rvm/gems/ruby-2.0.0-p353@bower-rails-bug/gems/rake-10.1.1/lib/rake/file_utils_ext.rb:37:in `ruby'
/Users/faun/.rvm/gems/ruby-2.0.0-p353@bower-rails-bug/gems/actionpack-3.2.16/lib/sprockets/assets.rake:12:in `ruby_rake_task'
/Users/faun/.rvm/gems/ruby-2.0.0-p353@bower-rails-bug/gems/actionpack-3.2.16/lib/sprockets/assets.rake:21:in `invoke_or_reboot_rake_task'
/Users/faun/.rvm/gems/ruby-2.0.0-p353@bower-rails-bug/gems/actionpack-3.2.16/lib/sprockets/assets.rake:29:in `block (2 levels) in <top (required)>'
/Users/faun/.rvm/gems/ruby-2.0.0-p353@bower-rails-bug/gems/rake-10.1.1/lib/rake/task.rb:236:in `call'
/Users/faun/.rvm/gems/ruby-2.0.0-p353@bower-rails-bug/gems/rake-10.1.1/lib/rake/task.rb:236:in `block in execute'
/Users/faun/.rvm/gems/ruby-2.0.0-p353@bower-rails-bug/gems/rake-10.1.1/lib/rake/task.rb:231:in `each'
/Users/faun/.rvm/gems/ruby-2.0.0-p353@bower-rails-bug/gems/rake-10.1.1/lib/rake/task.rb:231:in `execute'
/Users/faun/.rvm/gems/ruby-2.0.0-p353@bower-rails-bug/gems/rake-10.1.1/lib/rake/task.rb:175:in `block in invoke_with_call_chain'
/Users/faun/.rvm/rubies/ruby-2.0.0-p353/lib/ruby/2.0.0/monitor.rb:211:in `mon_synchronize'
/Users/faun/.rvm/gems/ruby-2.0.0-p353@bower-rails-bug/gems/rake-10.1.1/lib/rake/task.rb:168:in `invoke_with_call_chain'
/Users/faun/.rvm/gems/ruby-2.0.0-p353@bower-rails-bug/gems/rake-10.1.1/lib/rake/task.rb:161:in `invoke'
/Users/faun/.rvm/gems/ruby-2.0.0-p353@bower-rails-bug/gems/rake-10.1.1/lib/rake/application.rb:149:in `invoke_task'
/Users/faun/.rvm/gems/ruby-2.0.0-p353@bower-rails-bug/gems/rake-10.1.1/lib/rake/application.rb:106:in `block (2 levels) in top_level'
/Users/faun/.rvm/gems/ruby-2.0.0-p353@bower-rails-bug/gems/rake-10.1.1/lib/rake/application.rb:106:in `each'
/Users/faun/.rvm/gems/ruby-2.0.0-p353@bower-rails-bug/gems/rake-10.1.1/lib/rake/application.rb:106:in `block in top_level'
/Users/faun/.rvm/gems/ruby-2.0.0-p353@bower-rails-bug/gems/rake-10.1.1/lib/rake/application.rb:115:in `run_with_threads'
/Users/faun/.rvm/gems/ruby-2.0.0-p353@bower-rails-bug/gems/rake-10.1.1/lib/rake/application.rb:100:in `top_level'
/Users/faun/.rvm/gems/ruby-2.0.0-p353@bower-rails-bug/gems/rake-10.1.1/lib/rake/application.rb:78:in `block in run'
/Users/faun/.rvm/gems/ruby-2.0.0-p353@bower-rails-bug/gems/rake-10.1.1/lib/rake/application.rb:165:in `standard_exception_handling'
/Users/faun/.rvm/gems/ruby-2.0.0-p353@bower-rails-bug/gems/rake-10.1.1/lib/rake/application.rb:75:in `run'
/Users/faun/.rvm/gems/ruby-2.0.0-p353@bower-rails-bug/gems/rake-10.1.1/bin/rake:33:in `<top (required)>'
/Users/faun/.rvm/gems/ruby-2.0.0-p353@bower-rails-bug/bin/rake:23:in `load'
/Users/faun/.rvm/gems/ruby-2.0.0-p353@bower-rails-bug/bin/rake:23:in `<main>'
Tasks: TOP => assets:precompile
@faun
Copy link
Author

faun commented Jan 6, 2014

It also appears that excluding .gzip and .map from pre-compilation has the same effect: http://stackoverflow.com/questions/12938995/excluding-files-from-assetsprecompile-in-rails

@faun
Copy link
Author

faun commented Jan 6, 2014

I can't tell if this is a bug or not, since AngularJS does not work with bower-rails out of the box.

@SergeyKishenin
Copy link
Collaborator

After researching I found that Rails does not currently have support for source maps... http://stackoverflow.com/a/21007408/532252

With the .gzip file I've got a invalid UTF-8 byte sequence error. The solution is here http://stackoverflow.com/a/7837366/532252. But another problem appeared:

Invalid syntax: 1f8b (line: 1, col: 0, pos: 0)

Error
    at new JS_Parse_Error (/tmp/execjs20140110-30355-1tmd7tc.js:2357:10748)
    at js_error (/tmp/execjs20140110-30355-1tmd7tc.js:2357:10967)
    at parse_error (/tmp/execjs20140110-30355-1tmd7tc.js:2357:12685)
    at read_num (/tmp/execjs20140110-30355-1tmd7tc.js:2357:13284)
    at Object.next_token [as input] (/tmp/execjs20140110-30355-1tmd7tc.js:2357:17547)
    at next (/tmp/execjs20140110-30355-1tmd7tc.js:2357:19006)
    at Object.parse (/tmp/execjs20140110-30355-1tmd7tc.js:2357:18795)
    at print (/tmp/execjs20140110-30355-1tmd7tc.js:2630:26)
    at /tmp/execjs20140110-30355-1tmd7tc.js:2670:14
    at /tmp/execjs20140110-30355-1tmd7tc.js:1:92
  (in /home/sergey/src/bower-rails-bug/vendor/assets/bower_components/angular/angular.min.js.gzip)/home/sergey/.rvm/gems/ruby-2.0.0-p247/gems/execjs-2.0.2/lib/execjs/external_runtime.rb:68:in `extract_result'

After changing file extension from .gzip to .gz the problem gone away. Don't know what's the real reason, maybe just because the only correct extension is .gz https://github.com/sstephenson/sprockets/search?q=gzip&ref=cmdform https://github.com/sstephenson/sprockets/search?q=gz&type=Code

Actually after removing .gzip and .map files RAILS_ENV=production rake assets:precompile --trace command passed.

@faun
Copy link
Author

faun commented Jan 11, 2014

In the case of angular-resource bower package, the .gzip and .js.map files are not needed so added a workaround to tell sprockets to ignore these file extensions during pre-compilation. @SergeyKishenin, thanks for looking into it.

@sheerun
Copy link

sheerun commented Feb 28, 2014

We had similar issue with rails-assets. I ended up excluding .gzip files as well, and creating new issue on sprockets: sstephenson/sprockets#519

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

3 participants