MENU

【備忘録】【rails6】Herokuへのデプロイエラー「Precompiling assets failed.」

★環境
 Ruby:3.0.2
 Rails:6.1.5

目次

エラーが発生した背景

開発を中のコードをGitHubにコミットしてデプロイしたら、Herokuにてデプロイエラーが発生しました。

Herokuへのデプロイエラー

-----> Building on the Heroku-20 stack
-----> Using buildpack: heroku/ruby
-----> Ruby app detected
-----> Installing bundler 2.2.33
-----> Removing BUNDLED WITH version in the Gemfile.lock
-----> Compiling Ruby/Rails
-----> Using Ruby version: ruby-3.0.2
-----> Installing dependencies using bundler 2.2.33
       Running: BUNDLE_WITHOUT='development:test' BUNDLE_PATH=vendor/bundle BUNDLE_BIN=vendor/bundle/bin BUNDLE_DEPLOYMENT=1 bundle install -j4
       Using rake 13.0.6
       Using concurrent-ruby 1.1.9
       Using i18n 1.10.0
       Using minitest 5.15.0
       Using tzinfo 2.0.4
       Using zeitwerk 2.5.4
       Using activesupport 6.1.5
       Using builder 3.2.4
       Using erubi 1.10.0
       Using racc 1.6.0
       Using nokogiri 1.13.3 (x86_64-linux)
       Using rails-dom-testing 2.0.3
       Using crass 1.0.6
       Using loofah 2.15.0
       Using rails-html-sanitizer 1.4.2
       Using actionview 6.1.5
       Using rack 2.2.3
       Using rack-test 1.1.0
       Using actionpack 6.1.5
       Using nio4r 2.5.8
       Using websocket-extensions 0.1.5
       Using websocket-driver 0.7.5
       Using actioncable 6.1.5
       Using globalid 1.0.0
       Using activejob 6.1.5
       Using activemodel 6.1.5
       Using activerecord 6.1.5
       Using marcel 1.0.2
       Using mini_mime 1.1.2
       Using activestorage 6.1.5
       Using mail 2.7.1
       Using actionmailbox 6.1.5
       Using actionmailer 6.1.5
       Using actiontext 6.1.5
       Using bcrypt 3.1.17
       Using msgpack 1.4.5
       Using bootsnap 1.11.1
       Using bundler 2.2.33
       Using dotenv 2.7.6
       Using method_source 1.0.0
       Using thor 1.2.1
       Using railties 6.1.5
       Using dotenv-rails 2.7.6
       Using ffi 1.15.5
       Using jbuilder 2.11.5
       Using pg 1.3.4
       Using puma 5.6.2
       Using rack-proxy 0.7.2
       Using sprockets 4.0.3
       Using sprockets-rails 3.4.2
       Using rails 6.1.5
       Using sassc 2.4.0
       Using tilt 2.0.10
       Using sassc-rails 2.1.2
       Using sass-rails 6.0.0
       Using semantic_range 3.0.0
       Using turbolinks-source 5.2.0
       Using turbolinks 5.2.1
       Using webpacker 5.4.3
       Bundle complete! 20 Gemfile dependencies, 59 gems now installed.
       Gems in the groups 'development' and 'test' were not installed.
       Bundled gems are installed into `./vendor/bundle`
       Bundle completed (0.31s)
       Cleaning up the bundler cache.
-----> Installing node-v16.13.1-linux-x64
-----> Installing yarn-v1.22.17
-----> Detecting rake tasks
-----> Preparing app for Rails asset pipeline
       Running: rake assets:precompile
       yarn install v1.22.17
       warning package-lock.json found. Your project contains lock files generated by tools other than Yarn. It is advised not to mix package managers in order to avoid resolution inconsistencies caused by unsynchronized lock files. To clear this warning, remove package-lock.json.
       [1/4] Resolving packages...
       [2/4] Fetching packages...
       [3/4] Linking dependencies...
       [4/4] Building fresh packages...
       Done in 12.86s.
       rake aborted!
       Sprockets::ArgumentError: link_directory argument must be a directory
       /tmp/build_f545032c/app/assets/config/manifest.js:2
       /tmp/build_f545032c/vendor/bundle/ruby/3.0.0/gems/sprockets-4.0.3/lib/sprockets/directive_processor.rb:389:in `expand_relative_dirname'
       /tmp/build_f545032c/vendor/bundle/ruby/3.0.0/gems/sprockets-4.0.3/lib/sprockets/directive_processor.rb:325:in `process_link_directory_directive'
       /tmp/build_f545032c/vendor/bundle/ruby/3.0.0/gems/sprockets-4.0.3/lib/sprockets/directive_processor.rb:189:in `block in process_directives'
       /tmp/build_f545032c/vendor/bundle/ruby/3.0.0/gems/sprockets-4.0.3/lib/sprockets/directive_processor.rb:187:in `each'
       /tmp/build_f545032c/vendor/bundle/ruby/3.0.0/gems/sprockets-4.0.3/lib/sprockets/directive_processor.rb:187:in `process_directives'
       /tmp/build_f545032c/vendor/bundle/ruby/3.0.0/gems/sprockets-4.0.3/lib/sprockets/directive_processor.rb:84:in `_call'
       /tmp/build_f545032c/vendor/bundle/ruby/3.0.0/gems/sprockets-4.0.3/lib/sprockets/directive_processor.rb:65:in `call'
       /tmp/build_f545032c/vendor/bundle/ruby/3.0.0/gems/sprockets-4.0.3/lib/sprockets/processor_utils.rb:84:in `call_processor'
       /tmp/build_f545032c/vendor/bundle/ruby/3.0.0/gems/sprockets-4.0.3/lib/sprockets/processor_utils.rb:66:in `block in call_processors'
       /tmp/build_f545032c/vendor/bundle/ruby/3.0.0/gems/sprockets-4.0.3/lib/sprockets/processor_utils.rb:65:in `reverse_each'
       /tmp/build_f545032c/vendor/bundle/ruby/3.0.0/gems/sprockets-4.0.3/lib/sprockets/processor_utils.rb:65:in `call_processors'
       /tmp/build_f545032c/vendor/bundle/ruby/3.0.0/gems/sprockets-4.0.3/lib/sprockets/loader.rb:182:in `load_from_unloaded'
       /tmp/build_f545032c/vendor/bundle/ruby/3.0.0/gems/sprockets-4.0.3/lib/sprockets/loader.rb:59:in `block in load'
       /tmp/build_f545032c/vendor/bundle/ruby/3.0.0/gems/sprockets-4.0.3/lib/sprockets/loader.rb:337:in `fetch_asset_from_dependency_cache'
       /tmp/build_f545032c/vendor/bundle/ruby/3.0.0/gems/sprockets-4.0.3/lib/sprockets/loader.rb:43:in `load'
       /tmp/build_f545032c/vendor/bundle/ruby/3.0.0/gems/sprockets-4.0.3/lib/sprockets/cached_environment.rb:44:in `load'
       /tmp/build_f545032c/vendor/bundle/ruby/3.0.0/gems/sprockets-4.0.3/lib/sprockets/bundle.rb:27:in `call'
       /tmp/build_f545032c/vendor/bundle/ruby/3.0.0/gems/sprockets-4.0.3/lib/sprockets/processor_utils.rb:84:in `call_processor'
       /tmp/build_f545032c/vendor/bundle/ruby/3.0.0/gems/sprockets-4.0.3/lib/sprockets/processor_utils.rb:66:in `block in call_processors'
       /tmp/build_f545032c/vendor/bundle/ruby/3.0.0/gems/sprockets-4.0.3/lib/sprockets/processor_utils.rb:65:in `reverse_each'
       /tmp/build_f545032c/vendor/bundle/ruby/3.0.0/gems/sprockets-4.0.3/lib/sprockets/processor_utils.rb:65:in `call_processors'
       /tmp/build_f545032c/vendor/bundle/ruby/3.0.0/gems/sprockets-4.0.3/lib/sprockets/loader.rb:182:in `load_from_unloaded'
       /tmp/build_f545032c/vendor/bundle/ruby/3.0.0/gems/sprockets-4.0.3/lib/sprockets/loader.rb:59:in `block in load'
       /tmp/build_f545032c/vendor/bundle/ruby/3.0.0/gems/sprockets-4.0.3/lib/sprockets/loader.rb:337:in `fetch_asset_from_dependency_cache'
       /tmp/build_f545032c/vendor/bundle/ruby/3.0.0/gems/sprockets-4.0.3/lib/sprockets/loader.rb:43:in `load'
       /tmp/build_f545032c/vendor/bundle/ruby/3.0.0/gems/sprockets-4.0.3/lib/sprockets/cached_environment.rb:44:in `load'
       /tmp/build_f545032c/vendor/bundle/ruby/3.0.0/gems/sprockets-4.0.3/lib/sprockets/base.rb:81:in `find_asset'
       /tmp/build_f545032c/vendor/bundle/ruby/3.0.0/gems/sprockets-4.0.3/lib/sprockets/base.rb:88:in `find_all_linked_assets'
       /tmp/build_f545032c/vendor/bundle/ruby/3.0.0/gems/sprockets-4.0.3/lib/sprockets/manifest.rb:125:in `each'
       /tmp/build_f545032c/vendor/bundle/ruby/3.0.0/gems/sprockets-4.0.3/lib/sprockets/manifest.rb:125:in `to_a'
       /tmp/build_f545032c/vendor/bundle/ruby/3.0.0/gems/sprockets-4.0.3/lib/sprockets/manifest.rb:125:in `block (2 levels) in find'
       /tmp/build_f545032c/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_f545032c/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_f545032c/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_f545032c/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_f545032c/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_f545032c/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_f545032c/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_f545032c/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_f545032c/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_f545032c/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_f545032c/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_f545032c/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)
 !
 !     Precompiling assets failed.
 !
 !     Push rejected, failed to compile Ruby app.
 !     Push failed

<原因>「application.css」を誤って削除したため

/app/assets/stylesheets/application.css」ファイルを誤って削除したためです。

エラーメッセージ通り「アセットのプリコンパイルに失敗しました」となりました。

 !     Precompiling assets failed.

<解決>ファイルを元に戻した

削除したファイル「/app/assets/stylesheets/application.css」を戻しました。

コミットした時にしっかり確認すれば気づけた事です😅

無事エラーも解消できました。

よかったらシェアしてね!
  • URLをコピーしました!
  • URLをコピーしました!

コメント

コメントする

日本語が含まれない投稿は無視されますのでご注意ください。(スパム対策)

目次