vekozlov
vekozlov

Reputation: 684

File to import not found or unreadable: bootstrap. Heroku deploy failed

UPD: Issue solved.

I add gem twitter-bootstrap in overall list of gems (not only group :assets). And had to precompile before deploying.


Have a problem with deploying. application.css.scss now doesn't exist - the file was removed. What can be the problem? Problems started when I was adding bootstrap-sass instead of .less version. But it failed for unknown reasons. I decided to go back and now I have these problems.

-----> Preparing app for Rails asset pipeline
       Running: rake assets:precompile
       rake aborted!
       File to import not found or unreadable: bootstrap.
       Load path: Sass::Rails::Importer(/tmp/build_3es5vmj75q0ih/app/assets/stylesheets/application.css.scss)
       (in /tmp/build_3es5vmj75q0ih/app/assets/stylesheets/application.css.scss)
       /tmp/build_3es5vmj75q0ih/app/assets/stylesheets/application.css.scss:16
       /tmp/build_3es5vmj75q0ih/vendor/bundle/ruby/1.9.1/gems/sass-3.2.3/lib/sass/tree/import_node.rb:67:in `rescue in import'
       /tmp/build_3es5vmj75q0ih/vendor/bundle/ruby/1.9.1/gems/sass-3.2.3/lib/sass/tree/import_node.rb:45:in `import'
       /tmp/build_3es5vmj75q0ih/vendor/bundle/ruby/1.9.1/gems/sass-3.2.3/lib/sass/tree/import_node.rb:28:in `imported_file'
       /tmp/build_3es5vmj75q0ih/vendor/bundle/ruby/1.9.1/gems/sass-3.2.3/lib/sass/tree/import_node.rb:37:in `css_import?'
       /tmp/build_3es5vmj75q0ih/vendor/bundle/ruby/1.9.1/gems/sass-3.2.3/lib/sass/tree/visitors/perform.rb:215:in `visit_import'
       /tmp/build_3es5vmj75q0ih/vendor/bundle/ruby/1.9.1/gems/sass-3.2.3/lib/sass/tree/visitors/base.rb:37:in `visit'
       /tmp/build_3es5vmj75q0ih/vendor/bundle/ruby/1.9.1/gems/sass-3.2.3/lib/sass/tree/visitors/perform.rb:98:in `visit'
       /tmp/build_3es5vmj75q0ih/vendor/bundle/ruby/1.9.1/gems/sass-3.2.3/lib/sass/tree/visitors/base.rb:53:in `block in visit_children'
       /tmp/build_3es5vmj75q0ih/vendor/bundle/ruby/1.9.1/gems/sass-3.2.3/lib/sass/tree/visitors/base.rb:53:in `map'
       /tmp/build_3es5vmj75q0ih/vendor/bundle/ruby/1.9.1/gems/sass-3.2.3/lib/sass/tree/visitors/base.rb:53:in `visit_children'
       /tmp/build_3es5vmj75q0ih/vendor/bundle/ruby/1.9.1/gems/sass-3.2.3/lib/sass/tree/visitors/perform.rb:107:in `block in visit_children'
       /tmp/build_3es5vmj75q0ih/vendor/bundle/ruby/1.9.1/gems/sass-3.2.3/lib/sass/tree/visitors/perform.rb:119:in `with_environment'
       /tmp/build_3es5vmj75q0ih/vendor/bundle/ruby/1.9.1/gems/sass-3.2.3/lib/sass/tree/visitors/perform.rb:106:in `visit_children'
       /tmp/build_3es5vmj75q0ih/vendor/bundle/ruby/1.9.1/gems/sass-3.2.3/lib/sass/tree/visitors/base.rb:37:in `block in visit'
       /tmp/build_3es5vmj75q0ih/vendor/bundle/ruby/1.9.1/gems/sass-3.2.3/lib/sass/tree/visitors/perform.rb:126:in `visit_root'
       /tmp/build_3es5vmj75q0ih/vendor/bundle/ruby/1.9.1/gems/sass-3.2.3/lib/sass/tree/visitors/base.rb:37:in `visit'
       /tmp/build_3es5vmj75q0ih/vendor/bundle/ruby/1.9.1/gems/sass-3.2.3/lib/sass/tree/visitors/perform.rb:98:in `visit'
       /tmp/build_3es5vmj75q0ih/vendor/bundle/ruby/1.9.1/gems/sass-3.2.3/lib/sass/tree/visitors/perform.rb:7:in `visit'
       /tmp/build_3es5vmj75q0ih/vendor/bundle/ruby/1.9.1/gems/sass-3.2.3/lib/sass/tree/root_node.rb:20:in `render'
       /tmp/build_3es5vmj75q0ih/vendor/bundle/ruby/1.9.1/gems/sass-3.2.3/lib/sass/engine.rb:315:in `_render'
       /tmp/build_3es5vmj75q0ih/vendor/bundle/ruby/1.9.1/gems/sass-3.2.3/lib/sass/engine.rb:262:in `render'
       /tmp/build_3es5vmj75q0ih/vendor/bundle/ruby/1.9.1/gems/sass-rails-3.2.5/lib/sass/rails/template_handlers.rb:106:in `evaluate'
       /tmp/build_3es5vmj75q0ih/vendor/bundle/ruby/1.9.1/gems/tilt-1.3.3/lib/tilt/template.rb:76:in `render'
       /tmp/build_3es5vmj75q0ih/vendor/bundle/ruby/1.9.1/gems/sprockets-2.1.3/lib/sprockets/context.rb:177:in `block in evaluate'
       /tmp/build_3es5vmj75q0ih/vendor/bundle/ruby/1.9.1/gems/sprockets-2.1.3/lib/sprockets/context.rb:174:in `each'
       /tmp/build_3es5vmj75q0ih/vendor/bundle/ruby/1.9.1/gems/sprockets-2.1.3/lib/sprockets/context.rb:174:in `evaluate'
       /tmp/build_3es5vmj75q0ih/vendor/bundle/ruby/1.9.1/gems/sprockets-2.1.3/lib/sprockets/processed_asset.rb:12:in `initialize'
       /tmp/build_3es5vmj75q0ih/vendor/bundle/ruby/1.9.1/gems/sprockets-2.1.3/lib/sprockets/base.rb:241:in `new'
       /tmp/build_3es5vmj75q0ih/vendor/bundle/ruby/1.9.1/gems/sprockets-2.1.3/lib/sprockets/base.rb:241:in `block in build_asset'
       /tmp/build_3es5vmj75q0ih/vendor/bundle/ruby/1.9.1/gems/sprockets-2.1.3/lib/sprockets/base.rb:262:in `circular_call_protection'
       /tmp/build_3es5vmj75q0ih/vendor/bundle/ruby/1.9.1/gems/sprockets-2.1.3/lib/sprockets/base.rb:240:in `build_asset'
       /tmp/build_3es5vmj75q0ih/vendor/bundle/ruby/1.9.1/gems/sprockets-2.1.3/lib/sprockets/index.rb:89:in `block in build_asset'
       /tmp/build_3es5vmj75q0ih/vendor/bundle/ruby/1.9.1/gems/sprockets-2.1.3/lib/sprockets/caching.rb:19:in `cache_asset'
       /tmp/build_3es5vmj75q0ih/vendor/bundle/ruby/1.9.1/gems/sprockets-2.1.3/lib/sprockets/index.rb:88:in `build_asset'
       /tmp/build_3es5vmj75q0ih/vendor/bundle/ruby/1.9.1/gems/sprockets-2.1.3/lib/sprockets/base.rb:163:in `find_asset'
       /tmp/build_3es5vmj75q0ih/vendor/bundle/ruby/1.9.1/gems/sprockets-2.1.3/lib/sprockets/index.rb:56:in `find_asset'
       /tmp/build_3es5vmj75q0ih/vendor/bundle/ruby/1.9.1/gems/sprockets-2.1.3/lib/sprockets/processed_asset.rb:106:in `block in build_required_assets'
       /tmp/build_3es5vmj75q0ih/vendor/bundle/ruby/1.9.1/gems/sprockets-2.1.3/lib/sprockets/processed_asset.rb:100:in `each'
       /tmp/build_3es5vmj75q0ih/vendor/bundle/ruby/1.9.1/gems/sprockets-2.1.3/lib/sprockets/processed_asset.rb:100:in `build_required_assets'
       /tmp/build_3es5vmj75q0ih/vendor/bundle/ruby/1.9.1/gems/sprockets-2.1.3/lib/sprockets/processed_asset.rb:16:in `initialize'
       /tmp/build_3es5vmj75q0ih/vendor/bundle/ruby/1.9.1/gems/sprockets-2.1.3/lib/sprockets/base.rb:241:in `new'
       /tmp/build_3es5vmj75q0ih/vendor/bundle/ruby/1.9.1/gems/sprockets-2.1.3/lib/sprockets/base.rb:241:in `block in build_asset'
       /tmp/build_3es5vmj75q0ih/vendor/bundle/ruby/1.9.1/gems/sprockets-2.1.3/lib/sprockets/base.rb:262:in `circular_call_protection'
       /tmp/build_3es5vmj75q0ih/vendor/bundle/ruby/1.9.1/gems/sprockets-2.1.3/lib/sprockets/base.rb:240:in `build_asset'
       /tmp/build_3es5vmj75q0ih/vendor/bundle/ruby/1.9.1/gems/sprockets-2.1.3/lib/sprockets/index.rb:89:in `block in build_asset'
       /tmp/build_3es5vmj75q0ih/vendor/bundle/ruby/1.9.1/gems/sprockets-2.1.3/lib/sprockets/caching.rb:19:in `cache_asset'
       /tmp/build_3es5vmj75q0ih/vendor/bundle/ruby/1.9.1/gems/sprockets-2.1.3/lib/sprockets/index.rb:88:in `build_asset'
       /tmp/build_3es5vmj75q0ih/vendor/bundle/ruby/1.9.1/gems/sprockets-2.1.3/lib/sprockets/base.rb:163:in `find_asset'
       /tmp/build_3es5vmj75q0ih/vendor/bundle/ruby/1.9.1/gems/sprockets-2.1.3/lib/sprockets/index.rb:56:in `find_asset'
       /tmp/build_3es5vmj75q0ih/vendor/bundle/ruby/1.9.1/gems/sprockets-2.1.3/lib/sprockets/bundled_asset.rb:16:in `initialize'
       /tmp/build_3es5vmj75q0ih/vendor/bundle/ruby/1.9.1/gems/sprockets-2.1.3/lib/sprockets/base.rb:244:in `new'
       /tmp/build_3es5vmj75q0ih/vendor/bundle/ruby/1.9.1/gems/sprockets-2.1.3/lib/sprockets/base.rb:244:in `build_asset'
       /tmp/build_3es5vmj75q0ih/vendor/bundle/ruby/1.9.1/gems/sprockets-2.1.3/lib/sprockets/index.rb:89:in `block in build_asset'
       /tmp/build_3es5vmj75q0ih/vendor/bundle/ruby/1.9.1/gems/sprockets-2.1.3/lib/sprockets/caching.rb:19:in `cache_asset'
       /tmp/build_3es5vmj75q0ih/vendor/bundle/ruby/1.9.1/gems/sprockets-2.1.3/lib/sprockets/index.rb:88:in `build_asset'
       /tmp/build_3es5vmj75q0ih/vendor/bundle/ruby/1.9.1/gems/sprockets-2.1.3/lib/sprockets/base.rb:163:in `find_asset'
       /tmp/build_3es5vmj75q0ih/vendor/bundle/ruby/1.9.1/gems/sprockets-2.1.3/lib/sprockets/index.rb:56:in `find_asset'
       /tmp/build_3es5vmj75q0ih/vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.2/lib/sprockets/static_compiler.rb:20:in `block in compile'
       /tmp/build_3es5vmj75q0ih/vendor/bundle/ruby/1.9.1/gems/sprockets-2.1.3/lib/sprockets/base.rb:212:in `block in each_logical_path'
       /tmp/build_3es5vmj75q0ih/vendor/bundle/ruby/1.9.1/gems/sprockets-2.1.3/lib/sprockets/base.rb:200:in `block (2 levels) in each_file'
       /tmp/build_3es5vmj75q0ih/vendor/bundle/ruby/1.9.1/gems/sprockets-2.1.3/lib/sprockets/base.rb:190:in `each'
       /tmp/build_3es5vmj75q0ih/vendor/bundle/ruby/1.9.1/gems/sprockets-2.1.3/lib/sprockets/base.rb:190:in `each_entry'
       /tmp/build_3es5vmj75q0ih/vendor/bundle/ruby/1.9.1/gems/sprockets-2.1.3/lib/sprockets/base.rb:198:in `block in each_file'
       /tmp/build_3es5vmj75q0ih/vendor/bundle/ruby/1.9.1/gems/sprockets-2.1.3/lib/sprockets/base.rb:197:in `each'
       /tmp/build_3es5vmj75q0ih/vendor/bundle/ruby/1.9.1/gems/sprockets-2.1.3/lib/sprockets/base.rb:197:in `each_file'
       /tmp/build_3es5vmj75q0ih/vendor/bundle/ruby/1.9.1/gems/sprockets-2.1.3/lib/sprockets/base.rb:210:in `each_logical_path'
       /tmp/build_3es5vmj75q0ih/vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.2/lib/sprockets/static_compiler.rb:18:in `compile'
       /tmp/build_3es5vmj75q0ih/vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.2/lib/sprockets/assets.rake:56:in `internal_precompile'
       /tmp/build_3es5vmj75q0ih/vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.2/lib/sprockets/assets.rake:70:in `block (3 levels) in <top (required)>'
       /tmp/build_3es5vmj75q0ih/vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.2/lib/sprockets/assets.rake:60:in `block (3 levels) in <top (required)>'
       /tmp/build_3es5vmj75q0ih/vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.2/lib/sprockets/assets.rake:23:in `invoke_or_reboot_rake_task'
       /tmp/build_3es5vmj75q0ih/vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.2/lib/sprockets/assets.rake:29:in `block (2 levels) in <top (required)>'
       Tasks: TOP => assets:precompile:primary
       (See full trace by running task with --trace)
       Precompiling assets failed, enabling runtime asset compilation
       Injecting rails31_enable_runtime_asset_compilation
       Please see this article for troubleshooting help:
       http://devcenter.heroku.com/articles/rails31_heroku_cedar#troubleshooting
-----> Rails plugin injection
       Injecting rails_log_stdout
       Injecting rails3_serve_static_assets
-----> Discovering process types
       Procfile declares types      -> (none)
       Default types for Ruby/Rails -> console, rake, web, worker
-----> Compiled slug size: 15.9MB
-----> Launching... done, v14

And in Heroku logs I have that:

2012-11-23T01:34:01+00:00 app[web.1]: => Rails 3.2.2 application starting in production on http://0.0.0.0:4868
2012-11-23T01:34:01+00:00 app[web.1]: => Call with -d to detach
2012-11-23T01:34:01+00:00 app[web.1]: Processing by SearchesController#new as HTML
2012-11-23T01:34:02+00:00 app[web.1]:   Rendered searches/new.html.haml within layouts/application (707.1ms)
2012-11-23T01:34:03+00:00 app[web.1]: Completed 500 Internal Server Error in 1694ms
2012-11-23T01:34:03+00:00 app[web.1]: 
2012-11-23T01:34:03+00:00 app[web.1]: ActionView::Template::Error (File to import not found or unreadable: bootstrap.
2012-11-23T01:34:03+00:00 app[web.1]: Load path: /app
2012-11-23T01:34:03+00:00 app[web.1]:     4:    %title 
2012-11-23T01:34:03+00:00 app[web.1]:     5:        Seopositions
2012-11-23T01:34:03+00:00 app[web.1]:     6:    = stylesheet_link_tag "application", :media => "all"
2012-11-23T01:34:03+00:00 app[web.1]:   (in /app/app/assets/stylesheets/application.css.scss)):
2012-11-23T01:34:03+00:00 app[web.1]: 
2012-11-23T01:34:03+00:00 app[web.1]:   app/assets/stylesheets/application.css.scss:16
2012-11-23T01:34:03+00:00 app[web.1]:   app/views/layouts/application.html.haml:6:in `_app_views_layouts_application_html_haml__2436706826874996932_32759700'
2012-11-23T01:34:03+00:00 app[web.1]: cache: [GET /] miss
2012-11-23T01:34:03+00:00 app[web.1]:     8:    = csrf_meta_tags
2012-11-23T01:34:03+00:00 app[web.1]:     3: %head
2012-11-23T01:34:03+00:00 app[web.1]:     7:    = javascript_include_tag "application"
2012-11-23T01:34:03+00:00 app[web.1]:     9: %body
2012-11-23T01:34:03+00:00 app[web.1]: 
2012-11-23T01:34:03+00:00 heroku[router]: at=info method=GET path=/ host=seopositions-2.herokuapp.com fwd= dyno=web.1 queue=0 wait=2ms connect=5ms service=1939ms status=500 bytes=643
2012-11-23T01:34:04+00:00 app[web.1]: cache: [GET /favicon.ico] miss
2012-11-23T01:34:04+00:00 heroku[router]: at=info method=GET path=/favicon.ico host=seopositions-2.herokuapp.com fwd= dyno=web.1 queue=0 wait=0ms connect=3ms service=9ms status=200 bytes=0

Upvotes: 1

Views: 5214

Answers (3)

kakubei
kakubei

Reputation: 5400

You don't need to precompile manually. I was having the same problem and it turned out that the bootstrap-sass (or whatever bootstrap gem you are using) needs to be outside the assets group or you will get that error on Heroku.

If you commit to Heroku via git (I don't know any other way you would push to it) your gems will be installed via bundle and your app will get compiled. This is in the docs referenced by ethiyo.

So your Gemfile should look something like this (minus whatever assets you don't use):

# this needs to be outside of assets or it will fail on Heroku
  gem 'bootstrap-sass'

# Gems used only for assets and not required in production environments by default.
group :assets do
  gem 'coffee-rails'
  gem 'uglifier', '>= 1.0.3'
  gem 'sass-rails'
end

Precompiling locally is a pain, not least because you forget to do it, but mainly because if you do compile locally, then any changes in development to CSS or JS files will not get picked up by your local development mode since it's reading the precompiled ones. This can drive you crazy.

Upvotes: 5

ethiyo
ethiyo

Reputation: 11

Had the same problem, precompiling fixed the error. Apparently you're supposed to compile locally before pushing to Heroku, every time: https://devcenter.heroku.com/articles/rails3x-asset-pipeline-cedar.

Upvotes: 0

Edward Anderson
Edward Anderson

Reputation: 13916

Be sure to precompile your assets, either during your deploy or before you deploy, committing them into your repository

Upvotes: 1

Related Questions