sprocketsruby-on-rails-7dart-sassrails-sprocketsruby-3.1

LoadError: cannot load such file -- sassc


running rake assets:precompile ends with the error. Can't find why it still requires sassc, sassc only was in project when migrated to sprockets 4 using Guide to upgrading from Sprockets 3.x to 4.x:

gem 'sass-rails', '>= 5'
bundle update sass-rails sprockets

and then followed dartsass-rails install documentation. did:

rails tmp:clear
rake assets:clobber
rake assets:precompile

ruby-3.1.2

gem 'rails', '7.0.3.1'
gem 'webrick'
gem 'sprockets-rails', '~> 3.4', '>= 3.4.2'
gem 'dartsass-rails', '~> 0.4.0'
...

manifest.js file content:

//= link_tree ../images
//= link application.css
//= link application.js
//
//= link_tree ../builds

error log:

** Invoke assets:precompile (first_time)
** Invoke assets:environment (first_time)
** Execute assets:environment
** Invoke environment (first_time)
** Execute environment
** Invoke dartsass:build (first_time)
** Invoke environment 
** Execute dartsass:build
+ /.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/dartsass-rails-0.4.0/exe/darwin/sass --style\=compressed --no-source-map --load-path 

/app/assets/stylesheets --load-path 
/app/assets/builds --load-path 
/app/assets/config --load-path 
/app/assets/fonts --load-path 
/app/assets/images --load-path 
/app/assets/javascripts --load-path 
/app/assets/stylesheets --load-path 
/lib/assets/javascripts --load-path 
/lib/assets/stylesheets --load-path 
/vendor/assets/javascripts --load-path 
/vendor/assets/stylesheets --load-path 

/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/bundler/gems/flex_calendar-aae0ac1c9b3f/app/assets/javascripts --load-path 
/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/bundler/gems/flex_calendar-aae0ac1c9b3f/app/assets/images --load-path 
/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/bundler/gems/flex_calendar-aae0ac1c9b3f/app/assets/stylesheets --load-path 
/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/bundler/gems/flex_calendar-aae0ac1c9b3f/lib/assets/javascripts --load-path 
/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/flatpickr-4.5.7.0/vendor/assets/javascripts --load-path 
/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/bundler/gems/flex_calendar-aae0ac1c9b3f/vendor/assets/javascripts --load-path 
/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/flatpickr-4.5.7.0/vendor/assets/stylesheets --load-path 
/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/tinymce-rails-5.10.5/app/assets/javascripts --load-path 
/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/tinymce-rails-5.10.5/app/assets/source --load-path 
/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/tinymce-rails-5.10.5/vendor/assets/config --load-path 
/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/jquery-minicolors-rails-2.2.6.2/vendor/assets/javascripts --load-path 
/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/tinymce-rails-5.10.5/vendor/assets/javascripts --load-path 
/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/jquery-minicolors-rails-2.2.6.2/vendor/assets/stylesheets --load-path 
/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/select2-rails-4.0.13/vendor/assets/javascripts --load-path 
/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/select2-rails-4.0.13/vendor/assets/stylesheets --load-path 
/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/jquery-ui-rails-5.0.5/app/assets/images --load-path 
/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/jquery-ui-rails-5.0.5/app/assets/javascripts --load-path 
/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/jquery-ui-rails-5.0.5/app/assets/stylesheets --load-path 
/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/jquery-rails-4.2.1/vendor/assets/javascripts --load-path 
/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/coffee-rails-5.0.0/lib/assets/javascripts --load-path 
/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/actiontext-7.0.3.1/app/assets/javascripts --load-path 
/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/actiontext-7.0.3.1/app/assets/stylesheets --load-path 
/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/actioncable-7.0.3.1/app/assets/javascripts --load-path 
/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/activestorage-7.0.3.1/app/assets/javascripts --load-path 
/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/actionview-7.0.3.1/lib/assets/compiled --load-path 
/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/react-rails-1.9.0/lib/assets/react-source/development --load-path 
/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/react-rails-1.9.0/lib/assets/javascripts/ --load-path 
/app/assets/fonts 
/app/assets/stylesheets/application.scss:
/app/assets/builds/application.css
  ** Execute assets:precompile
  rake aborted!
  LoadError: cannot load such file -- sassc
 /.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/zeitwerk-2.6.0/lib/zeitwerk/kernel.rb:35:in `require'
 /.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/zeitwerk-2.6.0/lib/zeitwerk/kernel.rb:35:in `require'
 /.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/sprockets-4.1.1/lib/sprockets/autoload/sassc.rb:2:in `<top (required)>'
 /.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/zeitwerk-2.6.0/lib/zeitwerk/kernel.rb:35:in `require'
 /.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/zeitwerk-2.6.0/lib/zeitwerk/kernel.rb:35:in `require'
 /.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/sprockets-4.1.1/lib/sprockets/sassc_processor.rb:42:in `initialize'
 /.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/sprockets-4.1.1/lib/sprockets/sassc_processor.rb:27:in `new'
 /.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/sprockets-4.1.1/lib/sprockets/sassc_processor.rb:27:in `instance'
 /.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/sprockets-4.1.1/lib/sprockets/sassc_processor.rb:31:in `call'
 /.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/sprockets-4.1.1/lib/sprockets/processor_utils.rb:84:in `call_processor'
 /.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/sprockets-4.1.1/lib/sprockets/processor_utils.rb:66:in `block in call_processors'
 /.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/sprockets-4.1.1/lib/sprockets/processor_utils.rb:65:in `reverse_each'
 /.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/sprockets-4.1.1/lib/sprockets/processor_utils.rb:65:in `call_processors'
 /.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/sprockets-4.1.1/lib/sprockets/processor_utils.rb:22:in `block in <class:CompositeProcessor>'
 /.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/sprockets-4.1.1/lib/sprockets/processor_utils.rb:33:in `call'
 /.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/sprockets-4.1.1/lib/sprockets/processor_utils.rb:84:in `call_processor'
 /.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/sprockets-4.1.1/lib/sprockets/processor_utils.rb:66:in `block in call_processors'
 /.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/sprockets-4.1.1/lib/sprockets/processor_utils.rb:65:in `reverse_each'
 /.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/sprockets-4.1.1/lib/sprockets/processor_utils.rb:65:in `call_processors'
 /.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/sprockets-4.1.1/lib/sprockets/loader.rb:182:in `load_from_unloaded'
 /.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/sprockets-4.1.1/lib/sprockets/loader.rb:59:in `block in load'
 /.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/sprockets-4.1.1/lib/sprockets/loader.rb:337:in `fetch_asset_from_dependency_cache'
 /.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/sprockets-4.1.1/lib/sprockets/loader.rb:43:in `load'
 /.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/sprockets-4.1.1/lib/sprockets/cached_environment.rb:44:in `block in load'
 /.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/sprockets-4.1.1/lib/sprockets/cached_environment.rb:44:in `fetch'
 /.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/sprockets-4.1.1/lib/sprockets/cached_environment.rb:44:in `load'
 /.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/sprockets-4.1.1/lib/sprockets/bundle.rb:27:in `call'
 /.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/sprockets-4.1.1/lib/sprockets/processor_utils.rb:84:in `call_processor'
 /.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/sprockets-4.1.1/lib/sprockets/processor_utils.rb:66:in `block in call_processors'
 /.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/sprockets-4.1.1/lib/sprockets/processor_utils.rb:65:in `reverse_each'
 /.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/sprockets-4.1.1/lib/sprockets/processor_utils.rb:65:in `call_processors'
 /.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/sprockets-4.1.1/lib/sprockets/loader.rb:182:in `load_from_unloaded'
 /.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/sprockets-4.1.1/lib/sprockets/loader.rb:59:in `block in load'
 /.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/sprockets-4.1.1/lib/sprockets/loader.rb:337:in `fetch_asset_from_dependency_cache'
 /.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/sprockets-4.1.1/lib/sprockets/loader.rb:43:in `load'
 /.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/sprockets-4.1.1/lib/sprockets/cached_environment.rb:44:in `block in load'
 /.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/sprockets-4.1.1/lib/sprockets/cached_environment.rb:44:in `fetch'
 /.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/sprockets-4.1.1/lib/sprockets/cached_environment.rb:44:in `load'
 /.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/sprockets-4.1.1/lib/sprockets/base.rb:81:in `find_asset'
 /.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/sprockets-4.1.1/lib/sprockets/base.rb:88:in `find_all_linked_assets'
 /.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/sprockets-4.1.1/lib/sprockets/manifest.rb:125:in `each'
 /.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/sprockets-4.1.1/lib/sprockets/manifest.rb:125:in `to_a'
 /.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/sprockets-4.1.1/lib/sprockets/manifest.rb:125:in `block (2 levels) in find'
 /.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/concurrent-ruby-1.1.10/lib/concurrent-ruby/concurrent/executor/safe_task_executor.rb:24:in `block in execute'
 /.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/concurrent-ruby-1.1.10/lib/concurrent-ruby/concurrent/synchronization/mutex_lockable_object.rb:47:in `block in synchronize'
 /.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/concurrent-ruby-1.1.10/lib/concurrent-ruby/concurrent/synchronization/mutex_lockable_object.rb:47:in `synchronize'
 /.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/concurrent-ruby-1.1.10/lib/concurrent-ruby/concurrent/synchronization/mutex_lockable_object.rb:47:in `synchronize'
 /.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/concurrent-ruby-1.1.10/lib/concurrent-ruby/concurrent/executor/safe_task_executor.rb:22:in `execute'
 /.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/concurrent-ruby-1.1.10/lib/concurrent-ruby/concurrent/promise.rb:564:in `block in realize'
 /.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/concurrent-ruby-1.1.10/lib/concurrent-ruby/concurrent/executor/ruby_thread_pool_executor.rb:352:in `run_task'
 /.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/concurrent-ruby-1.1.10/lib/concurrent-ruby/concurrent/executor/ruby_thread_pool_executor.rb:343:in `block (3 levels) in create_worker'
 /.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/concurrent-ruby-1.1.10/lib/concurrent-ruby/concurrent/executor/ruby_thread_pool_executor.rb:334:in `loop'
 /.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/concurrent-ruby-1.1.10/lib/concurrent-ruby/concurrent/executor/ruby_thread_pool_executor.rb:334:in `block (2 levels) in create_worker'
 /.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/concurrent-ruby-1.1.10/lib/concurrent-ruby/concurrent/executor/ruby_thread_pool_executor.rb:333:in `catch'
 /.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/concurrent-ruby-1.1.10/lib/concurrent-ruby/concurrent/executor/ruby_thread_pool_executor.rb:333:in `block in create_worker'
  Tasks: TOP => assets:precompile

OS: mac

When I install gem with dependency on sassc-rails (example pdfjs_viewer-rails) and start server with ./bin/dev , then web starts up and works fine.

Question: Any idea what could be reason of this and what would be possible solution?


Solution

  • Found out the problem: As under stylesheets root folder were extra example.scss file and it was set to precompile with:

    Rails.application.config.assets.precompile += %w( example.css )
    

    This errors showed because file actually had different extension.

    Solution:

    1. Took out example.css from precompilation;
    2. Added file for dartsass to handle it using:
    Rails.application.config.dartsass.builds = {
          "application.scss"    => "application.css",
          "example.scss"        => "example.css"
        }