UPD:问题已解决。
我在整体宝石列表中添加了gem twitter-bootstrap(不仅仅是group:assets)。 并且必须在部署之前进行预编译。
部署时遇到问题。
application.css.scss
现在不存在 - 文件已被删除。
可能是什么问题?
我在添加bootstrap-sass
而不是.less
版本时启动了问题。但它失败的原因不明。我决定回去,现在我遇到了这些问题。
-----> 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
在 Heroku 日志中,我有:
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
答案 0 :(得分:5)
您无需手动预编译。我遇到了同样的问题,事实证明bootstrap-sass
(或者你正在使用的任何bootstrap gem)需要在资产组之外,否则你将在Heroku上获得该错误。
如果你通过git提交Heroku(我不知道你会推动它的任何其他方式)你的宝石将通过bundle安装,你的应用程序将被编译。这是在ethiyo引用的文档中。
所以你的Gemfile看起来应该是这样的(减去你不使用的资产):
# 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
本地预编译是一种痛苦,尤其是因为你忘了这样做,但主要是因为如果你在本地编译,那么开发到CSS或JS文件的任何改变都不会被你的本地开发模式所取代,因为它正在阅读预编译的。这可能会让你发疯。
答案 1 :(得分:1)
确保在部署期间或部署之前预先编译资产,将它们提交到存储库
答案 2 :(得分:0)
有同样的问题,预编译修复了错误。显然你应该在推送到Heroku之前在本地编译,每次:https://devcenter.heroku.com/articles/rails3x-asset-pipeline-cedar。