【问题标题】:Rails app keeps trying to connect to "development .rb" fileRails 应用程序不断尝试连接到“开发 .rb”文件
【发布时间】:2013-05-16 23:52:23
【问题描述】:

所以这是一个令人困惑的问题。我不确定我哪里出错了,但我在某个地方做了,鉴于问题,它似乎应该是一个简单的修复。

第一次,我的 Rails 应用程序每次在终端中启动时都会崩溃。它崩溃是因为它试图连接到“development .rb”——单词的结尾和句号之间有一个空格。每次启动时,它都会创建一个名为“development.log”的文件。

我实际上没有“开发 .rb”文件,所以我不确定它为什么要尝试连接它。

所以在我的代码中的某个地方我必须告诉它只连接到 development.rb(没有空格)。关于如何做到这一点的任何想法?

19:44:43 web.1  | started with pid 28696
19:44:44 web.1  | I, [2013-05-16T19:44:44.514474 #28696]  INFO -- : Refreshing Gem list
19:44:47 web.1  | You did not specify how you would like Rails to report deprecation notices for your development  environment, please set config.active_support.deprecation to :log, :notify or :stderr at config/environments/development .rb
19:44:47 web.1  | /Users/myname/.rvm/gems/ruby-1.9.3-p374/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract/connection_specification.rb:47:in `resolve_hash_connection': database configuration does not specify adapter (ActiveRecord::AdapterNotSpecified)
19:44:47 web.1  |   from /Users/myname/.rvm/gems/ruby-1.9.3-p374/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract/connection_specification.rb:41:in `resolve_string_connection'
19:44:47 web.1  |   from /Users/myname/.rvm/gems/ruby-1.9.3-p374/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract/connection_specification.rb:25:in `spec'
19:44:47 web.1  |   from /Users/myname/.rvm/gems/ruby-1.9.3-p374/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract/connection_specification.rb:130:in `establish_connection'
19:44:47 web.1  |   from /Users/myname/.rvm/gems/ruby-1.9.3-p374/gems/activerecord-3.2.13/lib/active_record/railtie.rb:82:in `block (2 levels) in <class:Railtie>'
19:44:47 web.1  |   from /Users/myname/.rvm/gems/ruby-1.9.3-p374/gems/activesupport-3.2.13/lib/active_support/lazy_load_hooks.rb:36:in `instance_eval'
19:44:47 web.1  |   from /Users/myname/.rvm/gems/ruby-1.9.3-p374/gems/activesupport-3.2.13/lib/active_support/lazy_load_hooks.rb:36:in `execute_hook'
19:44:47 web.1  |   from /Users/myname/.rvm/gems/ruby-1.9.3-p374/gems/activesupport-3.2.13/lib/active_support/lazy_load_hooks.rb:26:in `block in on_load'
19:44:47 web.1  |   from /Users/myname/.rvm/gems/ruby-1.9.3-p374/gems/activesupport-3.2.13/lib/active_support/lazy_load_hooks.rb:25:in `each'
19:44:47 web.1  |   from /Users/myname/.rvm/gems/ruby-1.9.3-p374/gems/activesupport-3.2.13/lib/active_support/lazy_load_hooks.rb:25:in `on_load'
19:44:47 web.1  |   from /Users/myname/.rvm/gems/ruby-1.9.3-p374/gems/activerecord-3.2.13/lib/active_record/railtie.rb:74:in `block in <class:Railtie>'
19:44:47 web.1  |   from /Users/myname/.rvm/gems/ruby-1.9.3-p374/gems/railties-3.2.13/lib/rails/initializable.rb:30:in `instance_exec'
19:44:47 web.1  |   from /Users/myname/.rvm/gems/ruby-1.9.3-p374/gems/railties-3.2.13/lib/rails/initializable.rb:30:in `run'
19:44:47 web.1  |   from /Users/myname/.rvm/gems/ruby-1.9.3-p374/gems/railties-3.2.13/lib/rails/initializable.rb:55:in `block in run_initializers'
19:44:47 web.1  |   from /Users/myname/.rvm/gems/ruby-1.9.3-p374/gems/railties-3.2.13/lib/rails/initializable.rb:54:in `each'
19:44:47 web.1  |   from /Users/myname/.rvm/gems/ruby-1.9.3-p374/gems/railties-3.2.13/lib/rails/initializable.rb:54:in `run_initializers'
19:44:47 web.1  |   from /Users/myname/.rvm/gems/ruby-1.9.3-p374/gems/railties-3.2.13/lib/rails/application.rb:136:in `initialize!'
19:44:47 web.1  |   from /Users/myname/.rvm/gems/ruby-1.9.3-p374/gems/railties-3.2.13/lib/rails/railtie/configurable.rb:30:in `method_missing'
19:44:47 web.1  |   from /Users/myname/RailsApps/bptest/config/environment.rb:5:in `<top (required)>'
19:44:47 web.1  |   from config.ru:4:in `require'
19:44:47 web.1  |   from config.ru:4:in `block in <main>'
19:44:47 web.1  |   from /Users/myname/.rvm/gems/ruby-1.9.3-p374/gems/rack-1.4.5/lib/rack/builder.rb:51:in `instance_eval'
19:44:47 web.1  |   from /Users/myname/.rvm/gems/ruby-1.9.3-p374/gems/rack-1.4.5/lib/rack/builder.rb:51:in `initialize'
19:44:47 web.1  |   from config.ru:1:in `new'
19:44:47 web.1  |   from config.ru:1:in `<main>'
19:44:47 web.1  |   from /Users/myname/.rvm/gems/ruby-1.9.3-p374/gems/unicorn-4.6.2/lib/unicorn.rb:44:in `eval'
19:44:47 web.1  |   from /Users/myname/.rvm/gems/ruby-1.9.3-p374/gems/unicorn-4.6.2/lib/unicorn.rb:44:in `block in builder'
19:44:47 web.1  |   from /Users/myname/.rvm/gems/ruby-1.9.3-p374/gems/unicorn-4.6.2/lib/unicorn/http_server.rb:722:in `call'
19:44:47 web.1  |   from /Users/myname/.rvm/gems/ruby-1.9.3-p374/gems/unicorn-4.6.2/lib/unicorn/http_server.rb:722:in `build_app!'
19:44:47 web.1  |   from /Users/myname/.rvm/gems/ruby-1.9.3-p374/gems/unicorn-4.6.2/lib/unicorn/http_server.rb:140:in `start'
19:44:47 web.1  |   from /Users/myname/.rvm/gems/ruby-1.9.3-p374/gems/unicorn-4.6.2/bin/unicorn:126:in `<top (required)>'
19:44:47 web.1  |   from /Users/myname/.rvm/gems/ruby-1.9.3-p374/bin/unicorn:23:in `load'
19:44:47 web.1  |   from /Users/myname/.rvm/gems/ruby-1.9.3-p374/bin/unicorn:23:in `<main>'
19:44:47 web.1  |   from /Users/myname/.rvm/gems/ruby-1.9.3-p374/bin/ruby_noexec_wrapper:14:in `eval'
19:44:47 web.1  |   from /Users/myname/.rvm/gems/ruby-1.9.3-p374/bin/ruby_noexec_wrapper:14:in `<main>'
19:44:47 web.1  | exited with code 1
19:44:47 system | sending SIGTERM to all processes
SIGTERM received

【问题讨论】:

  • 你用什么命令来启动或者你的 Procfile 是什么样的?
  • 看起来问题来自 Rails 正在等待适配器的事实,可能在您的数据库文件中,例如例如 mysql 或 mysql2。
  • 请发布 config/database.yml
  • 您可能有一个RAILS_ENV 环境变量,其末尾有一个空格。在你的配置中寻找类似export RAILS_ENV="development " 的东西。也可以在 shell 提示符下尝试确认:echo $RAILS_ENV | od -c;在八进制转储中查找尾随空格。

标签: ruby-on-rails ruby-on-rails-3 development-environment


【解决方案1】:

谢谢大家的建议。就我而言,吉姆·斯图尔特完全正确。在我的应用程序的 .env 文件中,我在“RACK_ENV=development”之后直接有一个空格——我一定是最近打开了那个文件并按下了空格键。我只是删除了多余的空间,现在一切正常。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-02-16
    • 1970-01-01
    相关资源
    最近更新 更多