简体   繁体   English

当我推送heroku时,Sqlite错误和预编译资产失败

[英]Sqlite error and Precompiling assets failed when I push heroku

I have set in the application.rb according with heroku docs about "Precompiling assets failed". 我已经根据heroku文档在application.rb中设置了有关“预编译资产失败”的信息。

config.assets.initialize_on_precompile = false

Assets were precompiled successfully locally by run 通过运行在本地成功对资产进行了预编译

RAILS_ENV=production bundle exec rake assets:precompile

I work with Rails 3.2.13. 我使用Rails 3.2.13。 I have squlite3 in the gemfile. 我在gemfile中有squlite3。 When I try to push app on heroku I have such problem: 当我尝试在heroku上推送应用时,我遇到了这样的问题:

Running: rake assets:precompile
DEPRECATION WARNING: You have Rails 2.3-style plugins...
...
rake aborted!
       Please install the sqlite3 adapter: `gem install activerecord-sqlite3-adapter` (sqlite3 is not part of the bundle. Add it to Gemfile.)
       /tmp/build_256ed4cc-34a4-4fed-8fdb-d5d5c459a1df/vendor/bundle/ruby/2.0.0/gems/bundler-1.5.2/lib/bundler/rubygems_integration.rb:240:in `block in replace_gem'
       /tmp/build_256ed4cc-34a4-4fed-8fdb-d5d5c459a1df/vendor/bundle/ruby/2.0.0/gems/activerecord-3.2.13/lib/active_record/connection_adapters/sqlite3_adapter.rb:3:in `<top (required)>'
       /tmp/build_256ed4cc-34a4-4fed-8fdb-d5d5c459a1df/vendor/bundle/ruby/2.0.0/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:251:in `require'
       /tmp/build_256ed4cc-34a4-4fed-8fdb-d5d5c459a1df/vendor/bundle/ruby/2.0.0/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:251:in `block in require'
       /tmp/build_256ed4cc-34a4-4fed-8fdb-d5d5c459a1df/vendor/bundle/ruby/2.0.0/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:236:in `load_dependency'
       /tmp/build_256ed4cc-34a4-4fed-8fdb-d5d5c459a1df/vendor/bundle/ruby/2.0.0/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:251:in `require'
       /tmp/build_256ed4cc-34a4-4fed-8fdb-d5d5c459a1df/vendor/bundle/ruby/2.0.0/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract/connection_specification.rb:50:in `resolve_hash_connection'
       /tmp/build_256ed4cc-34a4-4fed-8fdb-d5d5c459a1df/vendor/bundle/ruby/2.0.0/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract/connection_specification.rb:41:in `resolve_string_connection'
       /tmp/build_256ed4cc-34a4-4fed-8fdb-d5d5c459a1df/vendor/bundle/ruby/2.0.0/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract/connection_specification.rb:27:in `spec'
       /tmp/build_256ed4cc-34a4-4fed-8fdb-d5d5c459a1df/vendor/bundle/ruby/2.0.0/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract/connection_specification.rb:130:in `establish_connection'
       /tmp/build_256ed4cc-34a4-4fed-8fdb-d5d5c459a1df/vendor/bundle/ruby/2.0.0/gems/activerecord-3.2.13/lib/active_record/railtie.rb:82:in `block (2 levels) in <class:Railtie>'
       /tmp/build_256ed4cc-34a4-4fed-8fdb-d5d5c459a1df/vendor/bundle/ruby/2.0.0/gems/activesupport-3.2.13/lib/active_support/lazy_load_hooks.rb:36:in `instance_eval'
       /tmp/build_256ed4cc-34a4-4fed-8fdb-d5d5c459a1df/vendor/bundle/ruby/2.0.0/gems/activesupport-3.2.13/lib/active_support/lazy_load_hooks.rb:36:in `execute_hook'
       /tmp/build_256ed4cc-34a4-4fed-8fdb-d5d5c459a1df/vendor/bundle/ruby/2.0.0/gems/activesupport-3.2.13/lib/active_support/lazy_load_hooks.rb:26:in `block in on_load'
       /tmp/build_256ed4cc-34a4-4fed-8fdb-d5d5c459a1df/vendor/bundle/ruby/2.0.0/gems/activesupport-3.2.13/lib/active_support/lazy_load_hooks.rb:25:in `each'
       /tmp/build_256ed4cc-34a4-4fed-8fdb-d5d5c459a1df/vendor/bundle/ruby/2.0.0/gems/activesupport-3.2.13/lib/active_support/lazy_load_hooks.rb:25:in `on_load'
       /tmp/build_256ed4cc-34a4-4fed-8fdb-d5d5c459a1df/vendor/bundle/ruby/2.0.0/gems/activerecord-3.2.13/lib/active_record/railtie.rb:74:in `block in <class:Railtie>'
       /tmp/build_256ed4cc-34a4-4fed-8fdb-d5d5c459a1df/vendor/bundle/ruby/2.0.0/gems/railties-3.2.13/lib/rails/initializable.rb:30:in `instance_exec'
       /tmp/build_256ed4cc-34a4-4fed-8fdb-d5d5c459a1df/vendor/bundle/ruby/2.0.0/gems/railties-3.2.13/lib/rails/initializable.rb:30:in `run'
       /tmp/build_256ed4cc-34a4-4fed-8fdb-d5d5c459a1df/vendor/bundle/ruby/2.0.0/gems/railties-3.2.13/lib/rails/initializable.rb:55:in `block in run_initializers'
       /tmp/build_256ed4cc-34a4-4fed-8fdb-d5d5c459a1df/vendor/bundle/ruby/2.0.0/gems/railties-3.2.13/lib/rails/initializable.rb:54:in `each'
       /tmp/build_256ed4cc-34a4-4fed-8fdb-d5d5c459a1df/vendor/bundle/ruby/2.0.0/gems/railties-3.2.13/lib/rails/initializable.rb:54:in `run_initializers'
       /tmp/build_256ed4cc-34a4-4fed-8fdb-d5d5c459a1df/vendor/bundle/ruby/2.0.0/gems/railties-3.2.13/lib/rails/application.rb:136:in `initialize!'
       /tmp/build_256ed4cc-34a4-4fed-8fdb-d5d5c459a1df/vendor/bundle/ruby/2.0.0/gems/railties-3.2.13/lib/rails/railtie/configurable.rb:30:in `method_missing'
       /tmp/build_256ed4cc-34a4-4fed-8fdb-d5d5c459a1df/config/environment.rb:5:in `<top (required)>'
       /tmp/build_256ed4cc-34a4-4fed-8fdb-d5d5c459a1df/vendor/bundle/ruby/2.0.0/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:251:in `require'
       /tmp/build_256ed4cc-34a4-4fed-8fdb-d5d5c459a1df/vendor/bundle/ruby/2.0.0/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:251:in `block in require'
       /tmp/build_256ed4cc-34a4-4fed-8fdb-d5d5c459a1df/vendor/bundle/ruby/2.0.0/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:236:in `load_dependency'
       /tmp/build_256ed4cc-34a4-4fed-8fdb-d5d5c459a1df/vendor/bundle/ruby/2.0.0/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:251:in `require'
       /tmp/build_256ed4cc-34a4-4fed-8fdb-d5d5c459a1df/vendor/bundle/ruby/2.0.0/gems/railties-3.2.13/lib/rails/application.rb:103:in `require_environment!'
       /tmp/build_256ed4cc-34a4-4fed-8fdb-d5d5c459a1df/vendor/bundle/ruby/2.0.0/gems/railties-3.2.13/lib/rails/application.rb:297:in `block (2 levels) in initialize_tasks'
       /tmp/build_256ed4cc-34a4-4fed-8fdb-d5d5c459a1df/vendor/bundle/ruby/2.0.0/gems/actionpack-3.2.13/lib/sprockets/assets.rake:93:in `block (2 levels) in <top (required)>'
       /tmp/build_256ed4cc-34a4-4fed-8fdb-d5d5c459a1df/vendor/bundle/ruby/2.0.0/gems/actionpack-3.2.13/lib/sprockets/assets.rake:60:in `block (3 levels) in <top (required)>'
       /tmp/build_256ed4cc-34a4-4fed-8fdb-d5d5c459a1df/vendor/bundle/ruby/2.0.0/gems/actionpack-3.2.13/lib/sprockets/assets.rake:23:in `invoke_or_reboot_rake_task'
       /tmp/build_256ed4cc-34a4-4fed-8fdb-d5d5c459a1df/vendor/bundle/ruby/2.0.0/gems/actionpack-3.2.13/lib/sprockets/assets.rake:29:in `block (2 levels) in <top (required)>'
       Tasks: TOP => environment
       (See full trace by running task with --trace)
 !
 !     Precompiling assets failed.
 !

 !     Push rejected, failed to compile Ruby app

You haven't set sqlite3 from your gemfile . 您尚未从gemfile设置sqlite3。

 Please install the sqlite3 adapter: `gem install activerecord-sqlite3-adapter` (sqlite3 is not part of the bundle. Add it to Gemfile.)

However, it will still not work because sqlite3 isn't supported by heroku. 但是,它仍然不起作用,因为heroku不支持sqlite3

You can set postgresql which is supported by Heroku (gem 'pg' in your gemfile) instead. 您可以设置Heroku支持的postgresql (gemfile中的'pg')。

You can follow this official guide to see how you can procede. 您可以按照此官方指南进行操作。

在您的Gemfile添加sqlite3

 gem 'sqlite3'

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM