rake db:setup
返回:
rake aborted!
You have already activated rake 0.9.6, but your Gemfile requires rake 10.1.1. Prepending `bundle exec` to your command may solve this.
/Users/chendriksen/.rvm/gems/ruby-2.0.0-p195@global/gems/bundler-1.5.3/lib/bundler/runtime.rb:34:in `block in setup'
/Users/chendriksen/.rvm/gems/ruby-2.0.0-p195@global/gems/bundler-1.5.3/lib/bundler/runtime.rb:19:in `setup'
/Users/chendriksen/.rvm/gems/ruby-2.0.0-p195@global/gems/bundler-1.5.3/lib/bundler.rb:119:in `setup'
/Users/chendriksen/.rvm/gems/ruby-2.0.0-p195@global/gems/bundler-1.5.3/lib/bundler/setup.rb:7:in `<top (required)>'
/Users/chendriksen/code/pact/config/boot.rb:6:in `<top (required)>'
/Users/chendriksen/code/pact/config/application.rb:1:in `<top (required)>'
/Users/chendriksen/code/pact/Rakefile:5:in `<top (required)>'
(See full trace by running task with --trace)
然后运行bundle exec rake db:setup
返回:
WARNING: Nokogiri was built against LibXML version 2.9.1, but has dynamically loaded 2.9.0
pact_development already exists
pact_test already exists
rake aborted!
PG::Error: ERROR: relation "vouchers" does not exist
LINE 5: WHERE a.attrelid = '"vouchers"'::regclass
^
: SELECT a.attname, format_type(a.atttypid, a.atttypmod),
pg_get_expr(d.adbin, d.adrelid), a.attnotnull, a.atttypid, a.atttypmod
FROM pg_attribute a LEFT JOIN pg_attrdef d
ON a.attrelid = d.adrelid AND a.attnum = d.adnum
WHERE a.attrelid = '"vouchers"'::regclass
AND a.attnum > 0 AND NOT a.attisdropped
ORDER BY a.attnum
/Users/chendriksen/code/pact/vendor/bundle/gems/activerecord-3.2.16/lib/active_record/connection_adapters/postgresql_adapter.rb:1163:in `exec'
/Users/chendriksen/code/pact/vendor/bundle/gems/activerecord-3.2.16/lib/active_record/connection_adapters/postgresql_adapter.rb:1163:in `exec_no_cache'
/Users/chendriksen/code/pact/vendor/bundle/gems/activerecord-3.2.16/lib/active_record/connection_adapters/postgresql_adapter.rb:660:in `block in exec_query'
/Users/chendriksen/code/pact/vendor/bundle/gems/activerecord-3.2.16/lib/active_record/connection_adapters/abstract_adapter.rb:280:in `block in log'
/Users/chendriksen/code/pact/vendor/bundle/gems/activesupport-3.2.16/lib/active_support/notifications/instrumenter.rb:20:in `instrument'
/Users/chendriksen/code/pact/vendor/bundle/gems/activerecord-3.2.16/lib/active_record/connection_adapters/abstract_adapter.rb:275:in `log'
/Users/chendriksen/code/pact/vendor/bundle/gems/activerecord-3.2.16/lib/active_record/connection_adapters/postgresql_adapter.rb:659:in `exec_query'
/Users/chendriksen/code/pact/vendor/bundle/gems/activerecord-3.2.16/lib/active_record/connection_adapters/postgresql_adapter.rb:1292:in `column_definitions'
/Users/chendriksen/code/pact/vendor/bundle/gems/activerecord-3.2.16/lib/active_record/connection_adapters/postgresql_adapter.rb:855:in `columns'
/Users/chendriksen/code/pact/vendor/bundle/gems/activerecord-3.2.16/lib/active_record/connection_adapters/schema_cache.rb:12:in `block in initialize'
/Users/chendriksen/code/pact/vendor/bundle/gems/activerecord-3.2.16/lib/active_record/model_schema.rb:229:in `yield'
/Users/chendriksen/code/pact/vendor/bundle/gems/activerecord-3.2.16/lib/active_record/model_schema.rb:229:in `columns'
/Users/chendriksen/code/pact/vendor/bundle/gems/activerecord-3.2.16/lib/active_record/model_schema.rb:238:in `columns_hash'
/Users/chendriksen/code/pact/vendor/bundle/gems/activerecord-3.2.16/lib/active_record/inheritance.rb:19:in `descends_from_active_record?'
/Users/chendriksen/code/pact/vendor/bundle/gems/activerecord-3.2.16/lib/active_record/inheritance.rb:25:in `finder_needs_type_condition?'
/Users/chendriksen/code/pact/vendor/bundle/gems/activerecord-3.2.16/lib/active_record/base.rb:455:in `relation'
/Users/chendriksen/code/pact/vendor/bundle/gems/activerecord-3.2.16/lib/active_record/scoping/named.rb:37:in `scoped'
/Users/chendriksen/code/pact/vendor/bundle/gems/activerecord-3.2.16/lib/active_record/querying.rb:9:in `where'
/Users/chendriksen/code/pact/app/models/bags_discount.rb:7:in `<class:BagsDiscount>'
/Users/chendriksen/code/pact/app/models/bags_discount.rb:1:in `<top (required)>'
/Users/chendriksen/code/pact/vendor/bundle/gems/activesupport-3.2.16/lib/active_support/dependencies.rb:469:in `load'
/Users/chendriksen/code/pact/vendor/bundle/gems/activesupport-3.2.16/lib/active_support/dependencies.rb:469:in `block in load_file'
/Users/chendriksen/code/pact/vendor/bundle/gems/activesupport-3.2.16/lib/active_support/dependencies.rb:639:in `new_constants_in'
/Users/chendriksen/code/pact/vendor/bundle/gems/activesupport-3.2.16/lib/active_support/dependencies.rb:468:in `load_file'
/Users/chendriksen/code/pact/vendor/bundle/gems/activesupport-3.2.16/lib/active_support/dependencies.rb:353:in `require_or_load'
/Users/chendriksen/code/pact/vendor/bundle/gems/activesupport-3.2.16/lib/active_support/dependencies.rb:502:in `load_missing_constant'
/Users/chendriksen/code/pact/vendor/bundle/gems/activesupport-3.2.16/lib/active_support/dependencies.rb:192:in `block in const_missing'
/Users/chendriksen/code/pact/vendor/bundle/gems/activesupport-3.2.16/lib/active_support/dependencies.rb:190:in `each'
/Users/chendriksen/code/pact/vendor/bundle/gems/activesupport-3.2.16/lib/active_support/dependencies.rb:190:in `const_missing'
/Users/chendriksen/code/pact/app/admin/bags_discounts.rb:1:in `<top (required)>'
/Users/chendriksen/code/pact/vendor/bundle/gems/activesupport-3.2.16/lib/active_support/dependencies.rb:245:in `load'
/Users/chendriksen/code/pact/vendor/bundle/gems/activesupport-3.2.16/lib/active_support/dependencies.rb:245:in `block in load'
/Users/chendriksen/code/pact/vendor/bundle/gems/activesupport-3.2.16/lib/active_support/dependencies.rb:236:in `load_dependency'
/Users/chendriksen/code/pact/vendor/bundle/gems/activesupport-3.2.16/lib/active_support/dependencies.rb:245:in `load'
/Users/chendriksen/code/pact/vendor/bundle/gems/activeadmin-0.6.0/lib/active_admin/application.rb:179:in `block in load!'
/Users/chendriksen/code/pact/vendor/bundle/gems/activeadmin-0.6.0/lib/active_admin/application.rb:179:in `each'
/Users/chendriksen/code/pact/vendor/bundle/gems/activeadmin-0.6.0/lib/active_admin/application.rb:179:in `load!'
/Users/chendriksen/code/pact/vendor/bundle/gems/activeadmin-0.6.0/lib/active_admin/application.rb:197:in `routes'
/Users/chendriksen/code/pact/vendor/bundle/gems/activeadmin-0.6.0/lib/active_admin.rb:83:in `routes'
/Users/chendriksen/code/pact/config/routes.rb:126:in `block in <top (required)>'
/Users/chendriksen/code/pact/vendor/bundle/gems/actionpack-3.2.16/lib/action_dispatch/routing/route_set.rb:285:in `instance_exec'
/Users/chendriksen/code/pact/vendor/bundle/gems/actionpack-3.2.16/lib/action_dispatch/routing/route_set.rb:285:in `eval_block'
/Users/chendriksen/code/pact/vendor/bundle/gems/actionpack-3.2.16/lib/action_dispatch/routing/route_set.rb:263:in `draw'
/Users/chendriksen/code/pact/config/routes.rb:1:in `<top (required)>'
/Users/chendriksen/code/pact/vendor/bundle/gems/activesupport-3.2.16/lib/active_support/dependencies.rb:245:in `load'
/Users/chendriksen/code/pact/vendor/bundle/gems/activesupport-3.2.16/lib/active_support/dependencies.rb:245:in `block in load'
/Users/chendriksen/code/pact/vendor/bundle/gems/activesupport-3.2.16/lib/active_support/dependencies.rb:236:in `load_dependency'
/Users/chendriksen/code/pact/vendor/bundle/gems/activesupport-3.2.16/lib/active_support/dependencies.rb:245:in `load'
/Users/chendriksen/code/pact/vendor/bundle/gems/railties-3.2.16/lib/rails/application/routes_reloader.rb:40:in `block in load_paths'
/Users/chendriksen/code/pact/vendor/bundle/gems/railties-3.2.16/lib/rails/application/routes_reloader.rb:40:in `each'
/Users/chendriksen/code/pact/vendor/bundle/gems/railties-3.2.16/lib/rails/application/routes_reloader.rb:40:in `load_paths'
/Users/chendriksen/code/pact/vendor/bundle/gems/railties-3.2.16/lib/rails/application/routes_reloader.rb:16:in `reload!'
/Users/chendriksen/code/pact/vendor/bundle/gems/railties-3.2.16/lib/rails/application.rb:108:in `reload_routes!'
/Users/chendriksen/code/pact/vendor/bundle/gems/activeadmin-0.6.0/lib/active_admin/reloader.rb:34:in `reload!'
/Users/chendriksen/code/pact/vendor/bundle/gems/activeadmin-0.6.0/lib/active_admin/reloader.rb:61:in `block in attach!'
/Users/chendriksen/code/pact/vendor/bundle/gems/activesupport-3.2.16/lib/active_support/callbacks.rb:429:in `_run__1647445383897827895__prepare__208299187468116130__callbacks'
/Users/chendriksen/code/pact/vendor/bundle/gems/activesupport-3.2.16/lib/active_support/callbacks.rb:405:in `__run_callback'
/Users/chendriksen/code/pact/vendor/bundle/gems/activesupport-3.2.16/lib/active_support/callbacks.rb:385:in `_run_prepare_callbacks'
/Users/chendriksen/code/pact/vendor/bundle/gems/activesupport-3.2.16/lib/active_support/callbacks.rb:81:in `run_callbacks'
/Users/chendriksen/code/pact/vendor/bundle/gems/actionpack-3.2.16/lib/action_dispatch/middleware/reloader.rb:74:in `prepare!'
/Users/chendriksen/code/pact/vendor/bundle/gems/actionpack-3.2.16/lib/action_dispatch/middleware/reloader.rb:48:in `prepare!'
/Users/chendriksen/code/pact/vendor/bundle/gems/railties-3.2.16/lib/rails/application/finisher.rb:47:in `block in <module:Finisher>'
/Users/chendriksen/code/pact/vendor/bundle/gems/railties-3.2.16/lib/rails/initializable.rb:30:in `instance_exec'
/Users/chendriksen/code/pact/vendor/bundle/gems/railties-3.2.16/lib/rails/initializable.rb:30:in `run'
/Users/chendriksen/code/pact/vendor/bundle/gems/railties-3.2.16/lib/rails/initializable.rb:55:in `block in run_initializers'
/Users/chendriksen/code/pact/vendor/bundle/gems/railties-3.2.16/lib/rails/initializable.rb:54:in `each'
/Users/chendriksen/code/pact/vendor/bundle/gems/railties-3.2.16/lib/rails/initializable.rb:54:in `run_initializers'
/Users/chendriksen/code/pact/vendor/bundle/gems/railties-3.2.16/lib/rails/application.rb:136:in `initialize!'
/Users/chendriksen/code/pact/vendor/bundle/gems/railties-3.2.16/lib/rails/railtie/configurable.rb:30:in `method_missing'
/Users/chendriksen/code/pact/config/environment.rb:5:in `<top (required)>'
/Users/chendriksen/code/pact/vendor/bundle/gems/activesupport-3.2.16/lib/active_support/dependencies.rb:251:in `require'
/Users/chendriksen/code/pact/vendor/bundle/gems/activesupport-3.2.16/lib/active_support/dependencies.rb:251:in `block in require'
/Users/chendriksen/code/pact/vendor/bundle/gems/activesupport-3.2.16/lib/active_support/dependencies.rb:236:in `load_dependency'
/Users/chendriksen/code/pact/vendor/bundle/gems/activesupport-3.2.16/lib/active_support/dependencies.rb:251:in `require'
/Users/chendriksen/code/pact/vendor/bundle/gems/railties-3.2.16/lib/rails/application.rb:103:in `require_environment!'
/Users/chendriksen/code/pact/vendor/bundle/gems/railties-3.2.16/lib/rails/application.rb:305:in `block (2 levels) in initialize_tasks'
Tasks: TOP => db:setup => db:schema:load_if_ruby => environment
(See full trace by running task with --trace)
我知道这不是代码的问题,因为它现在正在我们的服务器上运行。可能导致此问题的任何想法?
答案 0 :(得分:0)
'vouchers'
代替'"vouchers"'
答案 1 :(得分:0)
此错误
rake aborted!
You have already activated rake 0.9.6, but your Gemfile requires...
现在并不重要。始终使用bundle
exec
添加命令,这样你就会很好。
您的服务器应该在producion Rails环境中工作吗?如果 所以,你应该运行
RAILS_ENV=production bundle exec rake db:setup
但是由于第二个错误,它无论如何都不会起作用。
...PG::Error: ERROR: relation "vouchers" does not exist...
我相信这个错误的原因在于:
app/models/bags_discount.rb:7
BagsDiscount
模型可能有一些scope
,它使用
vouchers
表。当您运行db:setup
时,所有与应用程序相关
类已初始化,但表尚不存在。
此评论可能会有所帮助:
https://github.com/rails/rails/issues/6470#issuecomment-19839863
UPD:如果你想快速&amp;脏解决方案:只需注释掉问题行并在之后取消注释。这种耙子任务不应该太危险。