直到最近db:create
工作得很好,但現在它與我下面發佈的堆棧跟蹤失敗。這是一個String can't be coerced into Fixnum
錯誤。爲什麼db:create停止工作?
這可能是什麼原因造成的?
我的密碼包含字母和數字,所以this不能成爲原因。
跟蹤只指向Rails代碼,而不是我自己的代碼,這使得調試挑戰。
我評論了我的模型中使用+
運算符的方法,但是這並沒有解決任何問題。
我database.yml
:
development:
adapter: postgresql
database: db/testivate_development
pool: 5
username: steven
password: <redacted>
host: localhost
test: &test
adapter: postgresql
database: db/testivate_test<%= ENV['TEST_ENV_NUMBER'] %>
pool: 5
username: steven
password: <redacted>
host: localhost
production:
adapter: postgresql
database: db/testivate_production
pool: 5
username: steven
password:
cucumber:
<<: *test
跟蹤:
$ rake db:create
WARNING: Nokogiri was built against LibXML version 2.7.8, but has dynamically loaded 2.9.0
String can't be coerced into Fixnum
/Users/steven/.rvm/gems/ruby-1.9.2-p320/gems/enumstats-0.0.3/lib/enumstats/enumerable.rb:3:in `+'
/Users/steven/.rvm/gems/ruby-1.9.2-p320/gems/enumstats-0.0.3/lib/enumstats/enumerable.rb:3:in `block in sum'
/Users/steven/.rvm/gems/ruby-1.9.2-p320/gems/enumstats-0.0.3/lib/enumstats/enumerable.rb:3:in `each'
/Users/steven/.rvm/gems/ruby-1.9.2-p320/gems/enumstats-0.0.3/lib/enumstats/enumerable.rb:3:in `inject'
/Users/steven/.rvm/gems/ruby-1.9.2-p320/gems/enumstats-0.0.3/lib/enumstats/enumerable.rb:3:in `sum'
/Users/steven/.rvm/gems/ruby-1.9.2-p320/gems/activerecord-3.2.11/lib/active_record/connection_adapters/postgresql_adapter.rb:749:in `create_database'
/Users/steven/.rvm/gems/ruby-1.9.2-p320/gems/activerecord-3.2.11/lib/active_record/railties/databases.rake:130:in `rescue in create_database'
/Users/steven/.rvm/gems/ruby-1.9.2-p320/gems/activerecord-3.2.11/lib/active_record/railties/databases.rake:74:in `create_database'
/Users/steven/.rvm/gems/ruby-1.9.2-p320/gems/activerecord-3.2.11/lib/active_record/railties/databases.rake:62:in `block (3 levels) in <top (required)>'
/Users/steven/.rvm/gems/ruby-1.9.2-p320/gems/activerecord-3.2.11/lib/active_record/railties/databases.rake:62:in `each'
/Users/steven/.rvm/gems/ruby-1.9.2-p320/gems/activerecord-3.2.11/lib/active_record/railties/databases.rake:62:in `block (2 levels) in <top (required)>'
/Users/steven/.rvm/gems/ruby-1.9.2-p320/gems/rake-10.1.0/lib/rake/task.rb:236:in `call'
/Users/steven/.rvm/gems/ruby-1.9.2-p320/gems/rake-10.1.0/lib/rake/task.rb:236:in `block in execute'
/Users/steven/.rvm/gems/ruby-1.9.2-p320/gems/rake-10.1.0/lib/rake/task.rb:231:in `each'
/Users/steven/.rvm/gems/ruby-1.9.2-p320/gems/rake-10.1.0/lib/rake/task.rb:231:in `execute'
/Users/steven/.rvm/gems/ruby-1.9.2-p320/gems/rake-10.1.0/lib/rake/task.rb:175:in `block in invoke_with_call_chain'
/Users/steven/.rvm/rubies/ruby-1.9.2-p320/lib/ruby/1.9.1/monitor.rb:201:in `mon_synchronize'
/Users/steven/.rvm/gems/ruby-1.9.2-p320/gems/rake-10.1.0/lib/rake/task.rb:168:in `invoke_with_call_chain'
/Users/steven/.rvm/gems/ruby-1.9.2-p320/gems/rake-10.1.0/lib/rake/task.rb:161:in `invoke'
/Users/steven/.rvm/gems/ruby-1.9.2-p320/gems/rake-10.1.0/lib/rake/application.rb:149:in `invoke_task'
/Users/steven/.rvm/gems/ruby-1.9.2-p320/gems/rake-10.1.0/lib/rake/application.rb:106:in `block (2 levels) in top_level'
/Users/steven/.rvm/gems/ruby-1.9.2-p320/gems/rake-10.1.0/lib/rake/application.rb:106:in `each'
/Users/steven/.rvm/gems/ruby-1.9.2-p320/gems/rake-10.1.0/lib/rake/application.rb:106:in `block in top_level'
/Users/steven/.rvm/gems/ruby-1.9.2-p320/gems/rake-10.1.0/lib/rake/application.rb:115:in `run_with_threads'
/Users/steven/.rvm/gems/ruby-1.9.2-p320/gems/rake-10.1.0/lib/rake/application.rb:100:in `top_level'
/Users/steven/.rvm/gems/ruby-1.9.2-p320/gems/rake-10.1.0/lib/rake/application.rb:78:in `block in run'
/Users/steven/.rvm/gems/ruby-1.9.2-p320/gems/rake-10.1.0/lib/rake/application.rb:165:in `standard_exception_handling'
/Users/steven/.rvm/gems/ruby-1.9.2-p320/gems/rake-10.1.0/lib/rake/application.rb:75:in `run'
/Users/steven/.rvm/gems/ruby-1.9.2-p320/gems/rake-10.1.0/bin/rake:33:in `<top (required)>'
/Users/steven/.rvm/gems/ruby-1.9.2-p320/bin/rake:19:in `load'
/Users/steven/.rvm/gems/ruby-1.9.2-p320/bin/rake:19:in `<main>'
/Users/steven/.rvm/gems/ruby-1.9.2-p320/bin/ruby_noexec_wrapper:14:in `eval'
/Users/steven/.rvm/gems/ruby-1.9.2-p320/bin/ruby_noexec_wrapper:14:in `<main>'
Couldn't create database for {"adapter"=>"postgresql", "database"=>"db/testivate_development", "pool"=>5, "username"=>"steven", "password"=>"<redacted>", "host"=>"localhost"}
String can't be coerced into Fixnum
/Users/steven/.rvm/gems/ruby-1.9.2-p320/gems/enumstats-0.0.3/lib/enumstats/enumerable.rb:3:in `+'
/Users/steven/.rvm/gems/ruby-1.9.2-p320/gems/enumstats-0.0.3/lib/enumstats/enumerable.rb:3:in `block in sum'
/Users/steven/.rvm/gems/ruby-1.9.2-p320/gems/enumstats-0.0.3/lib/enumstats/enumerable.rb:3:in `each'
/Users/steven/.rvm/gems/ruby-1.9.2-p320/gems/enumstats-0.0.3/lib/enumstats/enumerable.rb:3:in `inject'
/Users/steven/.rvm/gems/ruby-1.9.2-p320/gems/enumstats-0.0.3/lib/enumstats/enumerable.rb:3:in `sum'
/Users/steven/.rvm/gems/ruby-1.9.2-p320/gems/activerecord-3.2.11/lib/active_record/connection_adapters/postgresql_adapter.rb:749:in `create_database'
/Users/steven/.rvm/gems/ruby-1.9.2-p320/gems/activerecord-3.2.11/lib/active_record/railties/databases.rake:130:in `rescue in create_database'
/Users/steven/.rvm/gems/ruby-1.9.2-p320/gems/activerecord-3.2.11/lib/active_record/railties/databases.rake:74:in `create_database'
/Users/steven/.rvm/gems/ruby-1.9.2-p320/gems/activerecord-3.2.11/lib/active_record/railties/databases.rake:62:in `block (3 levels) in <top (required)>'
/Users/steven/.rvm/gems/ruby-1.9.2-p320/gems/activerecord-3.2.11/lib/active_record/railties/databases.rake:62:in `each'
/Users/steven/.rvm/gems/ruby-1.9.2-p320/gems/activerecord-3.2.11/lib/active_record/railties/databases.rake:62:in `block (2 levels) in <top (required)>'
/Users/steven/.rvm/gems/ruby-1.9.2-p320/gems/rake-10.1.0/lib/rake/task.rb:236:in `call'
/Users/steven/.rvm/gems/ruby-1.9.2-p320/gems/rake-10.1.0/lib/rake/task.rb:236:in `block in execute'
/Users/steven/.rvm/gems/ruby-1.9.2-p320/gems/rake-10.1.0/lib/rake/task.rb:231:in `each'
/Users/steven/.rvm/gems/ruby-1.9.2-p320/gems/rake-10.1.0/lib/rake/task.rb:231:in `execute'
/Users/steven/.rvm/gems/ruby-1.9.2-p320/gems/rake-10.1.0/lib/rake/task.rb:175:in `block in invoke_with_call_chain'
/Users/steven/.rvm/rubies/ruby-1.9.2-p320/lib/ruby/1.9.1/monitor.rb:201:in `mon_synchronize'
/Users/steven/.rvm/gems/ruby-1.9.2-p320/gems/rake-10.1.0/lib/rake/task.rb:168:in `invoke_with_call_chain'
/Users/steven/.rvm/gems/ruby-1.9.2-p320/gems/rake-10.1.0/lib/rake/task.rb:161:in `invoke'
/Users/steven/.rvm/gems/ruby-1.9.2-p320/gems/rake-10.1.0/lib/rake/application.rb:149:in `invoke_task'
/Users/steven/.rvm/gems/ruby-1.9.2-p320/gems/rake-10.1.0/lib/rake/application.rb:106:in `block (2 levels) in top_level'
/Users/steven/.rvm/gems/ruby-1.9.2-p320/gems/rake-10.1.0/lib/rake/application.rb:106:in `each'
/Users/steven/.rvm/gems/ruby-1.9.2-p320/gems/rake-10.1.0/lib/rake/application.rb:106:in `block in top_level'
/Users/steven/.rvm/gems/ruby-1.9.2-p320/gems/rake-10.1.0/lib/rake/application.rb:115:in `run_with_threads'
/Users/steven/.rvm/gems/ruby-1.9.2-p320/gems/rake-10.1.0/lib/rake/application.rb:100:in `top_level'
/Users/steven/.rvm/gems/ruby-1.9.2-p320/gems/rake-10.1.0/lib/rake/application.rb:78:in `block in run'
/Users/steven/.rvm/gems/ruby-1.9.2-p320/gems/rake-10.1.0/lib/rake/application.rb:165:in `standard_exception_handling'
/Users/steven/.rvm/gems/ruby-1.9.2-p320/gems/rake-10.1.0/lib/rake/application.rb:75:in `run'
/Users/steven/.rvm/gems/ruby-1.9.2-p320/gems/rake-10.1.0/bin/rake:33:in `<top (required)>'
/Users/steven/.rvm/gems/ruby-1.9.2-p320/bin/rake:19:in `load'
/Users/steven/.rvm/gems/ruby-1.9.2-p320/bin/rake:19:in `<main>'
/Users/steven/.rvm/gems/ruby-1.9.2-p320/bin/ruby_noexec_wrapper:14:in `eval'
/Users/steven/.rvm/gems/ruby-1.9.2-p320/bin/ruby_noexec_wrapper:14:in `<main>'
Couldn't create database for {"adapter"=>"postgresql", "database"=>"db/testivate_test", "pool"=>5, "username"=>"steven", "password"=>"<redacted>", "host"=>"localhost"}
UPDATE
我得到同樣的錯誤,甚至當我把所有的移民來自/db/migrations/
去的最簡單,最明確的database.yml
可能的:
development:
adapter: postgresql
database: db/testivate_development
username: "steven"
password: "<redacted>"
host: localhost
test:
adapter: postgresql
database: db/testivate_test
username: "steven"
password: "<redacted>"
host: localhost
您是否升級了運行此代碼的操作系統?這可能是由於Nokogiri標記的警告或可能需要重新編譯的另一個寶石的副作用。 –
謝謝格蘭特。我最近沒有升級操作系統,但我會重新編譯Nokogiri等。 –
Steven - 嘗試強制將密碼字符串用「」包圍起來,以便YAML解析器不會嘗試脅迫Fixnum。剛剛意識到你在另一個SO問題/答案中與此相關。無論如何,你有沒有試過? –