Assets Precompile When Explicitly Invoked, Breaks During Capistrano Deployment - ruby-on-rails

I am using Rails 4.2, and Capistrano 3. When I run bundle exec rake assets:precompile, everything works out nice and dandy, however when I use Capistrano to deploy the site, I get this error during the asset:precompile step.
Tasks: TOP => deploy:assets:precompile
(See full trace by running task with --trace)
The deploy has failed with an error: Exception while executing as xxx#123.45.67.89: rake exit status: 1
rake stdout: rake aborted!
Sass::SyntaxError: Invalid CSS after " */": expected "}", was ""
(sass):6831
/home/xxx/Sites/my-app/shared/bundle/ruby/2.2.0/gems/sass-3.4.19/lib/sass/scss/parser.rb:1161:in `expected'
/home/xxx/Sites/my-app/shared/bundle/ruby/2.2.0/gems/sass-3.4.19/lib/sass/scss/parser.rb:1097:in `expected'
/home/xxx/Sites/my-app/shared/bundle/ruby/2.2.0/gems/sass-3.4.19/lib/sass/scss/parser.rb:1092:in `tok!'
/home/xxx/Sites/my-app/shared/bundle/ruby/2.2.0/gems/sass-3.4.19/lib/sass/scss/parser.rb:639:in `block'
/home/xxx/Sites/my-app/shared/bundle/ruby/2.2.0/gems/sass-3.4.19/lib/sass/scss/parser.rb:631:in `ruleset'
/home/xxx/Sites/my-app/shared/bundle/ruby/2.2.0/gems/sass-3.4.19/lib/sass/scss/parser.rb:656:in `block_child'
/home/xxx/Sites/my-app/shared/bundle/ruby/2.2.0/gems/sass-3.4.19/lib/sass/scss/parser.rb:649:in `block_contents'
/home/xxx/Sites/my-app/shared/bundle/ruby/2.2.0/gems/sass-3.4.19/lib/sass/scss/parser.rb:117:in `stylesheet'
/home/xxx/Sites/my-app/shared/bundle/ruby/2.2.0/gems/sass-3.4.19/lib/sass/scss/parser.rb:42:in `parse'
/home/xxx/Sites/my-app/shared/bundle/ruby/2.2.0/gems/sass-3.4.19/lib/sass/engine.rb:403:in `_to_tree'
/home/xxx/Sites/my-app/shared/bundle/ruby/2.2.0/gems/sass-3.4.19/lib/sass/engine.rb:278:in `render'
/home/xxx/Sites/my-app/shared/bundle/ruby/2.2.0/gems/sprockets-3.5.0/lib/sprockets/sass_compressor.rb:48:in `call'
/home/xxx/Sites/my-app/shared/bundle/ruby/2.2.0/gems/sprockets-3.5.0/lib/sprockets/sass_compressor.rb:28:in `call'
/home/xxx/Sites/my-app/shared/bundle/ruby/2.2.0/gems/sprockets-3.5.0/lib/sprockets/processor_utils.rb:75:in `call_processor'
/home/xxx/Sites/my-app/shared/bundle/ruby/2.2.0/gems/sprockets-3.5.0/lib/sprockets/processor_utils.rb:57:in `block in call_processors'
/home/xxx/Sites/my-app/shared/bundle/ruby/2.2.0/gems/sprockets-3.5.0/lib/sprockets/processor_utils.rb:56:in `reverse_each'
/home/xxx/Sites/my-app/shared/bundle/ruby/2.2.0/gems/sprockets-3.5.0/lib/sprockets/processor_utils.rb:56:in `call_processors'
/home/xxx/Sites/my-app/shared/bundle/ruby/2.2.0/gems/sprockets-3.5.0/lib/sprockets/loader.rb:134:in `load_from_unloaded'
/home/xxx/Sites/my-app/shared/bundle/ruby/2.2.0/gems/sprockets-3.5.0/lib/sprockets/loader.rb:60:in `block in load'
/home/xxx/Sites/my-app/shared/bundle/ruby/2.2.0/gems/sprockets-3.5.0/lib/sprockets/loader.rb:318:in `fetch_asset_from_dependency_cache'
/home/xxx/Sites/my-app/shared/bundle/ruby/2.2.0/gems/sprockets-3.5.0/lib/sprockets/loader.rb:44:in `load'
/home/xxx/Sites/my-app/shared/bundle/ruby/2.2.0/gems/sprockets-3.5.0/lib/sprockets/cached_environment.rb:20:in `block in initialize'
/home/xxx/Sites/my-app/shared/bundle/ruby/2.2.0/gems/sprockets-3.5.0/lib/sprockets/cached_environment.rb:47:in `yield'
/home/xxx/Sites/my-app/shared/bundle/ruby/2.2.0/gems/sprockets-3.5.0/lib/sprockets/cached_environment.rb:47:in `load'
/home/xxx/Sites/my-app/shared/bundle/ruby/2.2.0/gems/sprockets-3.5.0/lib/sprockets/base.rb:66:in `find_asset'
/home/xxx/Sites/my-app/shared/bundle/ruby/2.2.0/gems/sprockets-3.5.0/lib/sprockets/base.rb:73:in `find_all_linked_assets'
/home/xxx/Sites/my-app/shared/bundle/ruby/2.2.0/gems/sprockets-3.5.0/lib/sprockets/manifest.rb:142:in `block in find'
/home/xxx/Sites/my-app/shared/bundle/ruby/2.2.0/gems/sprockets-3.5.0/lib/sprockets/legacy.rb:114:in `block (2 levels) in logical_paths'
/home/xxx/Sites/my-app/shared/bundle/ruby/2.2.0/gems/sprockets-3.5.0/lib/sprockets/path_utils.rb:225:in `block in stat_tree'
/home/xxx/Sites/my-app/shared/bundle/ruby/2.2.0/gems/sprockets-3.5.0/lib/sprockets/path_utils.rb:209:in `block in stat_directory'
/home/xxx/Sites/my-app/shared/bundle/ruby/2.2.0/gems/sprockets-3.5.0/lib/sprockets/path_utils.rb:206:in `each'
/home/xxx/Sites/my-app/shared/bundle/ruby/2.2.0/gems/sprockets-3.5.0/lib/sprockets/path_utils.rb:206:in `stat_directory'
/home/xxx/Sites/my-app/shared/bundle/ruby/2.2.0/gems/sprockets-3.5.0/lib/sprockets/path_utils.rb:224:in `stat_tree'
/home/xxx/Sites/my-app/shared/bundle/ruby/2.2.0/gems/sprockets-3.5.0/lib/sprockets/legacy.rb:105:in `each'
/home/xxx/Sites/my-app/shared/bundle/ruby/2.2.0/gems/sprockets-3.5.0/lib/sprockets/legacy.rb:105:in `block in logical_paths'
/home/xxx/Sites/my-app/shared/bundle/ruby/2.2.0/gems/sprockets-3.5.0/lib/sprockets/legacy.rb:104:in `each'
/home/xxx/Sites/my-app/shared/bundle/ruby/2.2.0/gems/sprockets-3.5.0/lib/sprockets/legacy.rb:104:in `logical_paths'
/home/xxx/Sites/my-app/shared/bundle/ruby/2.2.0/gems/sprockets-3.5.0/lib/sprockets/manifest.rb:140:in `find'
/home/xxx/Sites/my-app/shared/bundle/ruby/2.2.0/gems/sprockets-3.5.0/lib/sprockets/manifest.rb:168:in `compile'
/home/xxx/Sites/my-app/shared/bundle/ruby/2.2.0/gems/sprockets-rails-2.3.3/lib/sprockets/rails/task.rb:70:in `block (3 levels) in define'
/home/xxx/Sites/my-app/shared/bundle/ruby/2.2.0/gems/sprockets-3.5.0/lib/rake/sprocketstask.rb:147:in `with_logger'
/home/xxx/Sites/my-app/shared/bundle/ruby/2.2.0/gems/sprockets-rails-2.3.3/lib/sprockets/rails/task.rb:69:in `block (2 levels) in define'
Tasks: TOP => assets:precompile
(See full trace by running task with --trace)
rake stderr: Nothing written
I have noticed that if I remove the line *= require styles in my application.css file, it successfully deploys, but obviously that is not the solution I am looking for. My assets/stylesheets file-structure is shown below:

Running the following command compiles assets locally in your dev environment:
rake assets:precompile
During deployment capistrano the following task is being invoked (as you can see on top of your backtrace):
cap env_name deploy:assets:precompile
which on it's part invokes this on remote server:
rake assets:precompile
Asset precompilation in development environment ignores syntax errors.
Try running this command locally to find and fix those errors:
RAILS_ENV=production rake assets:precompile --trace

Related

SassC::SyntaxError: Error: Invalid CSS after "}":

I'm trying to precompile + minify my js and css assets.
If I run: rake assets:precompile
Then it runs fine, but doesn't minify.
If I run: SECRET_KEY_BASE=rake secretRAILS_ENV=production rake assets:precompile
Then it returns an error message and doesn't compile: SassC::SyntaxError: Error: Invalid CSS after "}": expected 1 selector or at-rule, was '!function(){if("und' on line 17881 of stdin
I've tried updating various gems, changing some of the CSS, adding #import to application.scss, etc but none of it seems to be working.
Here's the full error message:
rake aborted!
SassC::SyntaxError: Error: Invalid CSS after "}": expected 1 selector or at-rule, was '!function(){if("und'
on line 17881 of stdin
>> }
-^
stdin:17881
/usr/local/rvm/gems/ruby-2.4.1/gems/sassc-2.0.0/lib/sassc/engine.rb:49:in `render'
/usr/local/rvm/gems/ruby-2.4.1/gems/sassc-rails-2.1.0/lib/sassc/rails/compressor.rb:29:in `call'
/usr/local/rvm/gems/ruby-2.4.1/gems/sprockets-3.7.2/lib/sprockets/sass_compressor.rb:28:in `call'
/usr/local/rvm/gems/ruby-2.4.1/gems/sprockets-3.7.2/lib/sprockets/processor_utils.rb:75:in `call_processor'
/usr/local/rvm/gems/ruby-2.4.1/gems/sprockets-3.7.2/lib/sprockets/processor_utils.rb:57:in `block in call_processors'
/usr/local/rvm/gems/ruby-2.4.1/gems/sprockets-3.7.2/lib/sprockets/processor_utils.rb:56:in `reverse_each'
/usr/local/rvm/gems/ruby-2.4.1/gems/sprockets-3.7.2/lib/sprockets/processor_utils.rb:56:in `call_processors'
/usr/local/rvm/gems/ruby-2.4.1/gems/sprockets-3.7.2/lib/sprockets/loader.rb:134:in `load_from_unloaded'
/usr/local/rvm/gems/ruby-2.4.1/gems/sprockets-3.7.2/lib/sprockets/loader.rb:60:in `block in load'
/usr/local/rvm/gems/ruby-2.4.1/gems/sprockets-3.7.2/lib/sprockets/loader.rb:317:in `fetch_asset_from_dependency_cache'
/usr/local/rvm/gems/ruby-2.4.1/gems/sprockets-3.7.2/lib/sprockets/loader.rb:44:in `load'
/usr/local/rvm/gems/ruby-2.4.1/gems/sprockets-3.7.2/lib/sprockets/cached_environment.rb:20:in `block in initialize'
/usr/local/rvm/gems/ruby-2.4.1/gems/sprockets-3.7.2/lib/sprockets/cached_environment.rb:47:in `load'
/usr/local/rvm/gems/ruby-2.4.1/gems/sprockets-3.7.2/lib/sprockets/base.rb:66:in `find_asset'
/usr/local/rvm/gems/ruby-2.4.1/gems/sprockets-3.7.2/lib/sprockets/base.rb:73:in `find_all_linked_assets'
/usr/local/rvm/gems/ruby-2.4.1/gems/sprockets-3.7.2/lib/sprockets/manifest.rb:142:in `block in find'
/usr/local/rvm/gems/ruby-2.4.1/gems/sprockets-3.7.2/lib/sprockets/legacy.rb:114:in `block (2 levels) in logical_paths'
/usr/local/rvm/gems/ruby-2.4.1/gems/sprockets-3.7.2/lib/sprockets/path_utils.rb:228:in `block in stat_tree'
/usr/local/rvm/gems/ruby-2.4.1/gems/sprockets-3.7.2/lib/sprockets/path_utils.rb:212:in `block in stat_directory'
/usr/local/rvm/gems/ruby-2.4.1/gems/sprockets-3.7.2/lib/sprockets/path_utils.rb:209:in `each'
/usr/local/rvm/gems/ruby-2.4.1/gems/sprockets-3.7.2/lib/sprockets/path_utils.rb:209:in `stat_directory'
/usr/local/rvm/gems/ruby-2.4.1/gems/sprockets-3.7.2/lib/sprockets/path_utils.rb:227:in `stat_tree'
/usr/local/rvm/gems/ruby-2.4.1/gems/sprockets-3.7.2/lib/sprockets/legacy.rb:105:in `each'
/usr/local/rvm/gems/ruby-2.4.1/gems/sprockets-3.7.2/lib/sprockets/legacy.rb:105:in `block in logical_paths'
/usr/local/rvm/gems/ruby-2.4.1/gems/sprockets-3.7.2/lib/sprockets/legacy.rb:104:in `each'
/usr/local/rvm/gems/ruby-2.4.1/gems/sprockets-3.7.2/lib/sprockets/legacy.rb:104:in `logical_paths'
/usr/local/rvm/gems/ruby-2.4.1/gems/sprockets-3.7.2/lib/sprockets/manifest.rb:140:in `find'
/usr/local/rvm/gems/ruby-2.4.1/gems/sprockets-3.7.2/lib/sprockets/manifest.rb:186:in `compile'
/usr/local/rvm/gems/ruby-2.4.1#global/gems/sprockets-rails-3.2.1/lib/sprockets/rails/task.rb:68:in `block (3 levels) in define'
/usr/local/rvm/gems/ruby-2.4.1/gems/sprockets-3.7.2/lib/rake/sprocketstask.rb:147:in `with_logger'
/usr/local/rvm/gems/ruby-2.4.1#global/gems/sprockets-rails-3.2.1/lib/sprockets/rails/task.rb:67:in `block (2 levels) in define'
/usr/local/rvm/gems/ruby-2.4.1/gems/rake-12.3.2/exe/rake:27:in `<top (required)>'
/usr/local/rvm/gems/ruby-2.4.1/bin/ruby_executable_hooks:15:in `eval'
/usr/local/rvm/gems/ruby-2.4.1/bin/ruby_executable_hooks:15:in `<main>'
Tasks: TOP => assets:precompile
What am I missing that will let it precompile and minify my js and css?
For anyone searching for this, in the end I just deleted two instances in my CSS and JS that included the problematic line (!function(){if().
Still not sure why they caused this error but as they were not actively used lines anyway (related to videos, which I don't currently use) I was happy enough to just delete and compile without them.
I met the same problem.
to solve it, the key is find what is the content of "stdin", so we have to modify your local gem file and add debug outputs:
# edit (/home/siwei/.asdf/installs/ruby/3.0.4/lib/ruby/gems/3.0.0/gems/sassc-rails-2.1.2/lib/sassc/rails/compressor.rb)
def call(*args)
input = if defined?(data)
data # sprockets 2.x
else
args[0][:data] #sprockets 3.x
end
# add these debug lines of code
puts "=== input is: "
File.write('/tmp/temp_scss', input)
puts "=== input end "
SassC::Engine.new(
input,
{
style: :compressed
}
).render
end
then run command:
RAILS_ENV=production bundle exec rails assets:precompile
then you will meet error, no worry, check out the file /tmp/temp_scss, find the "line 17881 of stdin", you will find the syntax error.
e.g. my error looks like:
just fix this bug and everything goes fine.

Rake assets in Rails app Heroku

I am trying rake assets:precompile with command "heroku run rake assets:precompile" but I have this error:
Running rake assets:precompile on ⬢ infinite-meadow-50968... up, run.9141 (Free)
yarn install v1.8.0
[1/4] Resolving packages...
[2/4] Fetching packages...
[3/4] Linking dependencies...
[4/4] Building fresh packages...
Done in 1.70s.
rake aborted!
Uglifier::Error: Unexpected character '#'
/app/vendor/bundle/ruby/2.5.0/gems/uglifier-4.1.10/lib/uglifier.rb:234:in `parse_result'
/app/vendor/bundle/ruby/2.5.0/gems/uglifier-4.1.10/lib/uglifier.rb:216:in `run_uglifyjs'
/app/vendor/bundle/ruby/2.5.0/gems/uglifier-4.1.10/lib/uglifier.rb:168:in `compile'
/app/vendor/bundle/ruby/2.5.0/gems/sprockets-3.7.1/lib/sprockets/compressing.rb:65:in `block in js_compressor='
/app/vendor/bundle/ruby/2.5.0/gems/sprockets-3.7.1/lib/sprockets/legacy_proc_processor.rb:31:in `call'
/app/vendor/bundle/ruby/2.5.0/gems/sprockets-3.7.1/lib/sprockets/processor_utils.rb:75:in `call_processor'
/app/vendor/bundle/ruby/2.5.0/gems/sprockets-3.7.1/lib/sprockets/processor_utils.rb:57:in `block in call_processors'
/app/vendor/bundle/ruby/2.5.0/gems/sprockets-3.7.1/lib/sprockets/processor_utils.rb:56:in `reverse_each'
/app/vendor/bundle/ruby/2.5.0/gems/sprockets-3.7.1/lib/sprockets/processor_utils.rb:56:in `call_processors'
/app/vendor/bundle/ruby/2.5.0/gems/sprockets-3.7.1/lib/sprockets/loader.rb:134:in `load_from_unloaded'
/app/vendor/bundle/ruby/2.5.0/gems/sprockets-3.7.1/lib/sprockets/loader.rb:60:in `block in load'
/app/vendor/bundle/ruby/2.5.0/gems/sprockets-3.7.1/lib/sprockets/loader.rb:317:in `fetch_asset_from_dependency_cache'
/app/vendor/bundle/ruby/2.5.0/gems/sprockets-3.7.1/lib/sprockets/loader.rb:44:in `load'
/app/vendor/bundle/ruby/2.5.0/gems/sprockets-3.7.1/lib/sprockets/cached_environment.rb:20:in `block in initialize'
/app/vendor/bundle/ruby/2.5.0/gems/sprockets-3.7.1/lib/sprockets/cached_environment.rb:47:in `load'
/app/vendor/bundle/ruby/2.5.0/gems/sprockets-3.7.1/lib/sprockets/base.rb:66:in `find_asset'
/app/vendor/bundle/ruby/2.5.0/gems/sprockets-3.7.1/lib/sprockets/base.rb:73:in `find_all_linked_assets'
/app/vendor/bundle/ruby/2.5.0/gems/sprockets-3.7.1/lib/sprockets/manifest.rb:142:in `block in find'
/app/vendor/bundle/ruby/2.5.0/gems/sprockets-3.7.1/lib/sprockets/legacy.rb:114:in `block (2 levels) in logical_paths'
/app/vendor/bundle/ruby/2.5.0/gems/sprockets-3.7.1/lib/sprockets/path_utils.rb:228:in `block in stat_tree'
/app/vendor/bundle/ruby/2.5.0/gems/sprockets-3.7.1/lib/sprockets/path_utils.rb:212:in `block in stat_directory'
/app/vendor/bundle/ruby/2.5.0/gems/sprockets-3.7.1/lib/sprockets/path_utils.rb:209:in `each'
/app/vendor/bundle/ruby/2.5.0/gems/sprockets-3.7.1/lib/sprockets/path_utils.rb:209:in `stat_directory'
/app/vendor/bundle/ruby/2.5.0/gems/sprockets-3.7.1/lib/sprockets/path_utils.rb:227:in `stat_tree'
/app/vendor/bundle/ruby/2.5.0/gems/sprockets-3.7.1/lib/sprockets/legacy.rb:105:in `each'
/app/vendor/bundle/ruby/2.5.0/gems/sprockets-3.7.1/lib/sprockets/legacy.rb:105:in `block in logical_paths'
/app/vendor/bundle/ruby/2.5.0/gems/sprockets-3.7.1/lib/sprockets/legacy.rb:104:in `each'
/app/vendor/bundle/ruby/2.5.0/gems/sprockets-3.7.1/lib/sprockets/legacy.rb:104:in `logical_paths'
/app/vendor/bundle/ruby/2.5.0/gems/sprockets-3.7.1/lib/sprockets/manifest.rb:140:in `find'
/app/vendor/bundle/ruby/2.5.0/gems/sprockets-3.7.1/lib/sprockets/manifest.rb:185:in `compile'
/app/vendor/bundle/ruby/2.5.0/gems/sprockets-rails-3.2.1/lib/sprockets/rails/task.rb:68:in `block (3 levels) in define'
/app/vendor/bundle/ruby/2.5.0/gems/sprockets-3.7.1/lib/rake/sprocketstask.rb:147:in `with_logger'
/app/vendor/bundle/ruby/2.5.0/gems/sprockets-rails-3.2.1/lib/sprockets/rails/task.rb:67:in `block (2 levels) in define'
/app/vendor/bundle/ruby/2.5.0/gems/rake-12.3.1/exe/rake:27:in `<top (required)>'
/app/vendor/bundle/ruby/2.5.0/gems/bundler-1.15.2/lib/bundler/cli/exec.rb:74:in `load'
/app/vendor/bundle/ruby/2.5.0/gems/bundler-1.15.2/lib/bundler/cli/exec.rb:74:in `kernel_load'
/app/vendor/bundle/ruby/2.5.0/gems/bundler-1.15.2/lib/bundler/cli/exec.rb:27:in `run'
/app/vendor/bundle/ruby/2.5.0/gems/bundler-1.15.2/lib/bundler/cli.rb:360:in `exec'
/app/vendor/bundle/ruby/2.5.0/gems/bundler-1.15.2/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
/app/vendor/bundle/ruby/2.5.0/gems/bundler-1.15.2/lib/bundler/vendor/thor/lib/thor/invocation.rb:126:in `invoke_command'
/app/vendor/bundle/ruby/2.5.0/gems/bundler-1.15.2/lib/bundler/vendor/thor/lib/thor.rb:369:in `dispatch'
/app/vendor/bundle/ruby/2.5.0/gems/bundler-1.15.2/lib/bundler/cli.rb:20:in `dispatch'
/app/vendor/bundle/ruby/2.5.0/gems/bundler-1.15.2/lib/bundler/vendor/thor/lib/thor/base.rb:444:in `start'
/app/vendor/bundle/ruby/2.5.0/gems/bundler-1.15.2/lib/bundler/cli.rb:10:in `start'
/app/vendor/bundle/ruby/2.5.0/gems/bundler-1.15.2/exe/bundle:30:in `block in <top (required)>'
/app/vendor/bundle/ruby/2.5.0/gems/bundler-1.15.2/lib/bundler/friendly_errors.rb:121:in `with_friendly_errors'
/app/vendor/bundle/ruby/2.5.0/gems/bundler-1.15.2/exe/bundle:22:in `<top (required)>'
/app/bin/bundle:3:in `load'
/app/bin/bundle:3:in `<main>'
Tasks: TOP => assets:precompile
(See full trace by running task with --trace)
Github
Styling on subpages does not work https://infinite-meadow-50968.herokuapp.com/meetups/ See the menu and the section with meetups (in the main page its working)
Can you try to precompile in local? After push it into Heroku. It may be working.
All your js files have wrong syntax for comments. You use # instead of //.
E.g. #= require froala_editor.min.js should be //= require froala_editor.min.js.
You use # for comments in coffee files, and // for js files. Please replace it in all your js files.

Getting ExecJS when compiling rassets:precompile against production

So I am running into an odd issue. I cannot precompile assets on Rails 5 against production. I keep getting the same error message, irrespective if I precompile on the server itself or on my local environment.
georg$ RAILS_ENV=production bundle exec rake assets:precompile
rake aborted!
ExecJS::RuntimeError: SyntaxError: Unexpected token: name ($)
get#(execjs):3538:630
(execjs):4058:47
(execjs):1:46
global code#(execjs):1:58
/Users/georg/.rvm/gems/ruby-2.2.4/gems/execjs-2.7.0/lib/execjs/external_runtime.rb:39:in `exec'
/Users/georg/.rvm/gems/ruby-2.2.4/gems/execjs-2.7.0/lib/execjs/external_runtime.rb:21:in `eval'
/Users/georg/.rvm/gems/ruby-2.2.4/gems/execjs-2.7.0/lib/execjs/external_runtime.rb:46:in `call'
/Users/georg/.rvm/gems/ruby-2.2.4/gems/uglifier-3.2.0/lib/uglifier.rb:195:in `run_uglifyjs'
/Users/georg/.rvm/gems/ruby-2.2.4/gems/uglifier-3.2.0/lib/uglifier.rb:157:in `compile'
/Users/georg/.rvm/gems/ruby-2.2.4/gems/sprockets-3.7.1/lib/sprockets/uglifier_compressor.rb:53:in `call'
/Users/georg/.rvm/gems/ruby-2.2.4/gems/sprockets-3.7.1/lib/sprockets/uglifier_compressor.rb:28:in `call'
/Users/georg/.rvm/gems/ruby-2.2.4/gems/sprockets-3.7.1/lib/sprockets/processor_utils.rb:75:in `call_processor'
/Users/georg/.rvm/gems/ruby-2.2.4/gems/sprockets-3.7.1/lib/sprockets/processor_utils.rb:57:in `block in call_processors'
/Users/georg/.rvm/gems/ruby-2.2.4/gems/sprockets-3.7.1/lib/sprockets/processor_utils.rb:56:in `reverse_each'
/Users/georg/.rvm/gems/ruby-2.2.4/gems/sprockets-3.7.1/lib/sprockets/processor_utils.rb:56:in `call_processors'
/Users/georg/.rvm/gems/ruby-2.2.4/gems/sprockets-3.7.1/lib/sprockets/loader.rb:134:in `load_from_unloaded'
/Users/georg/.rvm/gems/ruby-2.2.4/gems/sprockets-3.7.1/lib/sprockets/loader.rb:60:in `block in load'
/Users/georg/.rvm/gems/ruby-2.2.4/gems/sprockets-3.7.1/lib/sprockets/loader.rb:317:in `fetch_asset_from_dependency_cache'
/Users/georg/.rvm/gems/ruby-2.2.4/gems/sprockets-3.7.1/lib/sprockets/loader.rb:44:in `load'
/Users/georg/.rvm/gems/ruby-2.2.4/gems/sprockets-3.7.1/lib/sprockets/cached_environment.rb:20:in `block in initialize'
/Users/georg/.rvm/gems/ruby-2.2.4/gems/sprockets-3.7.1/lib/sprockets/cached_environment.rb:47:in `yield'
/Users/georg/.rvm/gems/ruby-2.2.4/gems/sprockets-3.7.1/lib/sprockets/cached_environment.rb:47:in `load'
/Users/georg/.rvm/gems/ruby-2.2.4/gems/sprockets-3.7.1/lib/sprockets/base.rb:66:in `find_asset'
/Users/georg/.rvm/gems/ruby-2.2.4/gems/sprockets-3.7.1/lib/sprockets/base.rb:73:in `find_all_linked_assets'
/Users/georg/.rvm/gems/ruby-2.2.4/gems/sprockets-3.7.1/lib/sprockets/manifest.rb:142:in `block in find'
/Users/georg/.rvm/gems/ruby-2.2.4/gems/sprockets-3.7.1/lib/sprockets/legacy.rb:114:in `block (2 levels) in logical_paths'
/Users/georg/.rvm/gems/ruby-2.2.4/gems/sprockets-3.7.1/lib/sprockets/path_utils.rb:228:in `block in stat_tree'
/Users/georg/.rvm/gems/ruby-2.2.4/gems/sprockets-3.7.1/lib/sprockets/path_utils.rb:212:in `block in stat_directory'
/Users/georg/.rvm/gems/ruby-2.2.4/gems/sprockets-3.7.1/lib/sprockets/path_utils.rb:209:in `each'
/Users/georg/.rvm/gems/ruby-2.2.4/gems/sprockets-3.7.1/lib/sprockets/path_utils.rb:209:in `stat_directory'
/Users/georg/.rvm/gems/ruby-2.2.4/gems/sprockets-3.7.1/lib/sprockets/path_utils.rb:227:in `stat_tree'
/Users/georg/.rvm/gems/ruby-2.2.4/gems/sprockets-3.7.1/lib/sprockets/path_utils.rb:231:in `block in stat_tree'
/Users/georg/.rvm/gems/ruby-2.2.4/gems/sprockets-3.7.1/lib/sprockets/path_utils.rb:212:in `block in stat_directory'
/Users/georg/.rvm/gems/ruby-2.2.4/gems/sprockets-3.7.1/lib/sprockets/path_utils.rb:209:in `each'
/Users/georg/.rvm/gems/ruby-2.2.4/gems/sprockets-3.7.1/lib/sprockets/path_utils.rb:209:in `stat_directory'
/Users/georg/.rvm/gems/ruby-2.2.4/gems/sprockets-3.7.1/lib/sprockets/path_utils.rb:227:in `stat_tree'
/Users/georg/.rvm/gems/ruby-2.2.4/gems/sprockets-3.7.1/lib/sprockets/path_utils.rb:231:in `block in stat_tree'
/Users/georg/.rvm/gems/ruby-2.2.4/gems/sprockets-3.7.1/lib/sprockets/path_utils.rb:212:in `block in stat_directory'
/Users/georg/.rvm/gems/ruby-2.2.4/gems/sprockets-3.7.1/lib/sprockets/path_utils.rb:209:in `each'
/Users/georg/.rvm/gems/ruby-2.2.4/gems/sprockets-3.7.1/lib/sprockets/path_utils.rb:209:in `stat_directory'
/Users/georg/.rvm/gems/ruby-2.2.4/gems/sprockets-3.7.1/lib/sprockets/path_utils.rb:227:in `stat_tree'
/Users/georg/.rvm/gems/ruby-2.2.4/gems/sprockets-3.7.1/lib/sprockets/path_utils.rb:231:in `block in stat_tree'
/Users/georg/.rvm/gems/ruby-2.2.4/gems/sprockets-3.7.1/lib/sprockets/path_utils.rb:212:in `block in stat_directory'
/Users/georg/.rvm/gems/ruby-2.2.4/gems/sprockets-3.7.1/lib/sprockets/path_utils.rb:209:in `each'
/Users/georg/.rvm/gems/ruby-2.2.4/gems/sprockets-3.7.1/lib/sprockets/path_utils.rb:209:in `stat_directory'
/Users/georg/.rvm/gems/ruby-2.2.4/gems/sprockets-3.7.1/lib/sprockets/path_utils.rb:227:in `stat_tree'
/Users/georg/.rvm/gems/ruby-2.2.4/gems/sprockets-3.7.1/lib/sprockets/legacy.rb:105:in `each'
/Users/georg/.rvm/gems/ruby-2.2.4/gems/sprockets-3.7.1/lib/sprockets/legacy.rb:105:in `block in logical_paths'
/Users/georg/.rvm/gems/ruby-2.2.4/gems/sprockets-3.7.1/lib/sprockets/legacy.rb:104:in `each'
/Users/georg/.rvm/gems/ruby-2.2.4/gems/sprockets-3.7.1/lib/sprockets/legacy.rb:104:in `logical_paths'
/Users/georg/.rvm/gems/ruby-2.2.4/gems/sprockets-3.7.1/lib/sprockets/manifest.rb:140:in `find'
/Users/georg/.rvm/gems/ruby-2.2.4/gems/sprockets-3.7.1/lib/sprockets/manifest.rb:185:in `compile'
/Users/georg/.rvm/gems/ruby-2.2.4/gems/sprockets-rails-3.2.0/lib/sprockets/rails/task.rb:68:in `block (3 levels) in define'
/Users/georg/.rvm/gems/ruby-2.2.4/gems/sprockets-3.7.1/lib/rake/sprocketstask.rb:147:in `with_logger'
/Users/georg/.rvm/gems/ruby-2.2.4/gems/sprockets-rails-3.2.0/lib/sprockets/rails/task.rb:67:in `block (2 levels) in define'
/Users/georg/.rvm/gems/ruby-2.2.4/gems/rake-12.0.0/exe/rake:27:in `<top (required)>'
/Users/georg/.rvm/gems/ruby-2.2.4/bin/ruby_executable_hooks:15:in `eval'
/Users/georg/.rvm/gems/ruby-2.2.4/bin/ruby_executable_hooks:15:in `<main>'
Tasks: TOP => assets:precompile
(See full trace by running task with --trace)
To solve the issue I did the following:
1.) I have a subfolder structure I am referring to under assets/javascript, so I added that to the asset path and I thought that may be the issue - but apparently it isn't. I read the paths in like this:
Dir.glob("#{Rails.root}/app/assets/javascripts/**/").each do |path|
config.assets.paths << path
end
2.) I removed all references from application.js - it is empty and I still get the error.
3.) I removed / added therubyracer
# gem 'therubyracer', platforms: :ruby
4.) I installed and updated the execjs gem independently
5.) Eventually, I was running out of ideas. Given that I get the error when there's nothing to compile.
My environment:
georg$ rails -v
Rails 5.0.5
georg$ ruby -v
ruby 2.2.4p230 (2015-12-16 revision 53155) [x86_64-darwin16]
The compiling was done on OSx and Debian.
Any hints are much appreciated!!
The issue was with a custom js file in the tree. Given that there are plenty of js files included in the applciation.js it is obviously a painful way of trial and error to get to the bottom of the issue given the limited information I got from the trace. It would be interesting to know if there are ways to get more information in return to avoid lengthy inefficient debug sessions.
For the time being, I removed all js, added them one-by-one and run a precompile till I hit the offending code.

Undefined mixin 'global-reset' when deploying to Heroku

Any ideas why does this happen when deploying to Heroku:
-----> Preparing app for Rails asset pipeline
Running: rake assets:precompile
rake aborted!
Undefined mixin 'global-reset'.
(in /tmp/build_b4afrg7i0afu/vendor/bundle/ruby/1.9.1/gems/activeadmin-0.3.4/app/assets/stylesheets/active_admin/_base.css.scss)
Tasks: TOP => assets:precompile:primary
(See full trace by running task with --trace)
Precompiling assets failed, enabling runtime asset compilation
Injecting rails31_enable_runtime_asset_compilation
I have an scss file with:
#import "compass/reset";
but why is it not finding it when compiling assets? Is there a way to just not compile them? It works fine at runtime and this step generates an exception that gets into airbrake and it's a pain.
Update: I run rake assets:precompile locally and I found the error seems to be generated by activeadmin:
$ rake assets:precompile --trace
** Invoke assets:precompile (first_time)
** Execute assets:precompile
/Users/pupeno/.rvm/rubies/ruby-1.9.2-p290/bin/ruby /Users/pupeno/.rvm/gems/ruby-1.9.2-p290#watu/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!
Undefined mixin 'global-reset'.
(in /Users/pupeno/.rvm/gems/ruby-1.9.2-p290#watu/gems/activeadmin-0.4.0/app/assets/stylesheets/active_admin/_base.css.scss)
/Users/pupeno/.rvm/gems/ruby-1.9.2-p290#watu/gems/activeadmin-0.4.0/app/assets/stylesheets/active_admin/_base.css.scss:4:in `global-reset'
/Users/pupeno/.rvm/gems/ruby-1.9.2-p290#watu/gems/activeadmin-0.4.0/app/assets/stylesheets/active_admin/_base.css.scss:4
/Users/pupeno/.rvm/gems/ruby-1.9.2-p290#watu/gems/sass-3.1.12/lib/sass/tree/visitors/perform.rb:170:in `visit_mixin'
/Users/pupeno/.rvm/gems/ruby-1.9.2-p290#watu/gems/sass-3.1.12/lib/sass/tree/visitors/base.rb:37:in `visit'
/Users/pupeno/.rvm/gems/ruby-1.9.2-p290#watu/gems/sass-3.1.12/lib/sass/tree/visitors/perform.rb:18:in `visit'
/Users/pupeno/.rvm/gems/ruby-1.9.2-p290#watu/gems/sass-3.1.12/lib/sass/tree/visitors/base.rb:53:in `block in visit_children'
/Users/pupeno/.rvm/gems/ruby-1.9.2-p290#watu/gems/sass-3.1.12/lib/sass/tree/visitors/base.rb:53:in `map'
/Users/pupeno/.rvm/gems/ruby-1.9.2-p290#watu/gems/sass-3.1.12/lib/sass/tree/visitors/base.rb:53:in `visit_children'
/Users/pupeno/.rvm/gems/ruby-1.9.2-p290#watu/gems/sass-3.1.12/lib/sass/tree/visitors/perform.rb:27:in `block in visit_children'
/Users/pupeno/.rvm/gems/ruby-1.9.2-p290#watu/gems/sass-3.1.12/lib/sass/tree/visitors/perform.rb:39:in `with_environment'
/Users/pupeno/.rvm/gems/ruby-1.9.2-p290#watu/gems/sass-3.1.12/lib/sass/tree/visitors/perform.rb:26:in `visit_children'
/Users/pupeno/.rvm/gems/ruby-1.9.2-p290#watu/gems/sass-3.1.12/lib/sass/tree/visitors/base.rb:37:in `block in visit'
/Users/pupeno/.rvm/gems/ruby-1.9.2-p290#watu/gems/sass-3.1.12/lib/sass/tree/visitors/perform.rb:47:in `visit_root'
/Users/pupeno/.rvm/gems/ruby-1.9.2-p290#watu/gems/sass-3.1.12/lib/sass/tree/visitors/base.rb:37:in `visit'
/Users/pupeno/.rvm/gems/ruby-1.9.2-p290#watu/gems/sass-3.1.12/lib/sass/tree/visitors/perform.rb:18:in `visit'
/Users/pupeno/.rvm/gems/ruby-1.9.2-p290#watu/gems/sass-3.1.12/lib/sass/tree/visitors/perform.rb:7:in `visit'
/Users/pupeno/.rvm/gems/ruby-1.9.2-p290#watu/gems/sass-3.1.12/lib/sass/tree/root_node.rb:20:in `render'
/Users/pupeno/.rvm/gems/ruby-1.9.2-p290#watu/gems/sass-3.1.12/lib/sass/engine.rb:300:in `_render'
/Users/pupeno/.rvm/gems/ruby-1.9.2-p290#watu/gems/sass-3.1.12/lib/sass/engine.rb:247:in `render'
/Users/pupeno/.rvm/gems/ruby-1.9.2-p290#watu/gems/sass-rails-3.1.5/lib/sass/rails/template_handlers.rb:95:in `evaluate'
/Users/pupeno/.rvm/gems/ruby-1.9.2-p290#watu/gems/tilt-1.3.3/lib/tilt/template.rb:76:in `render'
/Users/pupeno/.rvm/gems/ruby-1.9.2-p290#watu/gems/sprockets-2.0.3/lib/sprockets/context.rb:175:in `block in evaluate'
/Users/pupeno/.rvm/gems/ruby-1.9.2-p290#watu/gems/sprockets-2.0.3/lib/sprockets/context.rb:172:in `each'
/Users/pupeno/.rvm/gems/ruby-1.9.2-p290#watu/gems/sprockets-2.0.3/lib/sprockets/context.rb:172:in `evaluate'
/Users/pupeno/.rvm/gems/ruby-1.9.2-p290#watu/gems/sprockets-2.0.3/lib/sprockets/bundled_asset.rb:171:in `build_dependency_context_and_body'
/Users/pupeno/.rvm/gems/ruby-1.9.2-p290#watu/gems/sprockets-2.0.3/lib/sprockets/bundled_asset.rb:135:in `dependency_context'
/Users/pupeno/.rvm/gems/ruby-1.9.2-p290#watu/gems/sprockets-2.0.3/lib/sprockets/bundled_asset.rb:194:in `build_dependencies_paths_and_assets'
/Users/pupeno/.rvm/gems/ruby-1.9.2-p290#watu/gems/sprockets-2.0.3/lib/sprockets/bundled_asset.rb:141:in `dependency_paths'
/Users/pupeno/.rvm/gems/ruby-1.9.2-p290#watu/gems/sprockets-2.0.3/lib/sprockets/bundled_asset.rb:61:in `mtime'
/Users/pupeno/.rvm/gems/ruby-1.9.2-p290#watu/gems/sprockets-2.0.3/lib/sprockets/asset.rb:58:in `block in encode_with'
/Users/pupeno/.rvm/gems/ruby-1.9.2-p290#watu/gems/sprockets-2.0.3/lib/sprockets/asset.rb:57:in `each'
/Users/pupeno/.rvm/gems/ruby-1.9.2-p290#watu/gems/sprockets-2.0.3/lib/sprockets/asset.rb:57:in `encode_with'
/Users/pupeno/.rvm/gems/ruby-1.9.2-p290#watu/gems/sprockets-2.0.3/lib/sprockets/bundled_asset.rb:43:in `encode_with'
/Users/pupeno/.rvm/gems/ruby-1.9.2-p290#watu/gems/sprockets-2.0.3/lib/sprockets/caching.rb:52:in `cache_asset'
/Users/pupeno/.rvm/gems/ruby-1.9.2-p290#watu/gems/sprockets-2.0.3/lib/sprockets/index.rb:67:in `block in build_asset'
/Users/pupeno/.rvm/gems/ruby-1.9.2-p290#watu/gems/sprockets-2.0.3/lib/sprockets/index.rb:76:in `memoize'
/Users/pupeno/.rvm/gems/ruby-1.9.2-p290#watu/gems/sprockets-2.0.3/lib/sprockets/index.rb:65:in `build_asset'
/Users/pupeno/.rvm/gems/ruby-1.9.2-p290#watu/gems/sprockets-2.0.3/lib/sprockets/trail.rb:102:in `find_asset_in_path'
/Users/pupeno/.rvm/gems/ruby-1.9.2-p290#watu/gems/sprockets-2.0.3/lib/sprockets/base.rb:101:in `find_asset'
/Users/pupeno/.rvm/gems/ruby-1.9.2-p290#watu/gems/sprockets-2.0.3/lib/sprockets/index.rb:48:in `find_asset'
/Users/pupeno/.rvm/gems/ruby-1.9.2-p290#watu/gems/actionpack-3.1.3/lib/sprockets/static_compiler.rb:20:in `block in compile'
/Users/pupeno/.rvm/gems/ruby-1.9.2-p290#watu/gems/sprockets-2.0.3/lib/sprockets/base.rb:151:in `block in each_logical_path'
/Users/pupeno/.rvm/gems/ruby-1.9.2-p290#watu/gems/sprockets-2.0.3/lib/sprockets/base.rb:139:in `block (2 levels) in each_file'
/Users/pupeno/.rvm/gems/ruby-1.9.2-p290#watu/gems/sprockets-2.0.3/lib/sprockets/base.rb:129:in `each'
/Users/pupeno/.rvm/gems/ruby-1.9.2-p290#watu/gems/sprockets-2.0.3/lib/sprockets/base.rb:129:in `each_entry'
/Users/pupeno/.rvm/gems/ruby-1.9.2-p290#watu/gems/sprockets-2.0.3/lib/sprockets/base.rb:137:in `block in each_file'
/Users/pupeno/.rvm/gems/ruby-1.9.2-p290#watu/gems/sprockets-2.0.3/lib/sprockets/base.rb:136:in `each'
/Users/pupeno/.rvm/gems/ruby-1.9.2-p290#watu/gems/sprockets-2.0.3/lib/sprockets/base.rb:136:in `each_file'
/Users/pupeno/.rvm/gems/ruby-1.9.2-p290#watu/gems/sprockets-2.0.3/lib/sprockets/base.rb:149:in `each_logical_path'
/Users/pupeno/.rvm/gems/ruby-1.9.2-p290#watu/gems/actionpack-3.1.3/lib/sprockets/static_compiler.rb:18:in `compile'
/Users/pupeno/.rvm/gems/ruby-1.9.2-p290#watu/gems/actionpack-3.1.3/lib/sprockets/assets.rake:52:in `internal_precompile'
/Users/pupeno/.rvm/gems/ruby-1.9.2-p290#watu/gems/actionpack-3.1.3/lib/sprockets/assets.rake:66:in `block (3 levels) in <top (required)>'
/Users/pupeno/.rvm/gems/ruby-1.9.2-p290#watu/gems/rake-0.9.2.2/lib/rake/task.rb:205:in `call'
/Users/pupeno/.rvm/gems/ruby-1.9.2-p290#watu/gems/rake-0.9.2.2/lib/rake/task.rb:205:in `block in execute'
/Users/pupeno/.rvm/gems/ruby-1.9.2-p290#watu/gems/rake-0.9.2.2/lib/rake/task.rb:200:in `each'
/Users/pupeno/.rvm/gems/ruby-1.9.2-p290#watu/gems/rake-0.9.2.2/lib/rake/task.rb:200:in `execute'
/Users/pupeno/.rvm/gems/ruby-1.9.2-p290#watu/gems/rake-0.9.2.2/lib/rake/task.rb:158:in `block in invoke_with_call_chain'
/Users/pupeno/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/monitor.rb:201:in `mon_synchronize'
/Users/pupeno/.rvm/gems/ruby-1.9.2-p290#watu/gems/rake-0.9.2.2/lib/rake/task.rb:151:in `invoke_with_call_chain'
/Users/pupeno/.rvm/gems/ruby-1.9.2-p290#watu/gems/rake-0.9.2.2/lib/rake/task.rb:144:in `invoke'
/Users/pupeno/.rvm/gems/ruby-1.9.2-p290#watu/gems/actionpack-3.1.3/lib/sprockets/assets.rake:56:in `block (3 levels) in <top (required)>'
/Users/pupeno/.rvm/gems/ruby-1.9.2-p290#watu/gems/rake-0.9.2.2/lib/rake/task.rb:205:in `call'
/Users/pupeno/.rvm/gems/ruby-1.9.2-p290#watu/gems/rake-0.9.2.2/lib/rake/task.rb:205:in `block in execute'
/Users/pupeno/.rvm/gems/ruby-1.9.2-p290#watu/gems/rake-0.9.2.2/lib/rake/task.rb:200:in `each'
/Users/pupeno/.rvm/gems/ruby-1.9.2-p290#watu/gems/rake-0.9.2.2/lib/rake/task.rb:200:in `execute'
/Users/pupeno/.rvm/gems/ruby-1.9.2-p290#watu/gems/rake-0.9.2.2/lib/rake/task.rb:158:in `block in invoke_with_call_chain'
/Users/pupeno/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/monitor.rb:201:in `mon_synchronize'
/Users/pupeno/.rvm/gems/ruby-1.9.2-p290#watu/gems/rake-0.9.2.2/lib/rake/task.rb:151:in `invoke_with_call_chain'
/Users/pupeno/.rvm/gems/ruby-1.9.2-p290#watu/gems/rake-0.9.2.2/lib/rake/task.rb:144:in `invoke'
/Users/pupeno/.rvm/gems/ruby-1.9.2-p290#watu/gems/rake-0.9.2.2/lib/rake/application.rb:116:in `invoke_task'
/Users/pupeno/.rvm/gems/ruby-1.9.2-p290#watu/gems/rake-0.9.2.2/lib/rake/application.rb:94:in `block (2 levels) in top_level'
/Users/pupeno/.rvm/gems/ruby-1.9.2-p290#watu/gems/rake-0.9.2.2/lib/rake/application.rb:94:in `each'
/Users/pupeno/.rvm/gems/ruby-1.9.2-p290#watu/gems/rake-0.9.2.2/lib/rake/application.rb:94:in `block in top_level'
/Users/pupeno/.rvm/gems/ruby-1.9.2-p290#watu/gems/rake-0.9.2.2/lib/rake/application.rb:133:in `standard_exception_handling'
/Users/pupeno/.rvm/gems/ruby-1.9.2-p290#watu/gems/rake-0.9.2.2/lib/rake/application.rb:88:in `top_level'
/Users/pupeno/.rvm/gems/ruby-1.9.2-p290#watu/gems/rake-0.9.2.2/lib/rake/application.rb:66:in `block in run'
/Users/pupeno/.rvm/gems/ruby-1.9.2-p290#watu/gems/rake-0.9.2.2/lib/rake/application.rb:133:in `standard_exception_handling'
/Users/pupeno/.rvm/gems/ruby-1.9.2-p290#watu/gems/rake-0.9.2.2/lib/rake/application.rb:63:in `run'
/Users/pupeno/.rvm/gems/ruby-1.9.2-p290#watu/gems/rake-0.9.2.2/bin/rake:33:in `<top (required)>'
/Users/pupeno/.rvm/gems/ruby-1.9.2-p290#watu/bin/rake:19:in `load'
/Users/pupeno/.rvm/gems/ruby-1.9.2-p290#watu/bin/rake:19:in `<main>'
Tasks: TOP => assets:precompile:primary
rake aborted!
I reported this issue in case it's a bug.
Check if you did all of the following:
In config/application.rb, ensure you have the line:
config.assets.initialize_on_precompile = false
If you're loading scss files other than application.css, make sure they're included in the assets pipeline. You'll need a line line the following at the top of the file:
/*= require_self */
In addition to #2, In config/environments/production.rb, add those files to the assets list. For instance, if your file is my.scss, you need a line like:
config.assets.precompile += %w( my.css )
Finally, there's a great guide at http://guides.rubyonrails.org/asset_pipeline.html

Ruby on Rails Rake assets:precompile error

I'm new in Rails development and this is my first deployment to Heroku.
When I execute my application (after the deployment) there is an error:
2011-09-18T21:05:54+00:00 app[web.1]: Completed 500 Internal Server Error in 10ms
2011-09-18T21:05:54+00:00 app[web.1]:
2011-09-18T21:05:54+00:00 app[web.1]: ActionView::Template::Error (application.css isn't precompiled):
I googled this and found that I have to precompile my assets, but when trying to do this I found an other error:
$ bundle exec rake assets:precompile RAILS_ENV=production
rake aborted!
No such process - /usr/lib/ruby/gems/1.8/gems/pg-0.11.0/lib/pg_ext.so
(See full trace by running task with --trace)
I haven't found any solution for this issue. Is there anyone who faced this an know how to solve this problem?
I ran into this issue as well and I resolved it by doing the following:
Open up config/environments/production.rb and make sure the following option is set to true:
# Don't fallback to assets pipeline if a precompiled asset is missed
config.assets.compile = true
Then run:
rake assets:precompile --trace RAILS_ENV=production
Hope this helps!
~Kevin
I got the problem too. But you can
rake assets:precompile RAILS_ENV=production
in local, and push to heroku with public/assets. It's resolved.
I would recommend to use the new Cedar stack. It precompiles assets for you on deploy and overall plays nicer with Rails 3.1, although you will need to configure your app a little bit to work: add some gems to your Gemfile and create a Procfile. But it is still an easier way to go.
Oh, this is an easy one. Your PG gem is breaking your rake task. You can either go the long route to try to fix it, or you can try commenting it out from your gemfile in order to run the precompile.
Yes like Simpleton posted above the PG gem is causing the problem. Imo a better solution would be to move the PG gem inside production in your gemfile and run;
bundle install --without production
Then you should be able to run the rake task without problems
I had the same error message. My issue was an incorrectly specified font url.
The bulk of this answer shows how I figured it out.
Although I didn't get the path of the asset it was failing on when running
RAILS_ENV=production SECRET_KEY_BASE=xxx rake assets:precompile --trace
Instead I had this stack trace:
** Invoke assets:precompile (first_time)
** Invoke assets:environment (first_time)
** Execute assets:environment
** Invoke environment (first_time)
** Execute environment
** Execute assets:precompile
rake aborted!
NoMethodError: undefined method `[]' for nil:NilClass
/Users/smithd98/.rvm/gems/ruby-2.3.1/gems/sprockets-3.7.0/lib/sprockets/sass_processor.rb:283:in `sprockets_context'
/Users/smithd98/.rvm/gems/ruby-2.3.1/gems/sprockets-3.7.0/lib/sprockets/sass_processor.rb:124:in `asset_path'
/Users/smithd98/.rvm/gems/ruby-2.3.1/gems/sprockets-3.7.0/lib/sprockets/sass_processor.rb:142:in `asset_url'
/Users/smithd98/.rvm/gems/ruby-2.3.1/gems/sprockets-3.7.0/lib/sprockets/sass_processor.rb:214:in `font_url'
/Users/smithd98/.rvm/gems/ruby-2.3.1/gems/sass-3.4.22/lib/sass/script/tree/funcall.rb:143:in `_perform'
/Users/smithd98/.rvm/gems/ruby-2.3.1/gems/sass-3.4.22/lib/sass/script/tree/node.rb:58:in `perform'
/Users/smithd98/.rvm/gems/ruby-2.3.1/gems/sass-3.4.22/lib/sass/script/tree/list_literal.rb:63:in `block in _perform'
/Users/smithd98/.rvm/gems/ruby-2.3.1/gems/sass-3.4.22/lib/sass/script/tree/list_literal.rb:63:in `map'
/Users/smithd98/.rvm/gems/ruby-2.3.1/gems/sass-3.4.22/lib/sass/script/tree/list_literal.rb:63:in `_perform'
/Users/smithd98/.rvm/gems/ruby-2.3.1/gems/sass-3.4.22/lib/sass/script/tree/node.rb:58:in `perform'
/Users/smithd98/.rvm/gems/ruby-2.3.1/gems/sass-3.4.22/lib/sass/tree/visitors/perform.rb:397:in `visit_prop'
/Users/smithd98/.rvm/gems/ruby-2.3.1/gems/sass-3.4.22/lib/sass/tree/visitors/base.rb:36:in `visit'
/Users/smithd98/.rvm/gems/ruby-2.3.1/gems/sass-3.4.22/lib/sass/tree/visitors/perform.rb:160:in `block in visit'
/Users/smithd98/.rvm/gems/ruby-2.3.1/gems/sass-3.4.22/lib/sass/stack.rb:79:in `block in with_base'
/Users/smithd98/.rvm/gems/ruby-2.3.1/gems/sass-3.4.22/lib/sass/stack.rb:115:in `with_frame'
/Users/smithd98/.rvm/gems/ruby-2.3.1/gems/sass-3.4.22/lib/sass/stack.rb:79:in `with_base'
/Users/smithd98/.rvm/gems/ruby-2.3.1/gems/sass-3.4.22/lib/sass/tree/visitors/perform.rb:160:in `visit'
/Users/smithd98/.rvm/gems/ruby-2.3.1/gems/sass-3.4.22/lib/sass/tree/visitors/perform.rb:433:in `block (2 levels) in visit_rule'
/Users/smithd98/.rvm/gems/ruby-2.3.1/gems/sass-3.4.22/lib/sass/tree/visitors/perform.rb:433:in `map'
/Users/smithd98/.rvm/gems/ruby-2.3.1/gems/sass-3.4.22/lib/sass/tree/visitors/perform.rb:433:in `block in visit_rule'
/Users/smithd98/.rvm/gems/ruby-2.3.1/gems/sass-3.4.22/lib/sass/tree/visitors/perform.rb:181:in `with_environment'
/Users/smithd98/.rvm/gems/ruby-2.3.1/gems/sass-3.4.22/lib/sass/tree/visitors/perform.rb:431:in `visit_rule'
/Users/smithd98/.rvm/gems/ruby-2.3.1/gems/sass-3.4.22/lib/sass/tree/visitors/base.rb:36:in `visit'
/Users/smithd98/.rvm/gems/ruby-2.3.1/gems/sass-3.4.22/lib/sass/tree/visitors/perform.rb:160:in `block in visit'
/Users/smithd98/.rvm/gems/ruby-2.3.1/gems/sass-3.4.22/lib/sass/stack.rb:79:in `block in with_base'
/Users/smithd98/.rvm/gems/ruby-2.3.1/gems/sass-3.4.22/lib/sass/stack.rb:115:in `with_frame'
/Users/smithd98/.rvm/gems/ruby-2.3.1/gems/sass-3.4.22/lib/sass/stack.rb:79:in `with_base'
/Users/smithd98/.rvm/gems/ruby-2.3.1/gems/sass-3.4.22/lib/sass/tree/visitors/perform.rb:160:in `visit'
/Users/smithd98/.rvm/gems/ruby-2.3.1/gems/sass-3.4.22/lib/sass/tree/visitors/base.rb:52:in `block in visit_children'
/Users/smithd98/.rvm/gems/ruby-2.3.1/gems/sass-3.4.22/lib/sass/tree/visitors/base.rb:52:in `map'
/Users/smithd98/.rvm/gems/ruby-2.3.1/gems/sass-3.4.22/lib/sass/tree/visitors/base.rb:52:in `visit_children'
/Users/smithd98/.rvm/gems/ruby-2.3.1/gems/sass-3.4.22/lib/sass/tree/visitors/perform.rb:169:in `block in visit_children'
/Users/smithd98/.rvm/gems/ruby-2.3.1/gems/sass-3.4.22/lib/sass/tree/visitors/perform.rb:181:in `with_environment'
/Users/smithd98/.rvm/gems/ruby-2.3.1/gems/sass-3.4.22/lib/sass/tree/visitors/perform.rb:168:in `visit_children'
/Users/smithd98/.rvm/gems/ruby-2.3.1/gems/sass-3.4.22/lib/sass/tree/visitors/base.rb:36:in `block in visit'
/Users/smithd98/.rvm/gems/ruby-2.3.1/gems/sass-3.4.22/lib/sass/tree/visitors/perform.rb:188:in `visit_root'
/Users/smithd98/.rvm/gems/ruby-2.3.1/gems/sass-3.4.22/lib/sass/tree/visitors/base.rb:36:in `visit'
/Users/smithd98/.rvm/gems/ruby-2.3.1/gems/sass-3.4.22/lib/sass/tree/visitors/perform.rb:159:in `visit'
/Users/smithd98/.rvm/gems/ruby-2.3.1/gems/sass-3.4.22/lib/sass/tree/visitors/perform.rb:8:in `visit'
/Users/smithd98/.rvm/gems/ruby-2.3.1/gems/sass-3.4.22/lib/sass/tree/root_node.rb:36:in `css_tree'
/Users/smithd98/.rvm/gems/ruby-2.3.1/gems/sass-3.4.22/lib/sass/tree/root_node.rb:20:in `render'
/Users/smithd98/.rvm/gems/ruby-2.3.1/gems/sass-3.4.22/lib/sass/engine.rb:281:in `render'
/Users/smithd98/.rvm/gems/ruby-2.3.1/gems/sprockets-3.7.0/lib/sprockets/sass_compressor.rb:48:in `call'
/Users/smithd98/.rvm/gems/ruby-2.3.1/gems/sprockets-3.7.0/lib/sprockets/sass_compressor.rb:28:in `call'
/Users/smithd98/.rvm/gems/ruby-2.3.1/gems/sprockets-3.7.0/lib/sprockets/processor_utils.rb:75:in `call_processor'
/Users/smithd98/.rvm/gems/ruby-2.3.1/gems/sprockets-3.7.0/lib/sprockets/processor_utils.rb:57:in `block in call_processors'
/Users/smithd98/.rvm/gems/ruby-2.3.1/gems/sprockets-3.7.0/lib/sprockets/processor_utils.rb:56:in `reverse_each'
/Users/smithd98/.rvm/gems/ruby-2.3.1/gems/sprockets-3.7.0/lib/sprockets/processor_utils.rb:56:in `call_processors'
/Users/smithd98/.rvm/gems/ruby-2.3.1/gems/sprockets-3.7.0/lib/sprockets/loader.rb:134:in `load_from_unloaded'
/Users/smithd98/.rvm/gems/ruby-2.3.1/gems/sprockets-3.7.0/lib/sprockets/loader.rb:60:in `block in load'
/Users/smithd98/.rvm/gems/ruby-2.3.1/gems/sprockets-3.7.0/lib/sprockets/loader.rb:317:in `fetch_asset_from_dependency_cache'
/Users/smithd98/.rvm/gems/ruby-2.3.1/gems/sprockets-3.7.0/lib/sprockets/loader.rb:44:in `load'
/Users/smithd98/.rvm/gems/ruby-2.3.1/gems/sprockets-3.7.0/lib/sprockets/cached_environment.rb:20:in `block in initialize'
/Users/smithd98/.rvm/gems/ruby-2.3.1/gems/sprockets-3.7.0/lib/sprockets/cached_environment.rb:47:in `load'
/Users/smithd98/.rvm/gems/ruby-2.3.1/gems/sprockets-3.7.0/lib/sprockets/base.rb:66:in `find_asset'
/Users/smithd98/.rvm/gems/ruby-2.3.1/gems/sprockets-3.7.0/lib/sprockets/base.rb:73:in `find_all_linked_assets'
/Users/smithd98/.rvm/gems/ruby-2.3.1/gems/sprockets-3.7.0/lib/sprockets/manifest.rb:142:in `block in find'
/Users/smithd98/.rvm/gems/ruby-2.3.1/gems/sprockets-3.7.0/lib/sprockets/legacy.rb:114:in `block (2 levels) in logical_paths'
/Users/smithd98/.rvm/gems/ruby-2.3.1/gems/sprockets-3.7.0/lib/sprockets/path_utils.rb:228:in `block in stat_tree'
/Users/smithd98/.rvm/gems/ruby-2.3.1/gems/sprockets-3.7.0/lib/sprockets/path_utils.rb:212:in `block in stat_directory'
/Users/smithd98/.rvm/gems/ruby-2.3.1/gems/sprockets-3.7.0/lib/sprockets/path_utils.rb:209:in `each'
/Users/smithd98/.rvm/gems/ruby-2.3.1/gems/sprockets-3.7.0/lib/sprockets/path_utils.rb:209:in `stat_directory'
/Users/smithd98/.rvm/gems/ruby-2.3.1/gems/sprockets-3.7.0/lib/sprockets/path_utils.rb:227:in `stat_tree'
/Users/smithd98/.rvm/gems/ruby-2.3.1/gems/sprockets-3.7.0/lib/sprockets/legacy.rb:105:in `each'
/Users/smithd98/.rvm/gems/ruby-2.3.1/gems/sprockets-3.7.0/lib/sprockets/legacy.rb:105:in `block in logical_paths'
/Users/smithd98/.rvm/gems/ruby-2.3.1/gems/sprockets-3.7.0/lib/sprockets/legacy.rb:104:in `each'
/Users/smithd98/.rvm/gems/ruby-2.3.1/gems/sprockets-3.7.0/lib/sprockets/legacy.rb:104:in `logical_paths'
/Users/smithd98/.rvm/gems/ruby-2.3.1/gems/sprockets-3.7.0/lib/sprockets/manifest.rb:140:in `find'
/Users/smithd98/.rvm/gems/ruby-2.3.1/gems/sprockets-3.7.0/lib/sprockets/manifest.rb:185:in `compile'
/Users/smithd98/.rvm/gems/ruby-2.3.1/gems/sprockets-rails-3.1.1/lib/sprockets/rails/task.rb:68:in `block (3 levels) in define'
/Users/smithd98/.rvm/gems/ruby-2.3.1/gems/sprockets-3.7.0/lib/rake/sprocketstask.rb:147:in `with_logger'
/Users/smithd98/.rvm/gems/ruby-2.3.1/gems/sprockets-rails-3.1.1/lib/sprockets/rails/task.rb:67:in `block (2 levels) in define'
/Users/smithd98/.rvm/gems/ruby-2.3.1/gems/rake-11.2.2/lib/rake/task.rb:248:in `block in execute'
/Users/smithd98/.rvm/gems/ruby-2.3.1/gems/rake-11.2.2/lib/rake/task.rb:243:in `each'
/Users/smithd98/.rvm/gems/ruby-2.3.1/gems/rake-11.2.2/lib/rake/task.rb:243:in `execute'
/Users/smithd98/.rvm/gems/ruby-2.3.1/gems/rake-11.2.2/lib/rake/task.rb:187:in `block in invoke_with_call_chain'
/Users/smithd98/.rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0/monitor.rb:214:in `mon_synchronize'
/Users/smithd98/.rvm/gems/ruby-2.3.1/gems/rake-11.2.2/lib/rake/task.rb:180:in `invoke_with_call_chain'
/Users/smithd98/.rvm/gems/ruby-2.3.1/gems/rake-11.2.2/lib/rake/task.rb:173:in `invoke'
/Users/smithd98/.rvm/gems/ruby-2.3.1/gems/rake-11.2.2/lib/rake/application.rb:152:in `invoke_task'
/Users/smithd98/.rvm/gems/ruby-2.3.1/gems/rake-11.2.2/lib/rake/application.rb:108:in `block (2 levels) in top_level'
/Users/smithd98/.rvm/gems/ruby-2.3.1/gems/rake-11.2.2/lib/rake/application.rb:108:in `each'
/Users/smithd98/.rvm/gems/ruby-2.3.1/gems/rake-11.2.2/lib/rake/application.rb:108:in `block in top_level'
/Users/smithd98/.rvm/gems/ruby-2.3.1/gems/rake-11.2.2/lib/rake/application.rb:117:in `run_with_threads'
/Users/smithd98/.rvm/gems/ruby-2.3.1/gems/rake-11.2.2/lib/rake/application.rb:102:in `top_level'
/Users/smithd98/.rvm/gems/ruby-2.3.1/gems/rake-11.2.2/lib/rake/application.rb:80:in `block in run'
/Users/smithd98/.rvm/gems/ruby-2.3.1/gems/rake-11.2.2/lib/rake/application.rb:178:in `standard_exception_handling'
/Users/smithd98/.rvm/gems/ruby-2.3.1/gems/rake-11.2.2/lib/rake/application.rb:77:in `run'
/Users/smithd98/.rvm/gems/ruby-2.3.1/gems/rake-11.2.2/exe/rake:27:in `<top (required)>'
/Users/smithd98/.rvm/gems/ruby-2.3.1/bin/rake:23:in `load'
/Users/smithd98/.rvm/gems/ruby-2.3.1/bin/rake:23:in `<main>'
/Users/smithd98/.rvm/gems/ruby-2.3.1/bin/ruby_executable_hooks:15:in `eval'
/Users/smithd98/.rvm/gems/ruby-2.3.1/bin/ruby_executable_hooks:15:in `<main>'
I modified the gem to spit out the filename
subl /Users/smithd98/.rvm/gems/ruby-2.3.1/gems/sprockets-3.7.0/lib/sprockets/sass_processor.rb:124:in
like this
def asset_path(path, options = {})
path = path.value
puts path
puts '123'
path, _, query, fragment = URI.split(path)[5..8]
puts '126'
path = sprockets_context.asset_path(path, options)
puts '128'
query = "?#{query}" if query
puts '130'
fragment = "##{fragment}" if fragment
puts '132'
Autoload::Sass::Script::String.new("#{path}#{query}#{fragment}", :string)
end
Then when I ran
RAILS_ENV=production SECRET_KEY_BASE=xxx rake assets:precompile --trace
I got
** Invoke assets:precompile (first_time)
** Invoke assets:environment (first_time)
** Execute assets:environment
** Invoke environment (first_time)
** Execute environment
** Execute assets:precompile
fonts/OpenSans-Light.ttf
123
126
rake aborted!
NoMethodError: undefined method `[]' for nil:NilClass
/Users/smithd98/.rvm/gems/ruby-2.3.1/gems/sprockets-3.7.0/lib/sprockets/sass_processor.rb:283:in `sprockets_context'
...the rest of the stack trace is the same...
Then I found out the issue was a font had been specified like this:
.btn-rect {
font-family: 'OpenSans-Light';
src:font-url('fonts/OpenSans-Light.ttf') format('truetype');
}
and should have been like this:
.btn-rect {
font-family: 'OpenSans-Light';
}
Instead of config.assets.compile = true use config.serve_static_assets = true
The first option is incorrect, because it tells your server to go back to serving the app/assets folder.

Resources