12

So I am using rails 6.0.1 and trying to use Action text. So I run the command rails action_text:install and add the gem image_processing and finally run rails db:migrate

When I launch my app I got this error message:

Sprockets::FileNotFound in Hotels#index
Showing /myapp/app/views/layouts/application.html.erb where line #8 raised:

couldn't find file 'trix/dist/trix' with type 'text/css'
Checked in these paths: 
  /myapp/app/assets/config
  /myapp/app/assets/images
  /myapp/app/assets/javascripts
  /myapp/app/assets/stylesheets
  /usr/local/bundle/gems/cloudinary-1.13.1/vendor/assets/html
  /usr/local/bundle/gems/cloudinary-1.13.1/vendor/assets/javascripts
  /usr/local/bundle/gems/activeadmin-2.5.0/app/assets/javascripts
  /usr/local/bundle/gems/activeadmin-2.5.0/app/assets/stylesheets
  /usr/local/bundle/gems/activeadmin-2.5.0/vendor/assets/javascripts
  /usr/local/bundle/gems/jquery-rails-4.3.5/vendor/assets/javascripts
  /usr/local/bundle/gems/formtastic-3.1.5/app/assets/stylesheets
  /usr/local/bundle/gems/actioncable-6.0.1/app/assets/javascripts
  /usr/local/bundle/gems/activestorage-6.0.1/app/assets/javascripts
  /usr/local/bundle/gems/actionview-6.0.1/lib/assets/compiled
  /usr/local/bundle/gems/turbolinks-source-5.2.0/lib/assets/javascripts
  /myapp/node_modules

under assets/config/stylesheets/actiontext.scss I have: //= require trix/dist/trix and config/initiliazers/assets.rb: Rails.application.config.assets.paths << Rails.root.join('node_modules')

Any idea how I could solve this?

TylerH
  • 20,799
  • 66
  • 75
  • 101
chris
  • 341
  • 2
  • 6

3 Answers3

22

I actually find the solution. I had to run yarn install --check-files then reinstall action_text: rails action_text:install and then it fixed the issue.

chris
  • 341
  • 2
  • 6
  • Thanks for sharing this solution. I followed it through, encountered nothing that looked like an error, but I still get the same error message. Do you have any other ideas on this? – Andreas Gebhard Jul 22 '21 at 14:50
  • @AndreasGebhard Had the same problem, and I've resolved it adding `Rails.application.config.assets.paths << Rails.root.join('node_modules')` in config/initializers/assets.rb, then doing the action proposed by @chris – Emilien Baudet Jan 20 '22 at 13:29
3

The issue arises while setting up your Rails 6 app for the first time on your PC. You need to install the JS dependencies. Run these lines of code

bundle install
yarn install --check-files
rails action_text:install
Aditya Tiwari
  • 204
  • 4
  • 17
Babatunde Mustapha
  • 2,131
  • 20
  • 21
1

I was getting this same error in my CI pipeline in Github Actions, with a Rails 7 app. The above solutions did not help. It turned out I needed to add yarn builds to my action:

# .github/workflows/verify.yml

      - name: Compile assets
        run: |
          yarn build
          yarn build:css
moveson
  • 5,103
  • 1
  • 15
  • 32