I am developing a Rails application. The database used is OrientDB. I am using the active-orient
gem for this. Everything was running fine until I updated my Bundler version. After that I am unable to open the Rails console with rails c
. Following is the error stack
我正在开发一个Rails应用程序。使用的数据库是OrientDB。我正在使用active-orient gem。一切都运行良好,直到我更新我的Bundler版本。之后我无法使用rails c打开Rails控制台。以下是错误堆栈
$ rails c
Railtie included!!
I, [2017-09-21T19:48:05.335384 #25012] INFO -- : Orientdb4r 0.5.1, running on Ruby 2.4.0 (2016-12-24) [x86_64-linux]
WARNING: Use strings for Figaro configuration. 5432 was converted to "5432".
WARNING: Use strings for Figaro configuration. 2480 was converted to "2480".
WARNING: Use strings for Figaro configuration. 100000000 was converted to "100000000".
/home/ubuntu/.rvm/rubies/ruby-2.4.0/lib/ruby/2.4.0/uri/rfc3986_parser.rb:67:in `split': bad URI(is not URI?): http://localhost:2480/connect/ENV['orientdb_database'] (URI::InvalidURIError)
from /home/ubuntu/.rvm/rubies/ruby-2.4.0/lib/ruby/2.4.0/uri/rfc3986_parser.rb:73:in `parse'
from /home/ubuntu/.rvm/rubies/ruby-2.4.0/lib/ruby/2.4.0/uri/common.rb:231:in `parse'
from /home/ubuntu/.rvm/gems/ruby-2.4.0/gems/rest-client-1.8.0/lib/restclient/request.rb:276:in `parse_url'
from /home/ubuntu/.rvm/gems/ruby-2.4.0/gems/rest-client-1.8.0/lib/restclient/request.rb:280:in `parse_url_with_auth'
from /home/ubuntu/.rvm/gems/ruby-2.4.0/gems/rest-client-1.8.0/lib/restclient/request.rb:175:in `execute'
from /home/ubuntu/.rvm/gems/ruby-2.4.0/gems/rest-client-1.8.0/lib/restclient/request.rb:41:in `execute'
from /home/ubuntu/.rvm/gems/ruby-2.4.0/gems/rest-client-1.8.0/lib/restclient/resource.rb:51:in `get'
from /home/ubuntu/.rvm/gems/ruby-2.4.0/bundler/gems/active-orient-4f90f0276d4c/lib/rest/rest.rb:105:in `connect'
from /home/ubuntu/.rvm/gems/ruby-2.4.0/bundler/gems/active-orient-4f90f0276d4c/lib/rest/rest.rb:83:in `initialize'
from /home/ubuntu/.rvm/gems/ruby-2.4.0/bundler/gems/active-orient-4f90f0276d4c/lib/railtie.rb:42:in `new'
from /home/ubuntu/.rvm/gems/ruby-2.4.0/bundler/gems/active-orient-4f90f0276d4c/lib/railtie.rb:42:in `block in <class:Railtie>'
from /home/ubuntu/.rvm/gems/ruby-2.4.0/gems/railties-5.0.6/lib/rails/initializable.rb:30:in `instance_exec'
from /home/ubuntu/.rvm/gems/ruby-2.4.0/gems/railties-5.0.6/lib/rails/initializable.rb:30:in `run'
from /home/ubuntu/.rvm/gems/ruby-2.4.0/gems/railties-5.0.6/lib/rails/initializable.rb:55:in `block in run_initializers'
from /home/ubuntu/.rvm/rubies/ruby-2.4.0/lib/ruby/2.4.0/tsort.rb:228:in `block in tsort_each'
from /home/ubuntu/.rvm/rubies/ruby-2.4.0/lib/ruby/2.4.0/tsort.rb:350:in `block (2 levels) in each_strongly_connected_component'
from /home/ubuntu/.rvm/rubies/ruby-2.4.0/lib/ruby/2.4.0/tsort.rb:431:in `each_strongly_connected_component_from'
from /home/ubuntu/.rvm/rubies/ruby-2.4.0/lib/ruby/2.4.0/tsort.rb:349:in `block in each_strongly_connected_component'
from /home/ubuntu/.rvm/rubies/ruby-2.4.0/lib/ruby/2.4.0/tsort.rb:347:in `each'
from /home/ubuntu/.rvm/rubies/ruby-2.4.0/lib/ruby/2.4.0/tsort.rb:347:in `call'
from /home/ubuntu/.rvm/rubies/ruby-2.4.0/lib/ruby/2.4.0/tsort.rb:347:in `each_strongly_connected_component'
from /home/ubuntu/.rvm/rubies/ruby-2.4.0/lib/ruby/2.4.0/tsort.rb:226:in `tsort_each'
from /home/ubuntu/.rvm/rubies/ruby-2.4.0/lib/ruby/2.4.0/tsort.rb:205:in `tsort_each'
from /home/ubuntu/.rvm/gems/ruby-2.4.0/gems/railties-5.0.6/lib/rails/initializable.rb:54:in `run_initializers'
from /home/ubuntu/.rvm/gems/ruby-2.4.0/gems/railties-5.0.6/lib/rails/application.rb:352:in `initialize!'
from /home/ubuntu/my-project/config/environment.rb:5:in `<top (required)>'
from /home/ubuntu/.rvm/gems/ruby-2.4.0/gems/activesupport-5.0.6/lib/active_support/dependencies.rb:293:in `require'
from /home/ubuntu/.rvm/gems/ruby-2.4.0/gems/activesupport-5.0.6/lib/active_support/dependencies.rb:293:in `block in require'
from /home/ubuntu/.rvm/gems/ruby-2.4.0/gems/activesupport-5.0.6/lib/active_support/dependencies.rb:259:in `load_dependency'
from /home/ubuntu/.rvm/gems/ruby-2.4.0/gems/activesupport-5.0.6/lib/active_support/dependencies.rb:293:in `require'
from /home/ubuntu/.rvm/gems/ruby-2.4.0/gems/spring-2.0.2/lib/spring/application.rb:102:in `preload'
from /home/ubuntu/.rvm/gems/ruby-2.4.0/gems/spring-2.0.2/lib/spring/application.rb:153:in `serve'
from /home/ubuntu/.rvm/gems/ruby-2.4.0/gems/spring-2.0.2/lib/spring/application.rb:141:in `block in run'
from /home/ubuntu/.rvm/gems/ruby-2.4.0/gems/spring-2.0.2/lib/spring/application.rb:135:in `loop'
from /home/ubuntu/.rvm/gems/ruby-2.4.0/gems/spring-2.0.2/lib/spring/application.rb:135:in `run'
from /home/ubuntu/.rvm/gems/ruby-2.4.0/gems/spring-2.0.2/lib/spring/application/boot.rb:19:in `<top (required)>'
from /home/ubuntu/.rvm/rubies/ruby-2.4.0/lib/ruby/site_ruby/2.4.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /home/ubuntu/.rvm/rubies/ruby-2.4.0/lib/ruby/site_ruby/2.4.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from -e:1:in `<main>'
My config/application.yml
file:
我的config / application.yml文件:
development:
orientdb_port: 2480
orientdb_server: <some-ip>
orientdb_root_username: <some-username>
orientdb_root_password: <some-password>
orientdb_database: <some-db-name>
My config/connect.yml
file that I use to provide details for OrientDB gem:
我的config / connect.yml文件用于提供OrientDB gem的详细信息:
:orientdb:
:server: ENV["orientdb_server"]
:port: ENV["orientdb_port"]
:logger: stdout
:database:
:development: ENV["orientdb_database"]
:production: ENV["orientdb_database"]
:test: ENV['orientdb_database']
:staging: ENV['orientdb_database']
:admin:
:user: ENV['orientdb_root_username']
:pass: ENV['orientdb_root_password']
I think this file is not loading correctly. What could be the issue here? I have even downgraded the bundler version, but still doesn't work.
我认为这个文件没有正确加载。这可能是什么问题?我甚至降级了捆绑版本,但仍然无法正常工作。
3 个解决方案
#1
0
Your config/connect.yml
file should look like this:
您的config / connect.yml文件应如下所示:
orientdb:
server: <%= ENV['orientdb_server'] %>
port: <%= ENV['orientdb_port'] %>
logger: stdout
database:
development: <%= ENV['orientdb_database'] %>
production: <%= ENV['orientdb_database'] %>
test: <%= ENV['orientdb_database'] %>
staging: <%= ENV['orientdb_database'] %>
admin:
user: <%= ENV['orientdb_root_username'] %>
pass: <%= ENV['orientdb_root_password'] %>
YML is not Ruby, so you must use the erb tags for Ruby statements to access environment variables. The same applies to config/application.yml
.
YML不是Ruby,因此必须使用Ruby语句的erb标记来访问环境变量。这同样适用于config / application.yml。
If you look at the error message carefully you'll see that the following line pretty much gives the reason why it's failing:
如果仔细查看错误消息,您会看到以下行几乎说明了它失败的原因:
/home/ubuntu/.rvm/rubies/ruby-2.4.0/lib/ruby/2.4.0/uri/rfc3986_parser.rb:67:in `split': bad URI(is not URI?): http://localhost:2480/connect/ENV['orientdb_database'] (URI::InvalidURIError)
Specifically, http://localhost:2480/connect/ENV['orientdb_database'] (URI::InvalidURIError)
indicates that you're passing the string ENV['orientdb_database']
to the connection instead of the actual environment variable.
具体来说,http:// localhost:2480 / connect / ENV ['orientdb_database'](URI :: InvalidURIError)表示您将字符串ENV ['orientdb_database']传递给连接而不是实际的环境变量。
#2
0
development:
orientdb_port: '2480'
orientdb_server: 'some-ip'
orientdb_root_username: 'some-username'
orientdb_root_password: 'some-password'
orientdb_database: 'some-db-name'
Note:
In the terminal run: figaro install
This will include you yml file in (.gitignore)
在终端运行:figaro install这将包括你(.gitignore)中的yml文件
#3
0
Assuming, you are using the latest version of active-orient (from github), look to the railties.rb-file in the lib directory.
假设您正在使用最新版本的active-orient(来自github),请查看lib目录中的railties.rb文件。
connect_file = Rails.root.join('config', 'connect.yml')
databaseyml = YAML.load_file( connect_file )[:orientdb][:database]
Thus: the yaml tags must be :orientdb: and :database:
因此:yaml标记必须是:orientdb:和:database:
You can easily debug your input adding a control-output into the railtie-file eg
您可以轻松调试输入,将控制输出添加到railtie文件中,例如
puts "DATABASEYML :#{databaseyml.inspect}"
If you set the database with an Environment-variable, just assign it to ActiveOrient.database
如果使用Environment-variable设置数据库,只需将其分配给ActiveOrient.database
ActiveOrient.database = ENV['orientdb_database']
Anything should work then.
什么应该工作呢。
#1
0
Your config/connect.yml
file should look like this:
您的config / connect.yml文件应如下所示:
orientdb:
server: <%= ENV['orientdb_server'] %>
port: <%= ENV['orientdb_port'] %>
logger: stdout
database:
development: <%= ENV['orientdb_database'] %>
production: <%= ENV['orientdb_database'] %>
test: <%= ENV['orientdb_database'] %>
staging: <%= ENV['orientdb_database'] %>
admin:
user: <%= ENV['orientdb_root_username'] %>
pass: <%= ENV['orientdb_root_password'] %>
YML is not Ruby, so you must use the erb tags for Ruby statements to access environment variables. The same applies to config/application.yml
.
YML不是Ruby,因此必须使用Ruby语句的erb标记来访问环境变量。这同样适用于config / application.yml。
If you look at the error message carefully you'll see that the following line pretty much gives the reason why it's failing:
如果仔细查看错误消息,您会看到以下行几乎说明了它失败的原因:
/home/ubuntu/.rvm/rubies/ruby-2.4.0/lib/ruby/2.4.0/uri/rfc3986_parser.rb:67:in `split': bad URI(is not URI?): http://localhost:2480/connect/ENV['orientdb_database'] (URI::InvalidURIError)
Specifically, http://localhost:2480/connect/ENV['orientdb_database'] (URI::InvalidURIError)
indicates that you're passing the string ENV['orientdb_database']
to the connection instead of the actual environment variable.
具体来说,http:// localhost:2480 / connect / ENV ['orientdb_database'](URI :: InvalidURIError)表示您将字符串ENV ['orientdb_database']传递给连接而不是实际的环境变量。
#2
0
development:
orientdb_port: '2480'
orientdb_server: 'some-ip'
orientdb_root_username: 'some-username'
orientdb_root_password: 'some-password'
orientdb_database: 'some-db-name'
Note:
In the terminal run: figaro install
This will include you yml file in (.gitignore)
在终端运行:figaro install这将包括你(.gitignore)中的yml文件
#3
0
Assuming, you are using the latest version of active-orient (from github), look to the railties.rb-file in the lib directory.
假设您正在使用最新版本的active-orient(来自github),请查看lib目录中的railties.rb文件。
connect_file = Rails.root.join('config', 'connect.yml')
databaseyml = YAML.load_file( connect_file )[:orientdb][:database]
Thus: the yaml tags must be :orientdb: and :database:
因此:yaml标记必须是:orientdb:和:database:
You can easily debug your input adding a control-output into the railtie-file eg
您可以轻松调试输入,将控制输出添加到railtie文件中,例如
puts "DATABASEYML :#{databaseyml.inspect}"
If you set the database with an Environment-variable, just assign it to ActiveOrient.database
如果使用Environment-variable设置数据库,只需将其分配给ActiveOrient.database
ActiveOrient.database = ENV['orientdb_database']
Anything should work then.
什么应该工作呢。