'Sprockets::FileNotFound: 'trix/dist/trix' type 'application/javascript' when attempting to host a Rails 7 app to Heroku. What am I missing?
I've built a simple blog application in Rails 7 using actionText. I'm using Ruby version 3.0.2 While attempting to push to Heroku, I keep getting this error:
Sprockets::FileNotFound: couldn't find file 'trix/dist/trix' with type 'application/javascript'
Installing sassc 2.4.0 with native extensions
Fetching sassc-rails 2.1.2
Installing sassc-rails 2.1.2
Fetching sass-rails 6.0.0
Installing sass-rails 6.0.0
Bundle complete! 18 Gemfile dependencies, 57 gems now installed.
Gems in the groups 'development' and 'test' were not installed.
Bundled gems are installed into `./vendor/bundle`
Bundle completed (88.33s)
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
rake aborted!
Sprockets::FileNotFound: couldn't find file 'trix/dist/trix' with type 'application/javascript'
Checked in these paths:
/tmp/build_e3e14720/app/assets/config
/tmp/build_e3e14720/app/assets/images
/tmp/build_e3e14720/app/assets/stylesheets
/tmp/build_e3e14720/vendor/bundle/ruby/3.0.0/gems/actiontext-7.0.0/app/assets/javascripts
/tmp/build_e3e14720/vendor/bundle/ruby/3.0.0/gems/actiontext-7.0.0/app/assets/stylesheets
/tmp/build_e3e14720/vendor/bundle/ruby/3.0.0/gems/actioncable-7.0.0/app/assets/javascripts
/tmp/build_e3e14720/vendor/bundle/ruby/3.0.0/gems/activestorage-7.0.0/app/assets/javascripts
/tmp/build_e3e14720/vendor/bundle/ruby/3.0.0/gems/actionview-7.0.0/lib/assets/compiled
/tmp/build_e3e14720/vendor/bundle/ruby/3.0.0/gems/turbolinks-source-5.2.0/lib/assets/javascripts
/tmp/build_e3e14720/node_modules
/tmp/build_e3e14720/app/assets/config/manifest.js:3
/tmp/build_e3e14720/vendor/bundle/ruby/3.0.0/gems/sprockets-4.0.2/lib/sprockets/resolve.rb:62:in `resolve!'
/tmp/build_e3e14720/vendor/bundle/ruby/3.0.0/gems/sprockets-4.0.2/lib/sprockets/directive_processor.rb:409:in `resolve'
/tmp/build_e3e14720/vendor/bundle/ruby/3.0.0/gems/sprockets-4.0.2/lib/sprockets/directive_processor.rb:216:in `process_require_directive'
/tmp/build_e3e14720/vendor/bundle/ruby/3.0.0/gems/sprockets-4.0.2/lib/sprockets/directive_processor.rb:189:in `block in process_directives'
/tmp/build_e3e14720/vendor/bundle/ruby/3.0.0/gems/sprockets-4.0.2/lib/sprockets/directive_processor.rb:187:in `each'
/tmp/build_e3e14720/vendor/bundle/ruby/3.0.0/gems/sprockets-4.0.2/lib/sprockets/directive_processor.rb:187:in `process_directives'
/tmp/build_e3e14720/vendor/bundle/ruby/3.0.0/gems/sprockets-4.0.2/lib/sprockets/directive_processor.rb:84:in `_call'
/tmp/build_e3e14720/vendor/bundle/ruby/3.0.0/gems/sprockets-4.0.2/lib/sprockets/directive_processor.rb:65:in `call'
/tmp/build_e3e14720/vendor/bundle/ruby/3.0.0/gems/sprockets-4.0.2/lib/sprockets/processor_utils.rb:84:in `call_processor'
/tmp/build_e3e14720/vendor/bundle/ruby/3.0.0/gems/sprockets-4.0.2/lib/sprockets/processor_utils.rb:66:in `block in call_processors'
/tmp/build_e3e14720/vendor/bundle/ruby/3.0.0/gems/sprockets-4.0.2/lib/sprockets/processor_utils.rb:65:in `reverse_each'
/tmp/build_e3e14720/vendor/bundle/ruby/3.0.0/gems/sprockets-4.0.2/lib/sprockets/processor_utils.rb:65:in `call_processors'
/tmp/build_e3e14720/vendor/bundle/ruby/3.0.0/gems/sprockets-4.0.2/lib/sprockets/loader.rb:182:in `load_from_unloaded'
/tmp/build_e3e14720/vendor/bundle/ruby/3.0.0/gems/sprockets-4.0.2/lib/sprockets/loader.rb:59:in `block in load'
/tmp/build_e3e14720/vendor/bundle/ruby/3.0.0/gems/sprockets-4.0.2/lib/sprockets/loader.rb:337:in `fetch_asset_from_dependency_cache'
/tmp/build_e3e14720/vendor/bundle/ruby/3.0.0/gems/sprockets-4.0.2/lib/sprockets/loader.rb:43:in `load'
/tmp/build_e3e14720/vendor/bundle/ruby/3.0.0/gems/sprockets-4.0.2/lib/sprockets/cached_environment.rb:44:in `load'
/tmp/build_e3e14720/vendor/bundle/ruby/3.0.0/gems/sprockets-4.0.2/lib/sprockets/bundle.rb:27:in `call'
/tmp/build_e3e14720/vendor/bundle/ruby/3.0.0/gems/sprockets-4.0.2/lib/sprockets/processor_utils.rb:84:in `call_processor'
/tmp/build_e3e14720/vendor/bundle/ruby/3.0.0/gems/sprockets-4.0.2/lib/sprockets/processor_utils.rb:66:in `block in call_processors'
/tmp/build_e3e14720/vendor/bundle/ruby/3.0.0/gems/sprockets-4.0.2/lib/sprockets/processor_utils.rb:65:in `reverse_each'
/tmp/build_e3e14720/vendor/bundle/ruby/3.0.0/gems/sprockets-4.0.2/lib/sprockets/processor_utils.rb:65:in `call_processors'
/tmp/build_e3e14720/vendor/bundle/ruby/3.0.0/gems/sprockets-4.0.2/lib/sprockets/loader.rb:182:in `load_from_unloaded'
/tmp/build_e3e14720/vendor/bundle/ruby/3.0.0/gems/sprockets-4.0.2/lib/sprockets/loader.rb:59:in `block in load'
/tmp/build_e3e14720/vendor/bundle/ruby/3.0.0/gems/sprockets-4.0.2/lib/sprockets/loader.rb:337:in `fetch_asset_from_dependency_cache'
/tmp/build_e3e14720/vendor/bundle/ruby/3.0.0/gems/sprockets-4.0.2/lib/sprockets/loader.rb:43:in `load'
/tmp/build_e3e14720/vendor/bundle/ruby/3.0.0/gems/sprockets-4.0.2/lib/sprockets/cached_environment.rb:44:in `load'
/tmp/build_e3e14720/vendor/bundle/ruby/3.0.0/gems/sprockets-4.0.2/lib/sprockets/base.rb:81:in `find_asset'
/tmp/build_e3e14720/vendor/bundle/ruby/3.0.0/gems/sprockets-4.0.2/lib/sprockets/base.rb:88:in `find_all_linked_assets'
/tmp/build_e3e14720/vendor/bundle/ruby/3.0.0/gems/sprockets-4.0.2/lib/sprockets/manifest.rb:125:in `block (2 levels) in find'
/tmp/build_e3e14720/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_e3e14720/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_e3e14720/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_e3e14720/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_e3e14720/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_e3e14720/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_e3e14720/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_e3e14720/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_e3e14720/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_e3e14720/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_e3e14720/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_e3e14720/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
Here is my Gemfile:
source 'https://rubygems.org'
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
ruby '3.0.2'
gem 'rails', '7.0.0'
gem 'pg', '~> 1.1'
gem 'puma', '~> 5.0'
gem 'sass-rails', '>= 6'
gem 'webpacker', '~> 5.0'
gem 'turbolinks', '~> 5'
gem 'jbuilder', '~> 2.7'
gem 'bcrypt', '~> 3.1.7'
gem 'bootsnap', '>= 1.4.4', require: false
group :development, :test do
gem 'byebug', platforms: [:mri, :mingw, :x64_mingw]
end
group :development do
gem 'web-console', '>= 4.1.0'
gem 'rack-mini-profiler', '~> 2.0'
gem 'listen', '~> 3.3'
gem 'spring'
end
group :test do
gem 'capybara', '>= 3.26'
gem 'selenium-webdriver'
gem 'webdrivers'
end
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
Here is my application.js file:
import Rails from "@rails/ujs"
import Turbolinks from "turbolinks"
import * as ActiveStorage from "@rails/activestorage"
import "channels"
import "trix"
import "@rails/actiontext"
Rails.start()
Turbolinks.start()
ActiveStorage.start()
Please let me know if i need to provide any further information. Thank you.
Edit -- Here is the package.json:
{
"name": "personal-blog",
"private": true,
"dependencies": {
"@rails/actioncable": "^6.0.0",
"@rails/actiontext": "^7.0.2-2",
"@rails/activestorage": "^6.0.0",
"@rails/ujs": "^6.0.0",
"@rails/webpacker": "5.4.3",
"trix": "^2.0.0-alpha.0",
"turbolinks": "^5.2.0",
"webpack": "^4.46.0",
"webpack-cli": "^3.3.12"
},
"version": "0.1.0",
"devDependencies": {
"webpack-dev-server": "^3"
}
}
Still no solution but I have a feeling that the problem probably has something to do with my manifest.js file in app/assets/config/ directory. Here is the file:
//= link_tree ../images
//= link_directory ../stylesheets .css
I deleted my public/assets/ and my tmp/cache/ folders before running git push heroku main again to check if my cached files were interfering with the hosting. They are not. Still no luck. Let me know if you can think of something else! Thanks!
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
