加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

rake资产:precompile不适用于PostgreSql

发布时间:2020-12-13 15:59:40 所属栏目:百科 来源:网络整理
导读:我正在尝试部署使用Postgres的Rails 3.2.3应用程序.我通过Capistrano使部署本身工作,数据库迁移也起作用.但现在我被困在预编译资产: deploy:MyAPP/current$bundle exec rake assets:precompile --trace** Invoke assets:precompile (first_time)** Execute
我正在尝试部署使用Postgres的Rails 3.2.3应用程序.我通过Capistrano使部署本身工作,数据库迁移也起作用.但现在我被困在预编译资产:

deploy:MyAPP/current$bundle exec rake assets:precompile --trace
** Invoke assets:precompile (first_time)
** Execute assets:precompile
/home/deploy/.rvm/rubies/ruby-1.9.3-p194/bin/ruby /home/deploy/www/MyApp/shared/bundle/ruby/1.9.1/bin/rake assets:precompile:all RAILS_ENV=production RAILS_GROUPS=assets --trace
** Invoke assets:precompile:all (first_time)
** Execute assets:precompile:all
** Invoke assets:precompile:primary (first_time)
** Invoke assets:environment (first_time)
** Execute assets:environment
** Invoke environment (first_time)
** Execute environment
** Invoke tmp:cache:clear (first_time)
** Execute tmp:cache:clear
** Execute assets:precompile:primary
** Invoke assets:precompile:nondigest (first_time)
** Invoke assets:environment (first_time)
** Execute assets:environment
** Invoke environment (first_time)
** Execute environment
rake aborted!
FATAL:  role "deploy" does not exist
/home/deploy/www/MyApp/shared/bundle/ruby/1.9.1/gems/activerecord-3.2.3/lib/active_record/connection_adapters/postgresql_adapter.rb:1194:in `initialize'
/home/deploy/www/MyApp/shared/bundle/ruby/1.9.1/gems/activerecord-3.2.3/lib/active_record/connection_adapters/postgresql_adapter.rb:1194:in `new'
/home/deploy/www/MyApp/shared/bundle/ruby/1.9.1/gems/activerecord-3.2.3/lib/active_record/connection_adapters/postgresql_adapter.rb:1194:in `connect'
/home/deploy/www/MyApp/shared/bundle/ruby/1.9.1/gems/activerecord-3.2.3/lib/active_record/connection_adapters/postgresql_adapter.rb:329:in `initialize'
/home/deploy/www/MyApp/shared/bundle/ruby/1.9.1/gems/activerecord-3.2.3/lib/active_record/connection_adapters/postgresql_adapter.rb:28:in `new'
/home/deploy/www/MyApp/shared/bundle/ruby/1.9.1/gems/activerecord-3.2.3/lib/active_record/connection_adapters/postgresql_adapter.rb:28:in `postgresql_connection'
/home/deploy/www/MyApp/shared/bundle/ruby/1.9.1/gems/activerecord-3.2.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:303:in `new_connection'
/home/deploy/www/MyApp/shared/bundle/ruby/1.9.1/gems/activerecord-3.2.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:313:in `checkout_new_connection'
/home/deploy/www/MyApp/shared/bundle/ruby/1.9.1/gems/activerecord-3.2.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:237:in `block (2 levels) in checkout'
/home/deploy/www/MyApp/shared/bundle/ruby/1.9.1/gems/activerecord-3.2.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:232:in `loop'
/home/deploy/www/MyApp/shared/bundle/ruby/1.9.1/gems/activerecord-3.2.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:232:in `block in checkout'
/home/deploy/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/monitor.rb:211:in `mon_synchronize'
/home/deploy/www/MyApp/shared/bundle/ruby/1.9.1/gems/activerecord-3.2.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:229:in `checkout'
/home/deploy/www/MyApp/shared/bundle/ruby/1.9.1/gems/activerecord-3.2.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:95:in `connection'
/home/deploy/www/MyApp/shared/bundle/ruby/1.9.1/gems/activerecord-3.2.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:398:in `retrieve_connection'
/home/deploy/www/MyApp/shared/bundle/ruby/1.9.1/gems/activerecord-3.2.3/lib/active_record/connection_adapters/abstract/connection_specification.rb:168:in `retrieve_connection'
/home/deploy/www/MyApp/shared/bundle/ruby/1.9.1/gems/activerecord-3.2.3/lib/active_record/connection_adapters/abstract/connection_specification.rb:142:in `connection'
/home/deploy/www/MyApp/shared/bundle/ruby/1.9.1/gems/activerecord-3.2.3/lib/active_record/model_schema.rb:308:in `clear_cache!'
/home/deploy/www/MyApp/shared/bundle/ruby/1.9.1/gems/activerecord-3.2.3/lib/active_record/railtie.rb:91:in `block (2 levels) in <class:Railtie>'
/home/deploy/www/MyApp/shared/bundle/ruby/1.9.1/gems/activesupport-3.2.3/lib/active_support/callbacks.rb:418:in `_run__1909267555841955845__prepare__3200542818861587462__callbacks'
/home/deploy/www/MyApp/shared/bundle/ruby/1.9.1/gems/activesupport-3.2.3/lib/active_support/callbacks.rb:405:in `__run_callback'
/home/deploy/www/MyApp/shared/bundle/ruby/1.9.1/gems/activesupport-3.2.3/lib/active_support/callbacks.rb:385:in `_run_prepare_callbacks'
/home/deploy/www/MyApp/shared/bundle/ruby/1.9.1/gems/activesupport-3.2.3/lib/active_support/callbacks.rb:81:in `run_callbacks'
/home/deploy/www/MyApp/shared/bundle/ruby/1.9.1/gems/actionpack-3.2.3/lib/action_dispatch/middleware/reloader.rb:74:in `prepare!'
/home/deploy/www/MyApp/shared/bundle/ruby/1.9.1/gems/actionpack-3.2.3/lib/action_dispatch/middleware/reloader.rb:48:in `prepare!'
/home/deploy/www/MyApp/shared/bundle/ruby/1.9.1/gems/railties-3.2.3/lib/rails/application/finisher.rb:47:in `block in <module:Finisher>'
/home/deploy/www/MyApp/shared/bundle/ruby/1.9.1/gems/railties-3.2.3/lib/rails/initializable.rb:30:in `instance_exec'
/home/deploy/www/MyApp/shared/bundle/ruby/1.9.1/gems/railties-3.2.3/lib/rails/initializable.rb:30:in `run'
/home/deploy/www/MyApp/shared/bundle/ruby/1.9.1/gems/railties-3.2.3/lib/rails/initializable.rb:55:in `block in run_initializers'
/home/deploy/www/MyApp/shared/bundle/ruby/1.9.1/gems/railties-3.2.3/lib/rails/initializable.rb:54:in `each'
/home/deploy/www/MyApp/shared/bundle/ruby/1.9.1/gems/railties-3.2.3/lib/rails/initializable.rb:54:in `run_initializers'
/home/deploy/www/MyApp/shared/bundle/ruby/1.9.1/gems/railties-3.2.3/lib/rails/application.rb:136:in `initialize!'
/home/deploy/www/MyApp/shared/bundle/ruby/1.9.1/gems/railties-3.2.3/lib/rails/railtie/configurable.rb:30:in `method_missing'
/home/deploy/www/MyApp/releases/20120503154931/config/environment.rb:5:in `<top (required)>'
/home/deploy/www/MyApp/shared/bundle/ruby/1.9.1/gems/activesupport-3.2.3/lib/active_support/dependencies.rb:251:in `require'
/home/deploy/www/MyApp/shared/bundle/ruby/1.9.1/gems/activesupport-3.2.3/lib/active_support/dependencies.rb:251:in `block in require'
/home/deploy/www/MyApp/shared/bundle/ruby/1.9.1/gems/activesupport-3.2.3/lib/active_support/dependencies.rb:236:in `load_dependency'
/home/deploy/www/MyApp/shared/bundle/ruby/1.9.1/gems/activesupport-3.2.3/lib/active_support/dependencies.rb:251:in `require'
/home/deploy/www/MyApp/shared/bundle/ruby/1.9.1/gems/railties-3.2.3/lib/rails/application.rb:103:in `require_environment!'
/home/deploy/www/MyApp/shared/bundle/ruby/1.9.1/gems/railties-3.2.3/lib/rails/application.rb:292:in `block (2 levels) in initialize_tasks'
/home/deploy/www/MyApp/shared/bundle/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:205:in `call'
/home/deploy/www/MyApp/shared/bundle/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:205:in `block in execute'
/home/deploy/www/MyApp/shared/bundle/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:200:in `each'
/home/deploy/www/MyApp/shared/bundle/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:200:in `execute'
/home/deploy/www/MyApp/shared/bundle/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:158:in `block in invoke_with_call_chain'
/home/deploy/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/monitor.rb:211:in `mon_synchronize'
/home/deploy/www/MyApp/shared/bundle/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:151:in `invoke_with_call_chain'
/home/deploy/www/MyApp/shared/bundle/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:144:in `invoke'
/home/deploy/www/MyApp/shared/bundle/ruby/1.9.1/gems/actionpack-3.2.3/lib/sprockets/assets.rake:93:in `block (2 levels) in <top (required)>'
/home/deploy/www/MyApp/shared/bundle/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:205:in `call'
/home/deploy/www/MyApp/shared/bundle/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:205:in `block in execute'
/home/deploy/www/MyApp/shared/bundle/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:200:in `each'
/home/deploy/www/MyApp/shared/bundle/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:200:in `execute'
/home/deploy/www/MyApp/shared/bundle/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:158:in `block in invoke_with_call_chain'
/home/deploy/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/monitor.rb:211:in `mon_synchronize'
/home/deploy/www/MyApp/shared/bundle/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:151:in `invoke_with_call_chain'
/home/deploy/www/MyApp/shared/bundle/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:176:in `block in invoke_prerequisites'
/home/deploy/www/MyApp/shared/bundle/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:174:in `each'
/home/deploy/www/MyApp/shared/bundle/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:174:in `invoke_prerequisites'
/home/deploy/www/MyApp/shared/bundle/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:157:in `block in invoke_with_call_chain'
/home/deploy/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/monitor.rb:211:in `mon_synchronize'
/home/deploy/www/MyApp/shared/bundle/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:151:in `invoke_with_call_chain'
/home/deploy/www/MyApp/shared/bundle/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:144:in `invoke'
/home/deploy/www/MyApp/shared/bundle/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:116:in `invoke_task'
/home/deploy/www/MyApp/shared/bundle/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:94:in `block (2 levels) in top_level'
/home/deploy/www/MyApp/shared/bundle/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:94:in `each'
/home/deploy/www/MyApp/shared/bundle/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:94:in `block in top_level'
/home/deploy/www/MyApp/shared/bundle/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:133:in `standard_exception_handling'
/home/deploy/www/MyApp/shared/bundle/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:88:in `top_level'
/home/deploy/www/MyApp/shared/bundle/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:66:in `block in run'
/home/deploy/www/MyApp/shared/bundle/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:133:in `standard_exception_handling'
/home/deploy/www/MyApp/shared/bundle/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:63:in `run'
/home/deploy/www/MyApp/shared/bundle/ruby/1.9.1/gems/rake-0.9.2.2/bin/rake:33:in `<top (required)>'
/home/deploy/www/MyApp/shared/bundle/ruby/1.9.1/bin/rake:23:in `load'
/home/deploy/www/MyApp/shared/bundle/ruby/1.9.1/bin/rake:23:in `<main>'
Tasks: TOP => environment
rake aborted!
Command failed with status (1): [/home/deploy/.rvm/rubies/ruby-1.9.3-p194/b...]
/home/deploy/www/MyApp/shared/bundle/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/file_utils.rb:53:in `block in create_shell_runner'
/home/deploy/www/MyApp/shared/bundle/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/file_utils.rb:45:in `call'
/home/deploy/www/MyApp/shared/bundle/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/file_utils.rb:45:in `sh'
/home/deploy/www/MyApp/shared/bundle/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/file_utils_ext.rb:39:in `sh'
/home/deploy/www/MyApp/shared/bundle/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/file_utils.rb:80:in `ruby'
/home/deploy/www/MyApp/shared/bundle/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/file_utils_ext.rb:39:in `ruby'
/home/deploy/www/MyApp/shared/bundle/ruby/1.9.1/gems/actionpack-3.2.3/lib/sprockets/assets.rake:12:in `ruby_rake_task'
/home/deploy/www/MyApp/shared/bundle/ruby/1.9.1/gems/actionpack-3.2.3/lib/sprockets/assets.rake:21:in `invoke_or_reboot_rake_task'
/home/deploy/www/MyApp/shared/bundle/ruby/1.9.1/gems/actionpack-3.2.3/lib/sprockets/assets.rake:29:in `block (2 levels) in <top (required)>'
/home/deploy/www/MyApp/shared/bundle/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:205:in `call'
/home/deploy/www/MyApp/shared/bundle/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:205:in `block in execute'
/home/deploy/www/MyApp/shared/bundle/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:200:in `each'
/home/deploy/www/MyApp/shared/bundle/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:200:in `execute'
/home/deploy/www/MyApp/shared/bundle/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:158:in `block in invoke_with_call_chain'
/home/deploy/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/monitor.rb:211:in `mon_synchronize'
/home/deploy/www/MyApp/shared/bundle/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:151:in `invoke_with_call_chain'
/home/deploy/www/MyApp/shared/bundle/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:144:in `invoke'
/home/deploy/www/MyApp/shared/bundle/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:116:in `invoke_task'
/home/deploy/www/MyApp/shared/bundle/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:94:in `block (2 levels) in top_level'
/home/deploy/www/MyApp/shared/bundle/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:94:in `each'
/home/deploy/www/MyApp/shared/bundle/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:94:in `block in top_level'
/home/deploy/www/MyApp/shared/bundle/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:133:in `standard_exception_handling'
/home/deploy/www/MyApp/shared/bundle/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:88:in `top_level'
/home/deploy/www/MyApp/shared/bundle/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:66:in `block in run'
/home/deploy/www/MyApp/shared/bundle/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:133:in `standard_exception_handling'
/home/deploy/www/MyApp/shared/bundle/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:63:in `run'
/home/deploy/www/MyApp/shared/bundle/ruby/1.9.1/gems/rake-0.9.2.2/bin/rake:33:in `<top (required)>'
/home/deploy/www/MyApp/shared/bundle/ruby/1.9.1/bin/rake:23:in `load'
/home/deploy/www/MyApp/shared/bundle/ruby/1.9.1/bin/rake:23:in `<main>'
Tasks: TOP => assets:precompile

出于某种原因,它试图以系统用户“部署”的身份登录Postgres,但我完全不知道为什么 – 我从来没有遇到过MySql的问题……

有人有想法吗?

干杯,CS

解决方法

Rake初始化整个rails堆栈,postgres适配器似乎在启动时测试连接.由于该案例没有凭据,因此rake失败.

为了防止rake这样做,我不得不把它放在我的config / application.rb中:

config.assets.initialize_on_precompile = false

这对我行得通!

发现于this answer.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读