资产:预编译导致 LoadError:无法加载此类文件 -- sassc

Shp*_*ord 8 ruby-on-rails sass ruby-on-rails-7

新的 Rails 7 应用程序使用esbuildwith tailwind.

\n

当我运行时,rake assets:precompile我收到此错误:LoadError: cannot load such file -- sassc

\n

由于 SaasC 语法错误,我删除了sassc-railsgem 。

\n

这是本地预编译的完整输出......

\n
rake assets:precompile\nyarn install v1.22.15\n[1/4]   Resolving packages...\nsuccess Already up-to-date.\n\xe2\x9c\xa8  Done in 0.06s.\nyarn run v1.22.15\n$ esbuild app/javascript/*.* --bundle --sourcemap --outdir=app/assets/builds\n\n  app/assets/builds/application.js      185.5kb\n  app/assets/builds/application.js.map  301.0kb\n\n\xe2\x9c\xa8  Done in 0.13s.\nyarn install v1.22.15\n[1/4]   Resolving packages...\nsuccess Already up-to-date.\n\xe2\x9c\xa8  Done in 0.06s.\nyarn run v1.22.15\n$ tailwindcss -i ./app/assets/stylesheets/application.tailwind.css -o ./app/assets/builds/application.css\n\nDone in 155ms.\n\xe2\x9c\xa8  Done in 0.52s.\nrake aborted!\nLoadError: cannot load such file -- sassc\n\nTasks: TOP => assets:precompile\n(See full trace by running task with --trace)\n
Run Code Online (Sandbox Code Playgroud)\n

这是 Heroku 的输出...

\n
Running: rake assets:precompile\n       yarn install v1.22.17\n       [1/4] Resolving packages...\n       [2/4] Fetching packages...\n       [3/4] Linking dependencies...\n       [4/4] Building fresh packages...\n       success Saved lockfile.\n       Done in 4.39s.\n       yarn run v1.22.17\n       $ esbuild app/javascript/*.* --bundle --sourcemap --outdir=app/assets/builds\n       \n         app/assets/builds/application.js      185.5kb\n         app/assets/builds/application.js.map  301.0kb\n       \n       Done in 0.11s.\n       yarn install v1.22.17\n       [1/4] Resolving packages...\n       success Already up-to-date.\n       Done in 0.13s.\n       yarn run v1.22.17\n       $ tailwindcss -i ./app/assets/stylesheets/application.tailwind.css -o ./app/assets/builds/application.css\n       \n       Done in 440ms.\n       Done in 0.99s.\n       rake aborted!\n       LoadError: cannot load such file -- sassc\n       /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\'\n       /tmp/build_7c167d00/vendor/bundle/ruby/3.0.0/gems/zeitwerk-2.5.1/lib/zeitwerk/kernel.rb:35:in `require\'\n       /tmp/build_7c167d00/vendor/bundle/ruby/3.0.0/gems/sprockets-4.0.2/lib/sprockets/autoload/sassc.rb:2:in `<main>\'\n       /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\'\n       /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\'\n       /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\'\n       /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\'\n       /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\'\n       /tmp/build_7c167d00/vendor/bundle/ruby/3.0.0/gems/zeitwerk-2.5.1/lib/zeitwerk/kernel.rb:35:in `require\'\n       /tmp/build_7c167d00/vendor/bundle/ruby/3.0.0/gems/sprockets-4.0.2/lib/sprockets/sassc_processor.rb:42:in `initialize\'\n       /tmp/build_7c167d00/vendor/bundle/ruby/3.0.0/gems/sprockets-4.0.2/lib/sprockets/sassc_processor.rb:27:in `new\'\n       /tmp/build_7c167d00/vendor/bundle/ruby/3.0.0/gems/sprockets-4.0.2/lib/sprockets/sassc_processor.rb:27:in `instance\'\n       /tmp/build_7c167d00/vendor/bundle/ruby/3.0.0/gems/sprockets-4.0.2/lib/sprockets/sassc_processor.rb:31:in `call\'\n       /tmp/build_7c167d00/vendor/bundle/ruby/3.0.0/gems/sprockets-4.0.2/lib/sprockets/processor_utils.rb:84:in `call_processor\'\n       /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\'\n       /tmp/build_7c167d00/vendor/bundle/ruby/3.0.0/gems/sprockets-4.0.2/lib/sprockets/processor_utils.rb:65:in `reverse_each\'\n       /tmp/build_7c167d00/vendor/bundle/ruby/3.0.0/gems/sprockets-4.0.2/lib/sprockets/processor_utils.rb:65:in `call_processors\'\n       /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>\'\n       /tmp/build_7c167d00/vendor/bundle/ruby/3.0.0/gems/sprockets-4.0.2/lib/sprockets/processor_utils.rb:33:in `call\'\n       /tmp/build_7c167d00/vendor/bundle/ruby/3.0.0/gems/sprockets-4.0.2/lib/sprockets/processor_utils.rb:84:in `call_processor\'\n       /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\'\n       /tmp/build_7c167d00/vendor/bundle/ruby/3.0.0/gems/sprockets-4.0.2/lib/sprockets/processor_utils.rb:65:in `reverse_each\'\n       /tmp/build_7c167d00/vendor/bundle/ruby/3.0.0/gems/sprockets-4.0.2/lib/sprockets/processor_utils.rb:65:in `call_processors\'\n       /tmp/build_7c167d00/vendor/bundle/ruby/3.0.0/gems/sprockets-4.0.2/lib/sprockets/loader.rb:182:in `load_from_unloaded\'\n       /tmp/build_7c167d00/vendor/bundle/ruby/3.0.0/gems/sprockets-4.0.2/lib/sprockets/loader.rb:59:in `block in load\'\n       /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\'\n       /tmp/build_7c167d00/vendor/bundle/ruby/3.0.0/gems/sprockets-4.0.2/lib/sprockets/loader.rb:43:in `load\'\n       /tmp/build_7c167d00/vendor/bundle/ruby/3.0.0/gems/sprockets-4.0.2/lib/sprockets/cached_environment.rb:44:in `load\'\n       /tmp/build_7c167d00/vendor/bundle/ruby/3.0.0/gems/sprockets-4.0.2/lib/sprockets/bundle.rb:27:in `call\'\n       /tmp/build_7c167d00/vendor/bundle/ruby/3.0.0/gems/sprockets-4.0.2/lib/sprockets/processor_utils.rb:84:in `call_processor\'\n       /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\'\n       /tmp/build_7c167d00/vendor/bundle/ruby/3.0.0/gems/sprockets-4.0.2/lib/sprockets/processor_utils.rb:65:in `reverse_each\'\n       /tmp/build_7c167d00/vendor/bundle/ruby/3.0.0/gems/sprockets-4.0.2/lib/sprockets/processor_utils.rb:65:in `call_processors\'\n       /tmp/build_7c167d00/vendor/bundle/ruby/3.0.0/gems/sprockets-4.0.2/lib/sprockets/loader.rb:182:in `load_from_unloaded\'\n       /tmp/build_7c167d00/vendor/bundle/ruby/3.0.0/gems/sprockets-4.0.2/lib/sprockets/loader.rb:59:in `block in load\'\n       /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\'\n       /tmp/build_7c167d00/vendor/bundle/ruby/3.0.0/gems/sprockets-4.0.2/lib/sprockets/loader.rb:43:in `load\'\n       /tmp/build_7c167d00/vendor/bundle/ruby/3.0.0/gems/sprockets-4.0.2/lib/sprockets/cached_environment.rb:44:in `load\'\n       /tmp/build_7c167d00/vendor/bundle/ruby/3.0.0/gems/sprockets-4.0.2/lib/sprockets/base.rb:81:in `find_asset\'\n       /tmp/build_7c167d00/vendor/bundle/ruby/3.0.0/gems/sprockets-4.0.2/lib/sprockets/base.rb:88:in `find_all_linked_assets\'\n       /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\'\n       /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\'\n       /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\'\n       /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\'\n       /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\'\n       /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\'\n       /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\'\n       /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\'\n       /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\'\n       /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\'\n       /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\'\n       /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\'\n       /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\'\n       Tasks: TOP => assets:precompile\n       (See full trace by running task with --trace)\n
Run Code Online (Sandbox Code Playgroud)\n

不知道这里还能尝试什么。

\n

Mik*_*ond 2

我今天遇到了同样的问题,并通过清除 Heroku 构建缓存在 Heroku 端解决了该问题(此处的说明)

heroku plugins:install heroku-builds

heroku builds:cache:purge -a example-app
Run Code Online (Sandbox Code Playgroud)