0

I get an error when Heroku is trying to compile assets of my Rails app:

remote: -----> Preparing app for Rails asset pipeline
remote:        Running: rake assets:precompile
remote:        rake aborted!
remote:        Sass::SyntaxError: Undefined variable: "$btn-default-border".
remote:        (in /tmp/build_8402012299c8c367a1dc15dd7f5cd85f/app/assets/stylesheets/auctions.css.scss:42)
remote:        /tmp/build_8402012299c8c367a1dc15dd7f5cd85f/app/assets/stylesheets/auctions.css.scss:42

When I run rake assets:precompile locally it works.

Here my application.css.scss

/*
 *
 *= require bootstrap-datepicker3
 */
@import "variables"; 
@import "bootstrap-sprockets";
@import "bootstrap";
@import "auctions";

auctions.css.scss

.form-control-feedback {
    pointer-events: all;

    &:hover {
        cursor:pointer;
        border: 1px solid $btn-default-border;
        background: $gray-lighter;
        border-radius: 5px; 
    }
}

Why is it working locally but not on Heroku? Is Heroku trying to compile auctions.css.scss without other dependencies?

Charles
  • 11,367
  • 10
  • 77
  • 114
  • Possibly related: http://stackoverflow.com/questions/17976140/false-positive-undefined-variable-error-when-compiling-scss/ – cimmanon Feb 08 '15 at 19:13

3 Answers3

2

Try bumping Rails.application.config.assets.version in config/initializers/assets.rb.

I had the same exact issue deploying to Heroku right after I switched Sprockets require to @import lines in my application manifest file. (I had issues with CSS rule precedences and realized I was doing something wrong. This article directed me to better conventions: https://content.pivotal.io/blog/structure-your-sass-files-with-import)

I fixed it by bumping the Rails.application.config.assets.version in my config/initializers/assets.rb.

Bumping the version prompted my app to reprocess all asset files, which seemed to reset its understanding of certain files and their dependence on variables.

Dave Powers
  • 2,051
  • 2
  • 30
  • 34
Carlos Drew
  • 1,633
  • 9
  • 17
0

Make sure that production.rb have the following code or else add it

 # Precompile additional assets (application.js, application.css, and all non-JS/CSS are already added)
    config.assets.precompile += %w( *.css *.js )
Jagdish Barabari
  • 2,673
  • 3
  • 20
  • 21
  • I read that it should not have it otherwise Rails will try to compile `auctions.css.scss` without loading dependencies. I try it anyway and get the same error. I also try `Rails.application.config.assets.precompile += %w( application.js ) Rails.application.config.assets.precompile += %w( application.css )` in config/initializers/assets.rb and it also failed. – Charles Feb 08 '15 at 19:06
0

go to the file config/initializers/assests.rb

add line or update. Rails.application.config.assets.precompile += [/.*\.js/,/.*\.scss/]

and run bundle exec assets:precompile