Rails 6 on Heroku: `SassC::SyntaxError: Error: Undefined variable: "$body-bg"`

2.8k views Asked by At

After upgrading from Rails 5 to Rails 6.0.3.1, my SCSS won't compile on Heroku:

remote:        yarn install v1.16.0
remote:        [1/4] Resolving packages...
remote:        [2/4] Fetching packages...
remote:        info [email protected]: The platform "linux" is incompatible with this module.
remote:        info "[email protected]" is an optional dependency and failed compatibility check. Excluding it from installation.
remote:        [3/4] Linking dependencies...
remote:        warning "@rails/webpacker > [email protected]" has unmet peer dependency "caniuse-lite@^1.0.30000697".
remote:        warning " > [email protected]" has unmet peer dependency "webpack@^2.2.0 || ^3.0.0".
remote:        warning "webpack-dev-server > [email protected]" has unmet peer dependency "webpack@^1.0.0 || ^2.0.0 || ^3.0.0".
remote:        [4/4] Building fresh packages...
remote:        Done in 5.09s.
remote:        rake aborted!
remote:        SassC::SyntaxError: Error: Undefined variable: "$body-bg".
remote:                on line 22:21 of app/assets/stylesheets/override_darkmode.scss
remote:        >>   background-color: $body-bg;
remote:
remote:           --------------------^
remote:        /tmp/build_2fccbc688d4b92273fdbd9ffef333655/app/assets/stylesheets/override_darkmode.scss:22
remote:        /tmp/build_2fccbc688d4b92273fdbd9ffef333655/vendor/bundle/ruby/2.6.0/gems/sassc-2.4.0/lib/sassc/engine.rb:50:in `render'
remote:        /tmp/build_2fccbc688d4b92273fdbd9ffef333655/vendor/bundle/ruby/2.6.0/gems/sassc-rails-2.1.2/lib/sassc/rails/template.rb:40:in `block in call'
remote:        /tmp/build_2fccbc688d4b92273fdbd9ffef333655/vendor/bundle/ruby/2.6.0/gems/sprockets-4.0.2/lib/sprockets/utils.rb:138:in `module_include'
remote:        /tmp/build_2fccbc688d4b92273fdbd9ffef333655/vendor/bundle/ruby/2.6.0/gems/sassc-rails-2.1.2/lib/sassc/rails/template.rb:39:in `call'
remote:        /tmp/build_2fccbc688d4b92273fdbd9ffef333655/vendor/bundle/ruby/2.6.0/gems/sprockets-4.0.2/lib/sprockets/processor_utils.rb:84:in `call_processor'
remote:        /tmp/build_2fccbc688d4b92273fdbd9ffef333655/vendor/bundle/ruby/2.6.0/gems/sprockets-4.0.2/lib/sprockets/processor_utils.rb:66:in `block in call_processors'
remote:        /tmp/build_2fccbc688d4b92273fdbd9ffef333655/vendor/bundle/ruby/2.6.0/gems/sprockets-4.0.2/lib/sprockets/processor_utils.rb:65:in `reverse_each'
remote:        /tmp/build_2fccbc688d4b92273fdbd9ffef333655/vendor/bundle/ruby/2.6.0/gems/sprockets-4.0.2/lib/sprockets/processor_utils.rb:65:in `call_processors'
remote:        /tmp/build_2fccbc688d4b92273fdbd9ffef333655/vendor/bundle/ruby/2.6.0/gems/sprockets-4.0.2/lib/sprockets/processor_utils.rb:22:in `block in <class:CompositeProcessor>'
remote:        /tmp/build_2fccbc688d4b92273fdbd9ffef333655/vendor/bundle/ruby/2.6.0/gems/sprockets-4.0.2/lib/sprockets/processor_utils.rb:33:in `call'
remote:        /tmp/build_2fccbc688d4b92273fdbd9ffef333655/vendor/bundle/ruby/2.6.0/gems/sprockets-4.0.2/lib/sprockets/processor_utils.rb:84:in `call_processor'
remote:        /tmp/build_2fccbc688d4b92273fdbd9ffef333655/vendor/bundle/ruby/2.6.0/gems/sprockets-4.0.2/lib/sprockets/processor_utils.rb:66:in `block in call_processors'
remote:        /tmp/build_2fccbc688d4b92273fdbd9ffef333655/vendor/bundle/ruby/2.6.0/gems/sprockets-4.0.2/lib/sprockets/processor_utils.rb:65:in `reverse_each'
remote:        /tmp/build_2fccbc688d4b92273fdbd9ffef333655/vendor/bundle/ruby/2.6.0/gems/sprockets-4.0.2/lib/sprockets/processor_utils.rb:65:in `call_processors'
remote:        /tmp/build_2fccbc688d4b92273fdbd9ffef333655/vendor/bundle/ruby/2.6.0/gems/sprockets-4.0.2/lib/sprockets/loader.rb:182:in `load_from_unloaded'
remote:        /tmp/build_2fccbc688d4b92273fdbd9ffef333655/vendor/bundle/ruby/2.6.0/gems/sprockets-4.0.2/lib/sprockets/loader.rb:59:in `block in load'
remote:        /tmp/build_2fccbc688d4b92273fdbd9ffef333655/vendor/bundle/ruby/2.6.0/gems/sprockets-4.0.2/lib/sprockets/loader.rb:337:in `fetch_asset_from_dependency_cache'
remote:        /tmp/build_2fccbc688d4b92273fdbd9ffef333655/vendor/bundle/ruby/2.6.0/gems/sprockets-4.0.2/lib/sprockets/loader.rb:43:in `load'
remote:        /tmp/build_2fccbc688d4b92273fdbd9ffef333655/vendor/bundle/ruby/2.6.0/gems/sprockets-4.0.2/lib/sprockets/cached_environment.rb:44:in `load'
remote:        /tmp/build_2fccbc688d4b92273fdbd9ffef333655/vendor/bundle/ruby/2.6.0/gems/sprockets-4.0.2/lib/sprockets/bundle.rb:27:in `call'
remote:        /tmp/build_2fccbc688d4b92273fdbd9ffef333655/vendor/bundle/ruby/2.6.0/gems/sprockets-4.0.2/lib/sprockets/processor_utils.rb:84:in `call_processor'
remote:        /tmp/build_2fccbc688d4b92273fdbd9ffef333655/vendor/bundle/ruby/2.6.0/gems/sprockets-4.0.2/lib/sprockets/processor_utils.rb:66:in `block in call_processors'
remote:        /tmp/build_2fccbc688d4b92273fdbd9ffef333655/vendor/bundle/ruby/2.6.0/gems/sprockets-4.0.2/lib/sprockets/processor_utils.rb:65:in `reverse_each'
remote:        /tmp/build_2fccbc688d4b92273fdbd9ffef333655/vendor/bundle/ruby/2.6.0/gems/sprockets-4.0.2/lib/sprockets/processor_utils.rb:65:in `call_processors'
remote:        /tmp/build_2fccbc688d4b92273fdbd9ffef333655/vendor/bundle/ruby/2.6.0/gems/sprockets-4.0.2/lib/sprockets/loader.rb:182:in `load_from_unloaded'
remote:        /tmp/build_2fccbc688d4b92273fdbd9ffef333655/vendor/bundle/ruby/2.6.0/gems/sprockets-4.0.2/lib/sprockets/loader.rb:59:in `block in load'
remote:        /tmp/build_2fccbc688d4b92273fdbd9ffef333655/vendor/bundle/ruby/2.6.0/gems/sprockets-4.0.2/lib/sprockets/loader.rb:337:in `fetch_asset_from_dependency_cache'
remote:        /tmp/build_2fccbc688d4b92273fdbd9ffef333655/vendor/bundle/ruby/2.6.0/gems/sprockets-4.0.2/lib/sprockets/loader.rb:43:in `load'
remote:        /tmp/build_2fccbc688d4b92273fdbd9ffef333655/vendor/bundle/ruby/2.6.0/gems/sprockets-4.0.2/lib/sprockets/cached_environment.rb:44:in `load'
remote:        /tmp/build_2fccbc688d4b92273fdbd9ffef333655/vendor/bundle/ruby/2.6.0/gems/sprockets-4.0.2/lib/sprockets/bundle.rb:32:in `block in call'
remote:        /tmp/build_2fccbc688d4b92273fdbd9ffef333655/vendor/bundle/ruby/2.6.0/gems/sprockets-4.0.2/lib/sprockets/bundle.rb:31:in `call'
remote:        /tmp/build_2fccbc688d4b92273fdbd9ffef333655/vendor/bundle/ruby/2.6.0/gems/sprockets-4.0.2/lib/sprockets/processor_utils.rb:84:in `call_processor'
remote:        /tmp/build_2fccbc688d4b92273fdbd9ffef333655/vendor/bundle/ruby/2.6.0/gems/sprockets-4.0.2/lib/sprockets/processor_utils.rb:66:in `block in call_processors'
remote:        /tmp/build_2fccbc688d4b92273fdbd9ffef333655/vendor/bundle/ruby/2.6.0/gems/sprockets-4.0.2/lib/sprockets/processor_utils.rb:65:in `reverse_each'
remote:        /tmp/build_2fccbc688d4b92273fdbd9ffef333655/vendor/bundle/ruby/2.6.0/gems/sprockets-4.0.2/lib/sprockets/processor_utils.rb:65:in `call_processors'
remote:        /tmp/build_2fccbc688d4b92273fdbd9ffef333655/vendor/bundle/ruby/2.6.0/gems/sprockets-4.0.2/lib/sprockets/loader.rb:182:in `load_from_unloaded'
remote:        /tmp/build_2fccbc688d4b92273fdbd9ffef333655/vendor/bundle/ruby/2.6.0/gems/sprockets-4.0.2/lib/sprockets/loader.rb:59:in `block in load'
remote:        /tmp/build_2fccbc688d4b92273fdbd9ffef333655/vendor/bundle/ruby/2.6.0/gems/sprockets-4.0.2/lib/sprockets/loader.rb:337:in `fetch_asset_from_dependency_cache'
remote:        /tmp/build_2fccbc688d4b92273fdbd9ffef333655/vendor/bundle/ruby/2.6.0/gems/sprockets-4.0.2/lib/sprockets/loader.rb:43:in `load'
remote:        /tmp/build_2fccbc688d4b92273fdbd9ffef333655/vendor/bundle/ruby/2.6.0/gems/sprockets-4.0.2/lib/sprockets/cached_environment.rb:44:in `load'
remote:        /tmp/build_2fccbc688d4b92273fdbd9ffef333655/vendor/bundle/ruby/2.6.0/gems/sprockets-4.0.2/lib/sprockets/base.rb:81:in `find_asset'
remote:        /tmp/build_2fccbc688d4b92273fdbd9ffef333655/vendor/bundle/ruby/2.6.0/gems/sprockets-4.0.2/lib/sprockets/base.rb:88:in `find_all_linked_assets'
remote:        /tmp/build_2fccbc688d4b92273fdbd9ffef333655/vendor/bundle/ruby/2.6.0/gems/sprockets-4.0.2/lib/sprockets/manifest.rb:125:in `block (2 levels) in find'
remote:        /tmp/build_2fccbc688d4b92273fdbd9ffef333655/vendor/bundle/ruby/2.6.0/gems/concurrent-ruby-1.1.6/lib/concurrent-ruby/concurrent/executor/safe_task_executor.rb:24:in `block in execute'
remote:        /tmp/build_2fccbc688d4b92273fdbd9ffef333655/vendor/bundle/ruby/2.6.0/gems/concurrent-ruby-1.1.6/lib/concurrent-ruby/concurrent/synchronization/mutex_lockable_object.rb:41:in `block in synchronize'
remote:        /tmp/build_2fccbc688d4b92273fdbd9ffef333655/vendor/bundle/ruby/2.6.0/gems/concurrent-ruby-1.1.6/lib/concurrent-ruby/concurrent/synchronization/mutex_lockable_object.rb:41:in `synchronize'
remote:        /tmp/build_2fccbc688d4b92273fdbd9ffef333655/vendor/bundle/ruby/2.6.0/gems/concurrent-ruby-1.1.6/lib/concurrent-ruby/concurrent/synchronization/mutex_lockable_object.rb:41:in `synchronize'
remote:        /tmp/build_2fccbc688d4b92273fdbd9ffef333655/vendor/bundle/ruby/2.6.0/gems/concurrent-ruby-1.1.6/lib/concurrent-ruby/concurrent/executor/safe_task_executor.rb:19:in `execute'
remote:        /tmp/build_2fccbc688d4b92273fdbd9ffef333655/vendor/bundle/ruby/2.6.0/gems/concurrent-ruby-1.1.6/lib/concurrent-ruby/concurrent/promise.rb:563:in `block in realize'
remote:        /tmp/build_2fccbc688d4b92273fdbd9ffef333655/vendor/bundle/ruby/2.6.0/gems/concurrent-ruby-1.1.6/lib/concurrent-ruby/concurrent/executor/ruby_thread_pool_executor.rb:353:in `run_task'
remote:        /tmp/build_2fccbc688d4b92273fdbd9ffef333655/vendor/bundle/ruby/2.6.0/gems/concurrent-ruby-1.1.6/lib/concurrent-ruby/concurrent/executor/ruby_thread_pool_executor.rb:342:in `block (3 levels) in create_worker'
remote:        /tmp/build_2fccbc688d4b92273fdbd9ffef333655/vendor/bundle/ruby/2.6.0/gems/concurrent-ruby-1.1.6/lib/concurrent-ruby/concurrent/executor/ruby_thread_pool_executor.rb:325:in `loop'
remote:        /tmp/build_2fccbc688d4b92273fdbd9ffef333655/vendor/bundle/ruby/2.6.0/gems/concurrent-ruby-1.1.6/lib/concurrent-ruby/concurrent/executor/ruby_thread_pool_executor.rb:325:in `block (2 levels) in create_worker'
remote:        /tmp/build_2fccbc688d4b92273fdbd9ffef333655/vendor/bundle/ruby/2.6.0/gems/concurrent-ruby-1.1.6/lib/concurrent-ruby/concurrent/executor/ruby_thread_pool_executor.rb:324:in `catch'
remote:        /tmp/build_2fccbc688d4b92273fdbd9ffef333655/vendor/bundle/ruby/2.6.0/gems/concurrent-ruby-1.1.6/lib/concurrent-ruby/concurrent/executor/ruby_thread_pool_executor.rb:324:in `block in create_worker'
remote:        Tasks: TOP => assets:precompile
remote:        (See full trace by running task with --trace)
remote:
remote:  !
remote:  !     Precompiling assets failed.
remote:  !
remote:  !     Push rejected, failed to compile Ruby app.

override_darkmode.scss :

input {
  background-color: $body-bg;
}

application-dark.scss :

$body-bg: #2d2d2d;

@import 'override_darkmode';

I use gems:

gem 'sass-rails', '>= 6'
gem 'bootstrap-sass'

resolved to:

    bootstrap-sass (3.4.1)
      autoprefixer-rails (>= 5.2.1)
      sassc (>= 2.0.0)
    sass-rails (6.0.0)
      sassc-rails (~> 2.1, >= 2.1.1)
    sassc (2.4.0)
    sassc-rails (2.1.2)
      sassc (>= 2.0)

Update: after rake assets:clean, a different error happens: Segmentation Fault:

remote:        [4/4] Building fresh packages...
remote:        Done in 5.26s.
remote:        /tmp/build_b13f5fdf4f65289fdc5aa3d30752d7e5/vendor/bundle/ruby/2.6.0/gems/sassc-2.4.0/lib/sassc/engine.rb:43: [BUG] Segmentation fault at 0x0000000000000000
remote:        ruby 2.6.6p146 (2020-03-31 revision 67876) [x86_64-linux]
remote:
remote:        -- Control frame information -----------------------------------------------
remote:        c:0059 p:---- s:0449 e:000448 CFUNC  :compile_data_context
remote:        c:0058 p:0318 s:0444 e:000443 METHOD /tmp/build_b13f5fdf4f65289fdc5aa3d30752d7e5/vendor/bundle/ruby/2.6.0/gems/sassc-2.4.0/lib/sassc/engine.rb:43
remote:        c:0057 p:0006 s:0432 e:000431 BLOCK  /tmp/build_b13f5fdf4f65289fdc5aa3d30752d7e5/vendor/bundle/ruby/2.6.0/gems/sassc-rails-2.1.2/lib/sassc/rails/template.rb:40
remote:        c:0056 p:0028 s:0429 e:000428 METHOD /tmp/build_b13f5fdf4f65289fdc5aa3d30752d7e5/vendor/bundle/ruby/2.6.0/gems/sprockets-4.0.2/lib/sprockets/utils.rb:138
remote:        c:0055 p:0164 s:0422 e:000421 METHOD /tmp/build_b13f5fdf4f65289fdc5aa3d30752d7e5/vendor/bundle/ruby/2.6.0/gems/sassc-rails-2.1.2/lib/sassc/rails/template.rb:39
remote:        c:0054 p:0053 s:0413 e:000412 METHOD /tmp/build_b13f5fdf4f65289fdc5aa3d30752d7e5/vendor/bundle/ruby/2.6.0/gems/sprockets-4.0.2/lib/sprockets/processor_utils.rb:84
remote:        c:0053 p:0016 s:0405 e:000404 BLOCK  /tmp/build_b13f5fdf4f65289fdc5aa3d30752d7e5/vendor/bundle/ruby/2.6.0/gems/sprockets-4.0.2/lib/sprockets/processor_utils.rb:66 [FINISH]
remote:        c:0052 p:---- s:0400 e:000399 CFUNC  :reverse_each
remote:        c:0051 p:0039 s:0396 e:000395 METHOD /tmp/build_b13f5fdf4f65289fdc5aa3d30752d7e5/vendor/bundle/ruby/2.6.0/gems/sprockets-4.0.2/lib/sprockets/processor_utils.rb:65
remote:        c:0050 p:0015 s:0388 e:000387 BLOCK  /tmp/build_b13f5fdf4f65289fdc5aa3d30752d7e5/vendor/bundle/ruby/2.6.0/gems/sprockets-4.0.2/lib/sprockets/processor_utils.rb:22
remote:        c:0049 p:0013 s:0383 e:000382 METHOD /tmp/build_b13f5fdf4f65289fdc5aa3d30752d7e5/vendor/bundle/ruby/2.6.0/gems/sprockets-4.0.2/lib/sprockets/processor_utils.rb:33
remote:        c:0048 p:0053 s:0378 e:000377 METHOD /tmp/build_b13f5fdf4f65289fdc5aa3d30752d7e5/vendor/bundle/ruby/2.6.0/gems/sprockets-4.0.2/lib/sprockets/processor_utils.rb:84
remote:        c:0047 p:0016 s:0370 e:000369 BLOCK  /tmp/build_b13f5fdf4f65289fdc5aa3d30752d7e5/vendor/bundle/ruby/2.6.0/gems/sprockets-4.0.2/lib/sprockets/processor_utils.rb:66 [FINISH]
remote:        c:0046 p:---- s:0365 e:000364 CFUNC  :reverse_each
remote:        c:0045 p:0039 s:0361 e:000360 METHOD /tmp/build_b13f5fdf4f65289fdc5aa3d30752d7e5/vendor/bundle/ruby/2.6.0/gems/sprockets-4.0.2/lib/sprockets/processor_utils.rb:65
remote:        c:0044 p:0476 s:0353 e:000352 METHOD /tmp/build_b13f5fdf4f65289fdc5aa3d30752d7e5/vendor/bundle/ruby/2.6.0/gems/sprockets-4.0.2/lib/sprockets/loader.rb:182
remote:        c:0043 p:0073 s:0331 e:000330 BLOCK  /tmp/build_b13f5fdf4f65289fdc5aa3d30752d7e5/vendor/bundle/ruby/2.6.0/gems/sprockets-4.0.2/lib/sprockets/loader.rb:59
remote:        c:0042 p:0038 s:0325 e:000324 METHOD /tmp/build_b13f5fdf4f65289fdc5aa3d30752d7e5/vendor/bundle/ruby/2.6.0/gems/sprockets-4.0.2/lib/sprockets/loader.rb:337
remote:        c:0041 p:0157 s:0315 e:000314 METHOD /tmp/build_b13f5fdf4f65289fdc5aa3d30752d7e5/vendor/bundle/ruby/2.6.0/gems/sprockets-4.0.2/lib/sprockets/loader.rb:43
remote:        c:0040 p:0022 s:0306 e:000302 METHOD /tmp/build_b13f5fdf4f65289fdc5aa3d30752d7e5/vendor/bundle/ruby/2.6.0/gems/sprockets-4.0.2/lib/sprockets/cached_environment.rb:4
remote:        c:0039 p:0111 s:0298 e:000297 METHOD /tmp/build_b13f5fdf4f65289fdc5aa3d30752d7e5/vendor/bundle/ruby/2.6.0/gems/sprockets-4.0.2/lib/sprockets/bundle.rb:27
remote:        c:0038 p:0053 s:0280 e:000279 METHOD /tmp/build_b13f5fdf4f65289fdc5aa3d30752d7e5/vendor/bundle/ruby/2.6.0/gems/sprockets-4.0.2/lib/sprockets/processor_utils.rb:84
remote:        c:0037 p:0016 s:0272 e:000271 BLOCK  /tmp/build_b13f5fdf4f65289fdc5aa3d30752d7e5/vendor/bundle/ruby/2.6.0/gems/sprockets-4.0.2/lib/sprockets/processor_utils.rb:66 [FINISH]
remote:        c:0036 p:---- s:0267 e:000266 CFUNC  :reverse_each
remote:        c:0035 p:0039 s:0263 e:000262 METHOD 
...

Related: https://github.com/sass/sassc-rails/issues/122

1

There are 1 answers

0
vmarquet On BEST ANSWER

Fixed by removing all config.assets.precompile calls in config files and using app/assets/config/manifest.js instead.

cf https://github.com/rails/sprockets/blob/8fc492abde6b20afbe6fa5d5aa7d1085aafd3527/UPGRADING.md#manifestjs