Home Ask Login Register

Developers Planet

Your answer is one click away!

Jay M February 2016

Rails 4 Heroku Deployment error: Precompiling assets failed - cannot import/find boostrap file

My app works locally; however, when I try to deploy it to Heroku I get the following error:

remote:        Sass::SyntaxError: File to import not found or unreadable: bootstrap/dist/css/bootstrap.
remote:        (sass):18
remote:        /tmp/build_c0c6ec9ea8e1ea183aca6e660993c246/vendor/bundle/ruby/2.2.0/gems/sprockets-rails-3.0.1/lib/sprockets/rails/task.rb:67:in `block (2 levels) in define'
Sass::SyntaxError: File to import not found or unreadable: bootstrap/dist/css/bootstrap.
remote:        Tasks: TOP => assets:precompile
remote:        (See full trace by running task with --trace)
remote:  !
remote:  !     Precompiling assets failed.
remote:  !

Here are the application.scss, and Gemfile files in order:


 *= require_self
 *= require custom
 *= require template
 @import "bootstrap-sprockets";
 @import "bootstrap";


# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.2.3'
# Specify Rake version
gem 'rake'
# Use postgresql as the database for Active Record
gem 'pg'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 5.0'
# Use bootstrap sass?
gem 'bootstrap-sass', '>= 3.3.6'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# Use CoffeeScript for .coffee assets and views
gem 'coffee-rails', '~> 4.1.0'
# See https://github.com/rails/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby

# Use jquery as the JavaScript library
gem 'jquery-rails'
# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
gem 'turbolinks'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.0'
# bundle exec rake doc:rails generates the API under doc/api.
gem 'sdoc', '~> 0.4.0', group: :doc

# For user authenti        


Nikhil Nanjappa February 2016

I remember this error back when I used to work on ROR. The issue has to do with the production.rb file inside your config folder.

Make sure this line is made true.

config.assets.initialize_on_precompile = true

Rails comes bundled with a task to compile the asset manifests and other files in the pipeline.

Compiled assets are written to the location specified in config.assets.prefix. By default, this is the /assets directory.

Andrew Hendrie February 2016

  1. You need to import the bootstrap file like this in application.scss:

    @import "bootstrap-sprockets";
    @import "bootstrap";
  2. Then, remove all the *= require_self and *= require_tree . statements from the sass file. Instead, use @import to import Sass files.

    Do not use *= require in Sass or your other stylesheets will not be able to access the Bootstrap mixins or variables. See the sass-rails gem documentation for more information on this.

  3. Run $ rake assets:precompile

  4. Run $ git add --all

  5. Run $ git commit -m 'switched to import syntax'

  6. Run $ git push heroku master

Jay M February 2016

The issue was that I was making changes while on the develop branch and trying to push them, not realising that (NEWBIES TAKE NOTE) when you do git push heroku master it actually only ever pushes from your local master branch.

So I merged all my changes into my master branch and pushed. Problem solved.

If your setup is similar to mine please take note of the other answers because I am sure taking on those suggestions means I avoided some other errors in my code.

Post Status

Asked in February 2016
Viewed 2,468 times
Voted 7
Answered 3 times


Leave an answer

Quote of the day: live life