Dokku + Rails + Postgresql错误 - URI :: InvalidURIError:方案postgres不接受注册表部分:root

时间:2015-03-16 06:52:00

标签: ruby-on-rails postgresql dokku

您好我正在数字海洋上玩Dokku作为Heroku的替代品。我已经阅读过Digital Ocean和其他博客的至少15个指南。除非我第一次运行rails迁移,否则一切看起来都非常简单。

我收到以下错误...

root@jibberishkey:~# RAILS_ENV=production rake db:migrate
rake aborted!
URI::InvalidURIError: the scheme postgres does not accept registry part: root:password: (or bad hostname?)
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.2.0/lib/active_record/connection_adapters/connection_specification.rb:36:in `initialize'
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.2.0/lib/active_record/connection_adapters/connection_specification.rb:270:in `new'
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.2.0/lib/active_record/connection_adapters/connection_specification.rb:270:in `resolve_url_connection'
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.2.0/lib/active_record/connection_adapters/connection_specification.rb:258:in `resolve_hash_connection'
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.2.0/lib/active_record/connection_adapters/connection_specification.rb:215:in `resolve_connection'
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.2.0/lib/active_record/connection_adapters/connection_specification.rb:139:in `resolve'
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.2.0/lib/active_record/connection_adapters/connection_specification.rb:151:in `block in resolve_all'
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.2.0/lib/active_record/connection_adapters/connection_specification.rb:150:in `each'
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.2.0/lib/active_record/connection_adapters/connection_specification.rb:150:in `resolve_all'
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.2.0/lib/active_record/connection_handling.rb:69:in `resolve'
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.2.0/lib/active_record/core.rb:46:in `configurations='
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.2.0/lib/active_record/core.rb:48:in `block in <module:Core>'
/app/vendor/bundle/ruby/2.0.0/gems/activesupport-4.2.0/lib/active_support/concern.rb:120:in `class_eval'
/app/vendor/bundle/ruby/2.0.0/gems/activesupport-4.2.0/lib/active_support/concern.rb:120:in `append_features'
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.2.0/lib/active_record/base.rb:285:in `include'
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.2.0/lib/active_record/base.rb:285:in `<class:Base>'
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.2.0/lib/active_record/base.rb:270:in `<module:ActiveRecord>'
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.2.0/lib/active_record/base.rb:26:in `<top (required)>'
/app/vendor/bundle/ruby/2.0.0/gems/ancestry-2.1.0/lib/ancestry/has_ancestry.rb:1:in `<top (required)>'
/app/vendor/bundle/ruby/2.0.0/gems/ancestry-2.1.0/lib/ancestry.rb:4:in `require_relative'
/app/vendor/bundle/ruby/2.0.0/gems/ancestry-2.1.0/lib/ancestry.rb:4:in `<top (required)>'
/app/vendor/bundle/ruby/2.0.0/gems/bundler-1.6.3/lib/bundler/runtime.rb:76:in `require'
/app/vendor/bundle/ruby/2.0.0/gems/bundler-1.6.3/lib/bundler/runtime.rb:76:in `block (2 levels) in require'
/app/vendor/bundle/ruby/2.0.0/gems/bundler-1.6.3/lib/bundler/runtime.rb:72:in `each'
/app/vendor/bundle/ruby/2.0.0/gems/bundler-1.6.3/lib/bundler/runtime.rb:72:in `block in require'
/app/vendor/bundle/ruby/2.0.0/gems/bundler-1.6.3/lib/bundler/runtime.rb:61:in `each'
/app/vendor/bundle/ruby/2.0.0/gems/bundler-1.6.3/lib/bundler/runtime.rb:61:in `require'
/app/vendor/bundle/ruby/2.0.0/gems/bundler-1.6.3/lib/bundler.rb:132:in `require'
/app/config/application.rb:16:in `<top (required)>'
/app/Rakefile:4:in `require'
/app/Rakefile:4:in `<top (required)>'
(See full trace by running task with --trace)

我已将postgresql数据库与我的Dokku应用程序相关联。我唯一能想到的是它与我的Dokku配置或与我的database.yml重叠Dokku配置设置有关。我似乎无法弄明白。

我的用于制作的database.yml文件是:

production:
  url: <%= ENV['DATABASE_URL'] %>

我的应用程序的dokku配置是:

DATABASE_URL:      postgres://root:password:/db
NO_VHOST:          1
rails_env:         production

我可以确认config中的密码与db:migrate错误中的密码相同。这也与我在Dokku应用程序export中的内容相同,我通过从服务器运行这一系列命令找到了...

docker run -i -t dokku/app_name /bin/bash
export HOME=/app
for file in /app/.profile.d/*; do source $file; done
hash -r
export

任何人都能够获得额外的光线吗?

由于

2 个答案:

答案 0 :(得分:1)

这可能是dokku-pg-plugin的最新问题,因为我能够使用较旧版本的dokku-pg-plugin创建数据库/使用数据库连接应用程序。< / p>

我向项目团队提出了一个问题,他可以提出建议:https://github.com/Kloadut/dokku-pg-plugin/issues/69

答案 1 :(得分:1)

我认为数据库URL不正确。它看起来应该像postgres://root:password@localhost/db