Can't push to heroku, sassc segmentation fault

Viewed 1522

I am having trouble pushing to heroku, I've already tried others solutions related to Precompiling assets failed., like modifing application.rb to disable precompiled assets, running rake assets:precompile, and updating to rails 6.3.1 to prevent mimemagic recent error.

Taking a look at heroku logs, I noticed:

tmp/build_7857ebbd/vendor/bundle/ruby/3.0.0/gems/sassc-2.4.0/lib/sassc/engine.rb:43: [BUG] Segmentation fault at 0x0000000000000000 ruby 3.0.0p0 (2020-12-25 revision 95aff21468) [x86_64-linux]

Part of heroku's log

       ...
       yarn install v1.22.4
       [1/4] Resolving packages...
       [2/4] Fetching packages...
       info fsevents@2.1.3: The platform "linux" is incompatible with this module.
       info "fsevents@2.1.3" is an optional dependency and failed compatibility check. Excluding it from installation.
       info fsevents@1.2.13: The platform "linux" is incompatible with this module.
       info "fsevents@1.2.13" is an optional dependency and failed compatibility check. Excluding it from installation.
       [3/4] Linking dependencies...
       [4/4] Building fresh packages...
       Done in 5.07s.
       /tmp/build_7857ebbd/vendor/bundle/ruby/3.0.0/gems/sassc-2.4.0/lib/sassc/engine.rb:43: [BUG] Segmentation fault at 0x0000000000000000
       ruby 3.0.0p0 (2020-12-25 revision 95aff21468) [x86_64-linux]
       
       -- Control frame information -----------------------------------------------
       c:0042 p:---- s:0308 e:000307 CFUNC  :compile_data_context
       c:0041 p:0314 s:0303 e:000302 METHOD /tmp/build_7857ebbd/vendor/bundle/ruby/3.0.0/gems/sassc-2.4.0/lib/sassc/engine.rb:43
       c:0040 p:0044 s:0291 e:000290 METHOD /tmp/build_7857ebbd/vendor/bundle/ruby/3.0.0/gems/sassc-rails-2.1.2/lib/sassc/rails/compressor.rb:29
       c:0039 p:0007 s:0285 e:000284 METHOD /tmp/build_7857ebbd/vendor/bundle/ruby/3.0.0/gems/sprockets-4.0.2/lib/sprockets/sass_compressor.rb:30
       c:0038 p:0047 s:0280 e:000279 METHOD /tmp/build_7857ebbd/vendor/bundle/ruby/3.0.0/gems/sprockets-4.0.2/lib/sprockets/processor_utils.rb:84
       c:0037 p:0014 s:0272 e:000271 BLOCK  /tmp/build_7857ebbd/vendor/bundle/ruby/3.0.0/gems/sprockets-4.0.2/lib/sprockets/processor_utils.rb:66 [FINISH]
       .....
       c:0036 p:---- s:0267 e:000266 CFUNC  :reverse_each
  7f104d3bd000-7f104d3be000 rw-p 00000000 00:00 0 
       7fffab4a6000-7fffac4a5000 rw-p 00000000 00:00 0                          [stack]
       7fffac503000-7fffac505000 r--p 00000000 00:00 0                          [vvar]
       7fffac505000-7fffac507000 r-xp 00000000 00:00 0                          [vdso]
       ffffffffff600000-ffffffffff601000 r-xp 00000000 00:00 0                  [vsyscall]
       
       
       Aborted
 !
 !     Precompiling assets failed.
 !
 !     Push rejected, failed to compile Ruby app.
 !     Push failed
3 Answers

Based on the same thread, I found this solution more suitable than downgrading a bunch of gems.

Putting this at the top of your initializers/assets.rb enabled the assets to compile successfully

# config/initializers/assets.rb
Rails.application.config.assets.configure do |env|
  env.export_concurrent = false
end

Still a hack, but another option.

Source: https://github.com/sass/sassc-ruby/issues/197#issuecomment-735359755

It seems to be a recent bug as reported in issue 133 and 197

One solution is to use an older sassc version. In particular, I've tried:

gem 'sassc', '~> 2.0', '>= 2.0.1'
gem 'sprockets', '~> 3.7.2'
gem 'sass-rails', '~> 5.1.0 ' 
gem 'concurrent-ruby',  '~>1.1.5'

Which works just fine. All available versions are listed here

I've seen sassc segmentation fault errors before when upgrading between Ruby versions on heroku (in this case it was from Ruby 3.1.0 to 3.1.1). I recommend trying two things first:

  1. Make sure you can precompile production assets locally RAILS_ENV=production rails assets:precompile
  2. Clear the Heroku build cache:
    • Install heroku-repo plugin heroku plugins:install heroku-repo
    • heroku repo:purge_cache -a appname
    • redeploy to Heroku
Related