Search code examples
ruby-on-railsasset-pipelineruby-on-rails-6ruby-on-rails-6.1

Deploy to Heroku Failing on Rails Upgrade from 6.0 to 6.1 - SassC::SyntaxError: Error: File to import not found or unreadable


I've recently upgraded to latest rails. The upgrade was from 6.0.3.4 to 6.1.3.1.

Everything in development and Production/Heroku worked great prior to the upgrade. Now everything works fine in development (local machine), but fails the rails assets:precompile step on Heroku with the following error message:

remote: -----> Installing node-v12.16.2-linux-x64
remote: -----> Installing yarn-v1.22.4
remote: -----> Detecting rake tasks
remote: -----> Preparing app for Rails asset pipeline
remote:        Running: rake assets:precompile
remote:        rake aborted!
remote:        SassC::SyntaxError: Error: File to import not found or unreadable: bootstrap/scss/bootstrap.
remote:                on line 21:1 of app/assets/stylesheets/application.scss
remote:        >> @import "bootstrap/scss/bootstrap";

My understanding is that the standard functionality is that it will look in local relative files first, then the node_modules folder.

What is my problem here?


Solution

  • I'm not sure if I'm missing something, but I needed to add NodeJS buildpack to Heroku in addition to the ruby buildpack. Now Heroku runs the yarn install before building the rails app, which must create the node_modules folder. Consequently, the step that failed during the rails build can now find the bootstrap folder in the node_modules.

    The only thing I can think of that I changed was upgrading from Rails 6.0 to 6.1.