Search code examples
ruby-on-railsherokuasset-pipelinesprockets

could not find file affix.js


I have a problem with the precompile assets when I push to Heroku, Bootstrap is installed and the file 'affix.js' is not found. I tried to add:

 //= require bootstrap/affix

but it did not help, anybody got the same problem?

I have had this problem a few time in the past and usually updating bootstrap fix it. Not this time:

GEMFILE:
# Assets
gem 'bootstrap-sass', '~> 3.3.5'
gem 'sass-rails', '>= 3.2'
gem 'uglifier', '>= 1.3.0'
gem 'coffee-rails', '~> 4.0.0'
gem 'font-awesome-sass'
gem 'nprogress-rails'

ERROR:
remote: rake aborted!
remote: Sprockets::FileNotFound: could not find file: 
/tmp/build_7160395b09b71ebb83ef5bf51eb32d75/vendor/bundle/ruby/2.2.0/gems/bootstrap-sass-3.3.5.1/assets/javascripts/bootstrap/affix.js          remote:tmp/build_2e50ddbbbfb3469acb16fa727d62c302/vendor/bundle/ruby/2.2.0/gems/sprockets-3.3.2/lib/sprockets/loader.rb:95:in `load_from_unloaded'

remote:/tmp/build_2e50ddbbbfb3469acb16fa727d62c302/vendor/bundle/ruby/2.2.0/gems/sprockets-3.3.2/lib/sprockets/loader.rb:60:in block in load' remote:/tmp/build_2e50ddbbbfb3469acb16fa727d62c302/vendor/bundle/ruby/2.2.0/gems/sprockets-3.3.2/lib/sprockets/loader.rb:286:infetch_asset_from_dependency_cache'


Solution

  • Ok so this worked:

    rake assets:precompile
    
    git add .
    git commit -m "precompile all assets"
    git push heroku-or-whatever-branch
    

    I am still not able to explain anything though...