Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

assets:precompile results in LoadError: cannot load such file -- sassc #3450

Closed
Shpigford opened this issue Dec 18, 2021 · 6 comments
Closed

Comments

@Shpigford
Copy link

New Rails 7 app using esbuild with tailwind with the rails_admin gem.

When I run rake assets:precompile I'm getting LoadError: cannot load such file -- sassc

I removed the sassc-rails gem due a SaasC syntax error.

The only non-vanilla gem I'm adding is rails_admin and it's throwing the Load Error.

Here's the full output of precompiling locally...

rake assets:precompile
yarn install v1.22.15
[1/4] 🔍  Resolving packages...
success Already up-to-date.
✨  Done in 0.06s.
yarn run v1.22.15
$ esbuild app/javascript/*.* --bundle --sourcemap --outdir=app/assets/builds

  app/assets/builds/application.js      185.5kb
  app/assets/builds/application.js.map  301.0kb

✨  Done in 0.13s.
yarn install v1.22.15
[1/4] 🔍  Resolving packages...
success Already up-to-date.
✨  Done in 0.06s.
yarn run v1.22.15
$ tailwindcss -i ./app/assets/stylesheets/application.tailwind.css -o ./app/assets/builds/application.css

Done in 155ms.
✨  Done in 0.52s.
rake aborted!
LoadError: cannot load such file -- sassc

Tasks: TOP => assets:precompile
(See full trace by running task with --trace)

And here's the output from Heroku...

Running: rake assets:precompile
       yarn install v1.22.17
       [1/4] Resolving packages...
       [2/4] Fetching packages...
       [3/4] Linking dependencies...
       [4/4] Building fresh packages...
       success Saved lockfile.
       Done in 4.39s.
       yarn run v1.22.17
       $ esbuild app/javascript/*.* --bundle --sourcemap --outdir=app/assets/builds
       
         app/assets/builds/application.js      185.5kb
         app/assets/builds/application.js.map  301.0kb
       
       Done in 0.11s.
       yarn install v1.22.17
       [1/4] Resolving packages...
       success Already up-to-date.
       Done in 0.13s.
       yarn run v1.22.17
       $ tailwindcss -i ./app/assets/stylesheets/application.tailwind.css -o ./app/assets/builds/application.css
       
       Done in 440ms.
       Done in 0.99s.
       rake aborted!
       LoadError: cannot load such file -- sassc
       /tmp/build_7c167d00/vendor/bundle/ruby/3.0.0/gems/bootsnap-1.9.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:34:in `require'
       /tmp/build_7c167d00/vendor/bundle/ruby/3.0.0/gems/zeitwerk-2.5.1/lib/zeitwerk/kernel.rb:35:in `require'
       /tmp/build_7c167d00/vendor/bundle/ruby/3.0.0/gems/sprockets-4.0.2/lib/sprockets/autoload/sassc.rb:2:in `<main>'
       /tmp/build_7c167d00/vendor/bundle/ruby/3.0.0/gems/bootsnap-1.9.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `require'
       /tmp/build_7c167d00/vendor/bundle/ruby/3.0.0/gems/bootsnap-1.9.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `block in require_with_bootsnap_lfi'
       /tmp/build_7c167d00/vendor/bundle/ruby/3.0.0/gems/bootsnap-1.9.3/lib/bootsnap/load_path_cache/loaded_features_index.rb:100:in `register'
       /tmp/build_7c167d00/vendor/bundle/ruby/3.0.0/gems/bootsnap-1.9.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require_with_bootsnap_lfi'
       /tmp/build_7c167d00/vendor/bundle/ruby/3.0.0/gems/bootsnap-1.9.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:31:in `require'
       /tmp/build_7c167d00/vendor/bundle/ruby/3.0.0/gems/zeitwerk-2.5.1/lib/zeitwerk/kernel.rb:35:in `require'
       /tmp/build_7c167d00/vendor/bundle/ruby/3.0.0/gems/sprockets-4.0.2/lib/sprockets/sassc_processor.rb:42:in `initialize'
       /tmp/build_7c167d00/vendor/bundle/ruby/3.0.0/gems/sprockets-4.0.2/lib/sprockets/sassc_processor.rb:27:in `new'
       /tmp/build_7c167d00/vendor/bundle/ruby/3.0.0/gems/sprockets-4.0.2/lib/sprockets/sassc_processor.rb:27:in `instance'
       /tmp/build_7c167d00/vendor/bundle/ruby/3.0.0/gems/sprockets-4.0.2/lib/sprockets/sassc_processor.rb:31:in `call'
       /tmp/build_7c167d00/vendor/bundle/ruby/3.0.0/gems/sprockets-4.0.2/lib/sprockets/processor_utils.rb:84:in `call_processor'
       /tmp/build_7c167d00/vendor/bundle/ruby/3.0.0/gems/sprockets-4.0.2/lib/sprockets/processor_utils.rb:66:in `block in call_processors'
       /tmp/build_7c167d00/vendor/bundle/ruby/3.0.0/gems/sprockets-4.0.2/lib/sprockets/processor_utils.rb:65:in `reverse_each'
       /tmp/build_7c167d00/vendor/bundle/ruby/3.0.0/gems/sprockets-4.0.2/lib/sprockets/processor_utils.rb:65:in `call_processors'
       /tmp/build_7c167d00/vendor/bundle/ruby/3.0.0/gems/sprockets-4.0.2/lib/sprockets/processor_utils.rb:22:in `block in <class:CompositeProcessor>'
       /tmp/build_7c167d00/vendor/bundle/ruby/3.0.0/gems/sprockets-4.0.2/lib/sprockets/processor_utils.rb:33:in `call'
       /tmp/build_7c167d00/vendor/bundle/ruby/3.0.0/gems/sprockets-4.0.2/lib/sprockets/processor_utils.rb:84:in `call_processor'
       /tmp/build_7c167d00/vendor/bundle/ruby/3.0.0/gems/sprockets-4.0.2/lib/sprockets/processor_utils.rb:66:in `block in call_processors'
       /tmp/build_7c167d00/vendor/bundle/ruby/3.0.0/gems/sprockets-4.0.2/lib/sprockets/processor_utils.rb:65:in `reverse_each'
       /tmp/build_7c167d00/vendor/bundle/ruby/3.0.0/gems/sprockets-4.0.2/lib/sprockets/processor_utils.rb:65:in `call_processors'
       /tmp/build_7c167d00/vendor/bundle/ruby/3.0.0/gems/sprockets-4.0.2/lib/sprockets/loader.rb:182:in `load_from_unloaded'
       /tmp/build_7c167d00/vendor/bundle/ruby/3.0.0/gems/sprockets-4.0.2/lib/sprockets/loader.rb:59:in `block in load'
       /tmp/build_7c167d00/vendor/bundle/ruby/3.0.0/gems/sprockets-4.0.2/lib/sprockets/loader.rb:337:in `fetch_asset_from_dependency_cache'
       /tmp/build_7c167d00/vendor/bundle/ruby/3.0.0/gems/sprockets-4.0.2/lib/sprockets/loader.rb:43:in `load'
       /tmp/build_7c167d00/vendor/bundle/ruby/3.0.0/gems/sprockets-4.0.2/lib/sprockets/cached_environment.rb:44:in `load'
       /tmp/build_7c167d00/vendor/bundle/ruby/3.0.0/gems/sprockets-4.0.2/lib/sprockets/bundle.rb:27:in `call'
       /tmp/build_7c167d00/vendor/bundle/ruby/3.0.0/gems/sprockets-4.0.2/lib/sprockets/processor_utils.rb:84:in `call_processor'
       /tmp/build_7c167d00/vendor/bundle/ruby/3.0.0/gems/sprockets-4.0.2/lib/sprockets/processor_utils.rb:66:in `block in call_processors'
       /tmp/build_7c167d00/vendor/bundle/ruby/3.0.0/gems/sprockets-4.0.2/lib/sprockets/processor_utils.rb:65:in `reverse_each'
       /tmp/build_7c167d00/vendor/bundle/ruby/3.0.0/gems/sprockets-4.0.2/lib/sprockets/processor_utils.rb:65:in `call_processors'
       /tmp/build_7c167d00/vendor/bundle/ruby/3.0.0/gems/sprockets-4.0.2/lib/sprockets/loader.rb:182:in `load_from_unloaded'
       /tmp/build_7c167d00/vendor/bundle/ruby/3.0.0/gems/sprockets-4.0.2/lib/sprockets/loader.rb:59:in `block in load'
       /tmp/build_7c167d00/vendor/bundle/ruby/3.0.0/gems/sprockets-4.0.2/lib/sprockets/loader.rb:337:in `fetch_asset_from_dependency_cache'
       /tmp/build_7c167d00/vendor/bundle/ruby/3.0.0/gems/sprockets-4.0.2/lib/sprockets/loader.rb:43:in `load'
       /tmp/build_7c167d00/vendor/bundle/ruby/3.0.0/gems/sprockets-4.0.2/lib/sprockets/cached_environment.rb:44:in `load'
       /tmp/build_7c167d00/vendor/bundle/ruby/3.0.0/gems/sprockets-4.0.2/lib/sprockets/base.rb:81:in `find_asset'
       /tmp/build_7c167d00/vendor/bundle/ruby/3.0.0/gems/sprockets-4.0.2/lib/sprockets/base.rb:88:in `find_all_linked_assets'
       /tmp/build_7c167d00/vendor/bundle/ruby/3.0.0/gems/sprockets-4.0.2/lib/sprockets/manifest.rb:125:in `block (2 levels) in find'
       /tmp/build_7c167d00/vendor/bundle/ruby/3.0.0/gems/concurrent-ruby-1.1.9/lib/concurrent-ruby/concurrent/executor/safe_task_executor.rb:24:in `block in execute'
       /tmp/build_7c167d00/vendor/bundle/ruby/3.0.0/gems/concurrent-ruby-1.1.9/lib/concurrent-ruby/concurrent/synchronization/mutex_lockable_object.rb:47:in `block in synchronize'
       /tmp/build_7c167d00/vendor/bundle/ruby/3.0.0/gems/concurrent-ruby-1.1.9/lib/concurrent-ruby/concurrent/synchronization/mutex_lockable_object.rb:47:in `synchronize'
       /tmp/build_7c167d00/vendor/bundle/ruby/3.0.0/gems/concurrent-ruby-1.1.9/lib/concurrent-ruby/concurrent/synchronization/mutex_lockable_object.rb:47:in `synchronize'
       /tmp/build_7c167d00/vendor/bundle/ruby/3.0.0/gems/concurrent-ruby-1.1.9/lib/concurrent-ruby/concurrent/executor/safe_task_executor.rb:19:in `execute'
       /tmp/build_7c167d00/vendor/bundle/ruby/3.0.0/gems/concurrent-ruby-1.1.9/lib/concurrent-ruby/concurrent/promise.rb:564:in `block in realize'
       /tmp/build_7c167d00/vendor/bundle/ruby/3.0.0/gems/concurrent-ruby-1.1.9/lib/concurrent-ruby/concurrent/executor/ruby_thread_pool_executor.rb:363:in `run_task'
       /tmp/build_7c167d00/vendor/bundle/ruby/3.0.0/gems/concurrent-ruby-1.1.9/lib/concurrent-ruby/concurrent/executor/ruby_thread_pool_executor.rb:352:in `block (3 levels) in create_worker'
       /tmp/build_7c167d00/vendor/bundle/ruby/3.0.0/gems/concurrent-ruby-1.1.9/lib/concurrent-ruby/concurrent/executor/ruby_thread_pool_executor.rb:335:in `loop'
       /tmp/build_7c167d00/vendor/bundle/ruby/3.0.0/gems/concurrent-ruby-1.1.9/lib/concurrent-ruby/concurrent/executor/ruby_thread_pool_executor.rb:335:in `block (2 levels) in create_worker'
       /tmp/build_7c167d00/vendor/bundle/ruby/3.0.0/gems/concurrent-ruby-1.1.9/lib/concurrent-ruby/concurrent/executor/ruby_thread_pool_executor.rb:334:in `catch'
       /tmp/build_7c167d00/vendor/bundle/ruby/3.0.0/gems/concurrent-ruby-1.1.9/lib/concurrent-ruby/concurrent/executor/ruby_thread_pool_executor.rb:334:in `block in create_worker'
       Tasks: TOP => assets:precompile
       (See full trace by running task with --trace)

Removing the rails_admin gem resolves the issue.

Additional context

  • rails version: 7.0.0
  • rails_admin version: 3.0.0.alpha
@AnalyzePlatypus
Copy link

This seems to be because the Sass gem cannot process modern CSS syntax used by Tailwind, as mentioned by the Rails team here.
Their suggested solution was removing the sassc-rails gem entirely.

Unfortunately, RailsAdmin seems to depends on sassc-rails, so that's not possible.

@Shpigford
Copy link
Author

Unfortunately, RailsAdmin seems to depends on sassc-rails, so that's not possible.

Yeah, hence the bug report. 🙃 sassc-rails hasn't been updated in years and as you noted is actually recommended to be removed by the Rails team. So it would seem it's time for RailsAdmin to move away from it.

@mshibuya
Copy link
Member

By default RailsAdmin will use asset pipeline for delivering its assets, so it requires sassc-rails dependency.

But you can eliminate that dependency by configuring RailsAdmin to use Webpack for asset delivery. Running rails g rails_admin:install will suggest you the necessary changes, so please try and see if it works.

If you need more information, see #3414 or ask any questions here.

@domchristie
Copy link

FWIW I also came across the sassc dependency issue whilst trying to compress the Tailwind 3 styles. My solution was to create a custom Sprockets compressor that uses CSSO for minification: rails/tailwindcss-rails#82 (comment)

@mshibuya
Copy link
Member

Please report back if you still have an issue.

@JWesorick
Copy link

JWesorick commented Jul 31, 2024

Does anyone have a workaround that works with esbuild? I don't really want to switch to Webpack.

edit: seems like it works by setting config.asset_source = :webpack without requiring me to switch my entire app to Webpack.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants