【问题标题】:Rails and Postgres aren't getting along after switching from Macports to Homebrew; PGError: ERROR: unrecognized time zone name: "UTC"从 Macports 切换到 Homebrew 后,Rails 和 Postgres 无法相处; PGError:错误:无法识别的时区名称:“UTC”
【发布时间】:2011-05-08 11:22:35
【问题描述】:

我将我在/opt/local(Macports 的东西所在的地方)中的所有东西都移到了~/.macports。这包括我的旧 postgres 数据库集群。

然后我使用 Homebrew 安装了 postgres 并运行了它告诉我的设置(在 /usr/local 中创建一个新的数据库集群)。

在我的项目中,我运行了rake db:drop:allrake db:create。这些人愉快地工作。

但是当我尝试rake db:migrate 时,postgres 和 rails 争吵并告诉我

rake aborted!
PGError: ERROR:  unrecognized time zone name: "UTC"
: SET time zone 'UTC'

不过,我不知道他们在说什么。我发现this article 有一个关于config.time_zone 的错误有点启发性,但还不足以找到我的方式。

谢谢!

【问题讨论】:

    标签: postgresql activerecord ruby-on-rails-3 macports homebrew


    【解决方案1】:

    我遇到了这个错误,只需要手动启动 postgres:

      pg_ctl -D /usr/local/var/postgres -l /usr/local/var/postgres/server.log start
    

    你也可以停止它:

    pg_ctl -D /usr/local/var/postgres stop -s -m fast
    

    【讨论】:

      【解决方案2】:

      经过多次头撞后,我通过运行解决了这个问题:

      env ARCHFLAGS="-arch x86_64" gem install pg

      【讨论】:

        【解决方案3】:

        我不完全确定我是如何修复它的,但是卸载 Postgres 并重新安装它(并非常仔细地遵循它提供的设置说明)让它工作了。

        【讨论】:

        • 您好,遇到了同样的问题。你所做的只是 brew uninstall postgres 然后 brew install postgres?一切正常吗?我试过了,但同样的问题出现了
        • 实际上问题出在我的范围内:范围:by_recent, where('created_at BETWEEN ? AND ?', 1.month.ago, Time.now).order('created_at desc') ...奇怪的是这个问题正在发生
        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2019-05-24
        相关资源
        最近更新 更多