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

时间:2014-01-23 10:45:23

标签: ruby-on-rails ruby sqlite heroku

我在application.rb中根据heroku docs设置了“预编译资产失败”。

config.assets.initialize_on_precompile = false

资产是通过运行

在本地成功预编译的
RAILS_ENV=production bundle exec rake assets:precompile

我使用Rails 3.2.13。我在gemfile中有squlite3。 当我尝试在heroku上推送app时,我遇到了这样的问题:

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

2 个答案:

答案 0 :(得分:1)

您尚未从gemfile设置sqlite3。

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

但是,它仍然无效,因为heroku不支持sqlite3

您可以设置Heroku支持的postgresql(gem文件中的gem'pg')。

您可以按照this official guide了解如何处理。

答案 1 :(得分:1)

Gemfile

中添加sqlite3
 gem 'sqlite3'