Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rails 4 - local assets precompile error

In development (rails 4.2 app), we are doing local assets precompile with following command:

$ RAILS_ENV=production bundle exec rake assets:clean assets:precompile RAILS_RELATIVE_URL_ROOT=/tj --trace
** Invoke assets:clean (first_time)
** Invoke assets:environment (first_time)
** Execute assets:environment
** Invoke environment (first_time)
** Execute environment
** Execute assets:clean
** Invoke assets:precompile (first_time)
** Invoke assets:environment
** Execute assets:precompile
rake aborted!
Sass::SyntaxError: Invalid CSS after "...ontent}*/ url(C": expected comma, was ":/Program Files..."
(sass):66
c:/Ruby200/lib/ruby/gems/2.0.0/gems/sass-3.4.14/lib/sass/scss/parser.rb:1162:in `expected'
c:/Ruby200/lib/ruby/gems/2.0.0/gems/sass-3.4.14/lib/sass/script/lexer.rb:221:in `expected!'
c:/Ruby200/lib/ruby/gems/2.0.0/gems/sass-3.4.14/lib/sass/script/parser.rb:463:in `block in arglist'
c:/Ruby200/lib/ruby/gems/2.0.0/gems/sass-3.4.14/lib/sass/script/parser.rb:460:in `loop'
c:/Ruby200/lib/ruby/gems/2.0.0/gems/sass-3.4.14/lib/sass/script/parser.rb:460:in `arglist'
c:/Ruby200/lib/ruby/gems/2.0.0/gems/sass-3.4.14/lib/sass/script/parser.rb:445:in `fn_arglist'
c:/Ruby200/lib/ruby/gems/2.0.0/gems/sass-3.4.14/lib/sass/script/parser.rb:407:in `funcall'
c:/Ruby200/lib/ruby/gems/2.0.0/gems/sass-3.4.14/lib/sass/script/parser.rb:387:in `ident'
c:/Ruby200/lib/ruby/gems/2.0.0/gems/sass-3.4.14/lib/sass/script/parser.rb:246:in `unary_not'
c:/Ruby200/lib/ruby/gems/2.0.0/gems/sass-3.4.14/lib/sass/script/parser.rb:246:in `unary_div'
c:/Ruby200/lib/ruby/gems/2.0.0/gems/sass-3.4.14/lib/sass/script/parser.rb:246:in `unary_minus'
c:/Ruby200/lib/ruby/gems/2.0.0/gems/sass-3.4.14/lib/sass/script/parser.rb:246:in `unary_plus'
c:/Ruby200/lib/ruby/gems/2.0.0/gems/sass-3.4.14/lib/sass/script/parser.rb:227:in `times_div_or_mod'
c:/Ruby200/lib/ruby/gems/2.0.0/gems/sass-3.4.14/lib/sass/script/parser.rb:227:in `plus_or_minus'
c:/Ruby200/lib/ruby/gems/2.0.0/gems/sass-3.4.14/lib/sass/script/parser.rb:227:in `relational'
c:/Ruby200/lib/ruby/gems/2.0.0/gems/sass-3.4.14/lib/sass/script/parser.rb:227:in `eq_or_neq'
c:/Ruby200/lib/ruby/gems/2.0.0/gems/sass-3.4.14/lib/sass/script/parser.rb:227:in `and_expr'
c:/Ruby200/lib/ruby/gems/2.0.0/gems/sass-3.4.14/lib/sass/script/parser.rb:227:in `or_expr'
c:/Ruby200/lib/ruby/gems/2.0.0/gems/sass-3.4.14/lib/sass/script/parser.rb:364:in `space'
c:/Ruby200/lib/ruby/gems/2.0.0/gems/sass-3.4.14/lib/sass/script/parser.rb:345:in `interpolation'
c:/Ruby200/lib/ruby/gems/2.0.0/gems/sass-3.4.14/lib/sass/script/parser.rb:293:in `expr'
c:/Ruby200/lib/ruby/gems/2.0.0/gems/sass-3.4.14/lib/sass/script/parser.rb:571:in `assert_expr'
c:/Ruby200/lib/ruby/gems/2.0.0/gems/sass-3.4.14/lib/sass/script/parser.rb:62:in `parse'
c:/Ruby200/lib/ruby/gems/2.0.0/gems/sass-3.4.14/lib/sass/scss/parser.rb:1024:in `sass_script'
c:/Ruby200/lib/ruby/gems/2.0.0/gems/sass-3.4.14/lib/sass/scss/parser.rb:877:in `value!'
c:/Ruby200/lib/ruby/gems/2.0.0/gems/sass-3.4.14/lib/sass/scss/parser.rb:750:in `block in try_declaration'
c:/Ruby200/lib/ruby/gems/2.0.0/gems/sass-3.4.14/lib/sass/scss/parser.rb:1138:in `call'
c:/Ruby200/lib/ruby/gems/2.0.0/gems/sass-3.4.14/lib/sass/scss/parser.rb:1138:in `rethrow'
c:/Ruby200/lib/ruby/gems/2.0.0/gems/sass-3.4.14/lib/sass/scss/parser.rb:763:in `try_declaration'
c:/Ruby200/lib/ruby/gems/2.0.0/gems/sass-3.4.14/lib/sass/scss/parser.rb:693:in `declaration_or_ruleset'
c:/Ruby200/lib/ruby/gems/2.0.0/gems/sass-3.4.14/lib/sass/scss/parser.rb:658:in `block_child'
c:/Ruby200/lib/ruby/gems/2.0.0/gems/sass-3.4.14/lib/sass/scss/parser.rb:650:in `block_contents'
c:/Ruby200/lib/ruby/gems/2.0.0/gems/sass-3.4.14/lib/sass/scss/parser.rb:639:in `block'
c:/Ruby200/lib/ruby/gems/2.0.0/gems/sass-3.4.14/lib/sass/scss/parser.rb:632:in `ruleset'
c:/Ruby200/lib/ruby/gems/2.0.0/gems/sass-3.4.14/lib/sass/scss/parser.rb:657:in `block_child'
c:/Ruby200/lib/ruby/gems/2.0.0/gems/sass-3.4.14/lib/sass/scss/parser.rb:650:in `block_contents'
c:/Ruby200/lib/ruby/gems/2.0.0/gems/sass-3.4.14/lib/sass/scss/parser.rb:117:in `stylesheet'
c:/Ruby200/lib/ruby/gems/2.0.0/gems/sass-3.4.14/lib/sass/scss/parser.rb:42:in `parse'
c:/Ruby200/lib/ruby/gems/2.0.0/gems/sass-3.4.14/lib/sass/engine.rb:393:in `_to_tree'
c:/Ruby200/lib/ruby/gems/2.0.0/gems/sass-3.4.14/lib/sass/engine.rb:268:in `render'
c:/Ruby200/lib/ruby/gems/2.0.0/gems/sprockets-3.2.0/lib/sprockets/sass_compressor.rb:48:in `call'
c:/Ruby200/lib/ruby/gems/2.0.0/gems/sprockets-3.2.0/lib/sprockets/sass_compressor.rb:28:in `call'
c:/Ruby200/lib/ruby/gems/2.0.0/gems/sprockets-3.2.0/lib/sprockets/processor_utils.rb:75:in `call_processor'
c:/Ruby200/lib/ruby/gems/2.0.0/gems/sprockets-3.2.0/lib/sprockets/processor_utils.rb:57:in `block in call_processors'
c:/Ruby200/lib/ruby/gems/2.0.0/gems/sprockets-3.2.0/lib/sprockets/processor_utils.rb:56:in `reverse_each'
c:/Ruby200/lib/ruby/gems/2.0.0/gems/sprockets-3.2.0/lib/sprockets/processor_utils.rb:56:in `call_processors'
c:/Ruby200/lib/ruby/gems/2.0.0/gems/sprockets-3.2.0/lib/sprockets/loader.rb:86:in `load_asset_by_uri'
c:/Ruby200/lib/ruby/gems/2.0.0/gems/sprockets-3.2.0/lib/sprockets/loader.rb:45:in `block in load'
c:/Ruby200/lib/ruby/gems/2.0.0/gems/sprockets-3.2.0/lib/sprockets/loader.rb:155:in `fetch_asset_from_dependency_cache'
c:/Ruby200/lib/ruby/gems/2.0.0/gems/sprockets-3.2.0/lib/sprockets/loader.rb:38:in `load'
c:/Ruby200/lib/ruby/gems/2.0.0/gems/sprockets-3.2.0/lib/sprockets/cached_environment.rb:20:in `block in initialize'
c:/Ruby200/lib/ruby/gems/2.0.0/gems/sprockets-3.2.0/lib/sprockets/cached_environment.rb:47:in `yield'
c:/Ruby200/lib/ruby/gems/2.0.0/gems/sprockets-3.2.0/lib/sprockets/cached_environment.rb:47:in `load'
c:/Ruby200/lib/ruby/gems/2.0.0/gems/sprockets-3.2.0/lib/sprockets/base.rb:63:in `find_asset'
c:/Ruby200/lib/ruby/gems/2.0.0/gems/sprockets-3.2.0/lib/sprockets/base.rb:70:in `find_all_linked_assets'
c:/Ruby200/lib/ruby/gems/2.0.0/gems/sprockets-3.2.0/lib/sprockets/manifest.rb:138:in `block in find'
c:/Ruby200/lib/ruby/gems/2.0.0/gems/sprockets-3.2.0/lib/sprockets/legacy.rb:114:in `block (2 levels) in logical_paths'
c:/Ruby200/lib/ruby/gems/2.0.0/gems/sprockets-3.2.0/lib/sprockets/path_utils.rb:223:in `block in stat_tree'
c:/Ruby200/lib/ruby/gems/2.0.0/gems/sprockets-3.2.0/lib/sprockets/path_utils.rb:207:in `block in stat_directory'
c:/Ruby200/lib/ruby/gems/2.0.0/gems/sprockets-3.2.0/lib/sprockets/path_utils.rb:204:in `each'
c:/Ruby200/lib/ruby/gems/2.0.0/gems/sprockets-3.2.0/lib/sprockets/path_utils.rb:204:in `stat_directory'
c:/Ruby200/lib/ruby/gems/2.0.0/gems/sprockets-3.2.0/lib/sprockets/path_utils.rb:222:in `stat_tree'
c:/Ruby200/lib/ruby/gems/2.0.0/gems/sprockets-3.2.0/lib/sprockets/path_utils.rb:226:in `block in stat_tree'
c:/Ruby200/lib/ruby/gems/2.0.0/gems/sprockets-3.2.0/lib/sprockets/path_utils.rb:207:in `block in stat_directory'
c:/Ruby200/lib/ruby/gems/2.0.0/gems/sprockets-3.2.0/lib/sprockets/path_utils.rb:204:in `each'
c:/Ruby200/lib/ruby/gems/2.0.0/gems/sprockets-3.2.0/lib/sprockets/path_utils.rb:204:in `stat_directory'
c:/Ruby200/lib/ruby/gems/2.0.0/gems/sprockets-3.2.0/lib/sprockets/path_utils.rb:222:in `stat_tree'
c:/Ruby200/lib/ruby/gems/2.0.0/gems/sprockets-3.2.0/lib/sprockets/legacy.rb:105:in `each'
c:/Ruby200/lib/ruby/gems/2.0.0/gems/sprockets-3.2.0/lib/sprockets/legacy.rb:105:in `block in logical_paths'
c:/Ruby200/lib/ruby/gems/2.0.0/gems/sprockets-3.2.0/lib/sprockets/legacy.rb:104:in `each'
c:/Ruby200/lib/ruby/gems/2.0.0/gems/sprockets-3.2.0/lib/sprockets/legacy.rb:104:in `logical_paths'
c:/Ruby200/lib/ruby/gems/2.0.0/gems/sprockets-3.2.0/lib/sprockets/manifest.rb:136:in `find'
c:/Ruby200/lib/ruby/gems/2.0.0/gems/sprockets-3.2.0/lib/sprockets/manifest.rb:162:in `compile'
c:/Ruby200/lib/ruby/gems/2.0.0/gems/sprockets-rails-2.3.1/lib/sprockets/rails/task.rb:70:in `block (3 levels) in define'
c:/Ruby200/lib/ruby/gems/2.0.0/gems/sprockets-3.2.0/lib/rake/sprocketstask.rb:147:in `with_logger'
c:/Ruby200/lib/ruby/gems/2.0.0/gems/sprockets-rails-2.3.1/lib/sprockets/rails/task.rb:69:in `block (2 levels) in define'
c:/Ruby200/lib/ruby/gems/2.0.0/gems/rake-10.4.2/lib/rake/task.rb:240:in `call'
c:/Ruby200/lib/ruby/gems/2.0.0/gems/rake-10.4.2/lib/rake/task.rb:240:in `block in execute'
c:/Ruby200/lib/ruby/gems/2.0.0/gems/rake-10.4.2/lib/rake/task.rb:235:in `each'
c:/Ruby200/lib/ruby/gems/2.0.0/gems/rake-10.4.2/lib/rake/task.rb:235:in `execute'
c:/Ruby200/lib/ruby/gems/2.0.0/gems/rake-10.4.2/lib/rake/task.rb:179:in `block in invoke_with_call_chain'
c:/Ruby200/lib/ruby/2.0.0/monitor.rb:211:in `mon_synchronize'
c:/Ruby200/lib/ruby/gems/2.0.0/gems/rake-10.4.2/lib/rake/task.rb:172:in `invoke_with_call_chain'
c:/Ruby200/lib/ruby/gems/2.0.0/gems/rake-10.4.2/lib/rake/task.rb:165:in `invoke'
c:/Ruby200/lib/ruby/gems/2.0.0/gems/rake-10.4.2/lib/rake/application.rb:150:in `invoke_task'
c:/Ruby200/lib/ruby/gems/2.0.0/gems/rake-10.4.2/lib/rake/application.rb:106:in `block (2 levels) in top_level'
c:/Ruby200/lib/ruby/gems/2.0.0/gems/rake-10.4.2/lib/rake/application.rb:106:in `each'
c:/Ruby200/lib/ruby/gems/2.0.0/gems/rake-10.4.2/lib/rake/application.rb:106:in `block in top_level'
c:/Ruby200/lib/ruby/gems/2.0.0/gems/rake-10.4.2/lib/rake/application.rb:115:in `run_with_threads'
c:/Ruby200/lib/ruby/gems/2.0.0/gems/rake-10.4.2/lib/rake/application.rb:100:in `top_level'
c:/Ruby200/lib/ruby/gems/2.0.0/gems/rake-10.4.2/lib/rake/application.rb:78:in `block in run'
c:/Ruby200/lib/ruby/gems/2.0.0/gems/rake-10.4.2/lib/rake/application.rb:176:in `standard_exception_handling'
c:/Ruby200/lib/ruby/gems/2.0.0/gems/rake-10.4.2/lib/rake/application.rb:75:in `run'
c:/Ruby200/lib/ruby/gems/2.0.0/gems/rake-10.4.2/bin/rake:33:in `<top (required)>'
c:/Ruby200/bin/rake:23:in `load'
c:/Ruby200/bin/rake:23:in `<main>'
Tasks: TOP => assets:precompile

The error is caused in parser.rb in sass. We don't quite understand what the error means. We tried to deploy on production server and the above assets precompile command ran successfully without any error. Can someone help us to understand the error and/or fix?

like image 517
user938363 Avatar asked Jun 19 '15 03:06

user938363


People also ask

How do you Precompile Rails assets?

To compile your assets locally, run the assets:precompile task locally on your app. Make sure to use the production environment so that the production version of your assets are generated. A public/assets directory will be created. Inside this directory you'll find a manifest.

What is assets Precompile?

rails assets:precompile is the task that does the compilation (concatenation, minification, and preprocessing). When the task is run, Rails first looks at the files in the config.assets.precompile array. By default, this array includes application.js and application.css .

What is require_ tree?

The require_tree directive tells Sprockets to recursively include all JavaScript files in the specified directory into the output. These paths must be specified relative to the manifest file.


2 Answers

Make sure your css files syntax is correct and properly indented. Or you can uninstall your sass gem from gem file... but this is not a good solution.. try to correct your css syntax..

like image 147
Ankit Kalia Avatar answered Nov 10 '22 02:11

Ankit Kalia


Check Line 66 of your SASS file.

Sass::SyntaxError: Invalid CSS after "...ontent}*/ url(C": expected comma, was      
":/Program Files..."(sass):66

Looks like an invalid CSS error. I'm guessing you're trying to link to an external file? You'll have to check the paths.

Probably can't use 'C:/Program Files...', instead change it to a relative path in relation to your files i.e

url(../../external_directory/image.png)
like image 27
br0tat0 Avatar answered Nov 10 '22 00:11

br0tat0