【问题标题】:heroku db:push Error: time zone displacement out of rangeheroku db:push 错误:时区位移超出范围
【发布时间】:2013-08-08 21:56:35
【问题描述】:

我发了heroku db:push

一开始还不错

Sending schema
Schema:        100% |==========================================| Time: 00:00:06
Sending indexes
schema_migrat: 100% |==========================================| Time: 00:00:01
Sending data
3 tables, 8 records
schema_migrat: 100% |==========================================| Time: 00:00:00
users:           0% |                                          | ETA:  --:--:--
Saving session to push_201204102202.dat..

这些是 push_201204102202.dat 文件的内容:

    {"klass":"Taps::Push","database_url":"sqlite://db/development.sqlite3","remote_url":"http://heroku:osui59a24am79x@taps19.heroku.com","session_uri":"/sessions/7436189125","stream_state":{},"completed_tables":["schema_migrations"],"table_filter":null,"local_tables_info":{"schema_migrations":2,"users":4,"microposts":2}}

然后麻烦开始了:

!!!捕获服务器异常 HTTP 代码:500 Taps 服务器错误:PGError:错误:时区位移超出范围:“2012-04-10 12:00:00.000000+5894467200” ["/app/.bundle/gems/ruby/1.9.1/gems/sequel3.20.0/lib/sequel/adapters/postgres.rb:175:in `async_exec'", "/app/.bundle/gems/ruby /1.9.1/gems/sequel-3.20.0/lib/seq uel/adapters/postgres.rb:175:in `block (2 levels) in execute'","/app/.bundle/gems/ruby/1.9.1/gems/sequel-.20.0/lib/sequel/database/ logging.rb:28:in`log_yield'","/app/.bundle/gems/ruby/1.9.1/gems/sequel-.20.0/lib/sequel/adapters/postgres.rb:175:in `block in执行'","/app/.bundle/gems/ruby/1.9.1/gems/sequel-.20.0/lib/sequel/adapters/postgres.rb:158:in`check_disconnect_errors'","/app/.bundle /gems/ruby/1.9.1/gems/sequel-3.20.0/lib/sequel/adapters/postgres.rb:175:in `execute'","/app/.bundle/gems/ruby/1.9.1/ gems/sequel-.20.0/lib/sequel/adapters/postgres.rb:240:in `block (2 levels) in execute'", "/app/.bundle/gems/ruby/1.9.1/gems/sequel- 3.20.0/lib/sequel/connection_pool/threaded.rb:71:in`hold'","/app/.bundle/gems/ruby/1.9.1/gems/sequel-3.20.0/lib/sequel/database /connecting.rb:226:in `同步'", "/app/.bundle/gems/ruby/1.9.1/gems/sequel-3.20.0/lib/sequel/adapters/postgres.rb:240:in `阻止执行'", "/app/.bundle/gems/ruby/1.9.1/gems/sequel-3.20.0/lib/sequel/adapters/postgres.rb:261:在 `check_database_errors'", "/app/.bundle/gems/ruby/1.9.1/gems/sequel-3.20.0/lib/sequel/adapters/postgres.r b:238:in `execute'", "/app/.bundle/gems/ruby/1.9.1/gems/sequel-3.20.0/lib/sequel/database/query.rb:71:in `execute_dui'" , "/app/.bundle/gems/ruby/1.9.1/gems/sequel-3.20.0/lib/sequel/dataset/actions.rb:552:in `execute_dui'", "/app/.bundle/gems /ruby/1.9.1/gems/sequel-3.20.0/lib/sequel/dataset/actions.rb:243:in `block (2 l evls) 在导入'", "/app/.bundle/gems/ruby/1.9.1/gems/sequel-3.20.0/lib/sequel/dataset/actions.rb:243:in `每个'", "/ app/.bundle/gems/ruby/1.9.1/gems/sequel-3.2 0.0/lib/sequel/dataset/actions.rb:243:in `block in import'", "/app/.bundle/gems/ruby/1.9.1/gems/sequel-3.20.0/lib/sequel/database /query.rb:223:in `_transaction' ", "/app/.bundle/gems/ruby/1.9.1/gems/sequel-3.20.0/lib/sequel/database/query.rb:209:in `block in transaction'", "/app/.捆绑包/gems/ruby/1.9.1/gems/sequel-3.20。 0/lib/sequel/connection_pool/threaded.rb:84:in `hold'", "/app/.bundle/gems/ruby/1.9.1/gems/sequel-3.20.0/lib/sequel/database/connecting .rb:226:in `同步'" , "/app/.bundle/gems/ruby/1.9.1/gems/sequel-3.20.0/lib/sequel/database/query.rb:207:in `事务'", "/app/.bundle/gems /ruby/1.9.1/gems/sequel-3.20.0/lib/sequ el/dataset/actions.rb:243:in `import'", "/app/lib/taps/data_stream.rb:315:in `import_rows'", "/app/lib/taps/data_stream.rb:158:在 `fetch_remote_in_server'", "/a pp/lib/taps/server.rb:114:in `block (3 levels) in '", "/app/lib/taps/utils.rb:161:in `call'", "/app/lib/taps /utils.rb:161:in `server_error_handlin g'", "/app/lib/taps/server.rb:112:in `block (2 levels) in '", "/app/lib/taps/db_session.rb:15:in `block in conn'" , "/app/.bundle/gems/ruby/1.9.1/g ems/sequel-3.20.0/lib/sequel/database/connecting.rb:76:in `connect'", "/app/.bundle/gems/ruby/1.9.1/gems/sequel-3.20.0/lib /sequel/core.rb:119:in `connect'", "/a pp/lib/taps/db_session.rb:14:in `conn'", "/app/lib/taps/server.rb:111:in `block in '", "/app/.bundle/gems/ruby/ 1.9.1/gems/sinatra-1.0/lib/sinatra/ base.rb:865:in `call'", "/app/.bundle/gems/ruby/1.9.1/gems/sinatra-1.0/lib/sinatra/base.rb:865:in `block in route'" , "/app/.bundle/gems/ruby/1.9.1/gems/sinatra- 1.0/lib/sinatra/base.rb:521:in `instance_eval'", "/app/.bundle/gems/ruby/1.9.1/gems/sinatra-1.0/lib/sinatra/base.rb:521:in `route_eval'", "/app/.bundle/gems/rub y/1.9.1/gems/sinatra-1.0/lib/sinatra/base.rb:500:in `block (2 levels) in route!'", "/app/.bundle/gems/ruby/1.9.1/ gems/sinatra-1.0/lib/sinatra/base.rb:497:in `ca tch'", "/app/.bundle/gems/ruby/1.9.1/gems/sinatra-1.0/lib/sinatra/base.rb:497:in `block in route!'", "/app/.bundle /gems/ruby/1.9.1/gems/sinatra-1.0/lib/sinatra/ base.rb:476:in `each'", "/app/.bundle/gems/ruby/1.9.1/gems/sinatra-1.0/lib/sinatra/base.rb:476:in `route!'", "/app/.bundle/gems/ruby/1.9.1/gems/sinatra-1.0/lib/ sinatra/base.rb:601:in `dispatch!'", "/app/.bundle/gems/ruby/1.9.1/gems/sinatra-1.0/lib/sinatra/base.rb:411:in `block in打电话!'", "/app/.bundle/gems/ruby/1.9.1/ gems/sinatra-1.0/lib/sinatra/base.rb:566:in `instance_eval'", "/app/.bundle/gems/ruby/1.9.1/gems/sinatra-1.0/lib/sinatra/base.rb :566:in `block in invoke'", "/ap p/.bundle/gems/ruby/1.9.1/gems/sinatra-1.0/lib/sinatra/base.rb:566:in `catch'", "/app/.bundle/gems/ruby/1.9.1/ gems/sinatra-1.0/lib/sinatra/base.rb:566:in `invok e'", "/app/.bundle/gems/ruby/1.9.1/gems/sinatra-1.0/lib/sinatra/base.rb:411:in `call!'", "/app/.bundle/gems /ruby/1.9.1/gems/sinatra-1.0/lib/sinatra/base.rb:399: 在`调用'中", "/app/.bundle/gems/ruby/1.9.1/gems/sinatra-1.0/lib/sinatra/base.rb:979:in `block in call'", "/app/.捆绑包/gems/ruby/1.9.1/gems/sinatra-1.0/lib/sinat ra/base.rb:1005:in `synchronize'", "/app/.bundle/gems/ruby/1.9.1/gems/sinatra-1.0/lib/sinatra/base.rb:979:in `call'" , "/home/heroku_rack/lib/static_assets.rb:9: 在 `call'", "/home/heroku_rack/lib/last_access.rb:15:in `call'", "/app/.bundle/gems/ruby/1.9.1/gems/rack-1.2.1/lib /rack/urlmap.rb:47:in `block in call'", "/app/ .bundle/gems/ruby/1.9.1/gems/rack-1.2.1/lib/rack/urlmap.rb:41:in `each'", "/app/.bundle/gems/ruby/1.9.1/ gems/rack-1.2.1/lib/rack/urlmap.rb:41:in `call'", "/home /heroku_rack/lib/date_header.rb:14:in `call'", "/app/.bundle/gems/ruby/1.9.1/gems/rack-1.2.1/lib/rack/builder.rb:77:在 `call'", "/app/.bundle/gems/ruby/1.9.1/ge ms/thin-1.2.7/lib/thin/connection.rb:76:in `block in pre_process'", "/app/.bundle/gems/ruby/1.9.1/gems/thin-1.2.7/lib /thin/connection.rb:74:in `catch'", "/app/. bundle/gems/ruby/1.9.1/gems/thin-1.2.7/lib/thin/connection.rb:74:in `pre_process'", "/app/.bundle/gems/ruby/1.9.1/gems /thin-1.2.7/lib/thin/connection.rb:57:in ` 进程'", "/app/.bundle/gems/ruby/1.9.1/gems/thin-1.2.7/lib/thin/connection.rb:42:in `receive_data'", "/app/.bundle/ gems/ruby/1.9.1/gems/eventmachine-0.12.10/l ib/eventmachine.rb:256:in `run_machine'", "/app/.bundle/gems/ruby/1.9.1/gems/eventmachine-0.12.10/lib/eventmachine.rb:256:in `run'" , "/app/.bundle/gems/ruby/1.9 .1/gems/thin-1.2.7/lib/thin/backends/base.rb:57:in `start'", "/app/.bundle/gems/ruby/1.9.1/gems/thin-1.2. 7/lib/thin/server.rb:156:in `start'", "/app/.bundle/gem s/ruby/1.9.1/gems/thin-1.2.7/lib/thin/controllers/controller.rb:80:in `start'", "/app/.bundle/gems/ruby/1.9.1/gems /thin-1.2.7/lib/thin/runner.rb:177:in `run_com mand'", "/app/.bundle/gems/ruby/1.9.1/gems/thin-1.2.7/lib/thin/runner.rb:143:in `run!'", "/app/.bundle /gems/ruby/1.9.1/gems/thin-1.2.7/bin/thin:6:in `'", "/app/.bundle/gems/ruby/1.9.1/bin/thin:19:in `load'", "/app/.bundle/gems/ruby/1.9.1/bin/thin:19:in `'"]

【问题讨论】:

  • 错误显示:2012-04-10 12:00:00.000000+5894467200;无法将 +5894467200 解析为与 UTC 的有效时区偏移量,并且消息说明了这一点。因此,您将不得不追查到底是如何获得这样一个价值的。
  • 查看这个 SO 问题 ...stackoverflow.com/questions/8151571/…(他们有一个可行的解决方案,但不确定它是否适用于您)。

标签: ruby-on-rails heroku timezone


【解决方案1】:

这是一个 ruby​​ 1.9.3 错误。您应该使用 1.9.2 和 db:push 才能工作。如果你安装了 rvm,你可以这样做:

rvm 使用 ruby​​-1.9.2-p318 heroku 数据库:推送

确保您使用正确的 1.9.2 版本,我以 p318 为例,因为我已经安装了它。要使用 rvm 查看已安装的 ruby​​ 版本,请使用rvm list。如果您没有安装 1.9.2,请使用 rvm install ruby-1.9.2

【讨论】:

  • 我不知何故需要指定 ruby​​ 的路径(即使我使用“rvm use ruby​​-1.9.2-...”)。 $ ~/.rvm/bin/ruby-1.9.2-p320 /usr/bin/heroku db:push
  • 这可能是因为有 Heroku gem 和 Heroku Toolbelt。我认为它们都提供了 heroku 命令。据我所知,gem 已被弃用,只应使用 Heroku Toolbelt。这只是一个疯狂的猜测。
【解决方案2】:

使用带有 Ruby 1.9.2 的 gemset,安装 taps 和 sqlite3,就可以了。

sudo gem install heroku --no-ri --no-rdoc

sudo gem install taps --no-ri --no-rdoc

sudo gem install sqlite3 --no-ri --no-rdoc

【讨论】:

  • 这很有用,结合上面的答案。切换到 1.9.2,然后安装 gem(不是 sudo cos 它的 rvm)所有三个 gem。赢了。
【解决方案3】:

终于在 Dosha 的回答 here 的帮助下完成了这项工作。

确保您的 ruby​​ 版本与 Heroku 上运行的版本相匹配。似乎 1.9.2 是这些迁移的最稳定版本。

将您的 gemfile 更改为具有以下内容(假设您使用的是 SQLite):

group :development do
 gem 'taps', :require => false
 gem 'sqlite3'
end

这可能仍然无法解决您的问题,因为您的 heroku db:push 命令使用的是 Heroku 工具栏,而不是旧的、现已弃用的 heroku gem。不幸的是,我们实际上想要较旧的 gem,但是 heroku 正在调用 Heroku 工具栏。为了解决这个问题,您需要在您的 ruby​​ 1.9.2 版本上安装 heroku gem,然后通过其特定的文件路径访问它。

所以,接下来的步骤展示了如何让它发挥作用:

在控制台中运行以下命令:

rvm install ruby-1.9.2-p320
rvm use ruby-1.9.2-p320
bundle install`
sudo gem install heroku --no-ri --no-rdoc

然后运行:

rake assets:clean
bundle exec rake assets:precompile

将您的更改提交到 Github。

然后在控制台中输入以下内容:

~/.rvm/gems/ruby-1.9.2-p320/gems/heroku-2.40.0/bin/heroku db:push (如果与此不同,请使用您自己的文件路径。)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-12-30
    • 2013-01-07
    • 2013-01-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-08-18
    相关资源
    最近更新 更多