【问题标题】:App stopped working after switching to Postgres切换到 Postgres 后应用停止工作
【发布时间】:2015-03-15 09:02:03
【问题描述】:

我的 Sinatra 应用在使用 sqlite 进行本地安装时运行良好。迁移到 Heroku 后,我遇到了奇怪的错误,因此我也切换到本地应用程序中的 Postgres,并且收到以下错误:

dyld: lazy symbol binding failed: Symbol not found: _rb_thread_select
  Referenced from: /Users/Emanuele/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/extensions/x86_64-darwin-14/2.2.0-static/do_postgres-0.10.14/do_postgres/do_postgres.bundle
  Expected in: flat namespace

dyld: Symbol not found: _rb_thread_select
  Referenced from: /Users/Emanuele/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/extensions/x86_64-darwin-14/2.2.0-static/do_postgres-0.10.14/do_postgres/do_postgres.bundle
  Expected in: flat namespace

在 irb 中加载模型时也会发生同样的情况。

这是我的模型文件:

require 'data_mapper'
require 'dm-types'
require 'dm-validations'
require 'dm-postgres-adapter'
require 'bcrypt'

# Setup DataMapper with a database URL. Will use ENV['DATABASE_URL'] on Heroku.
DataMapper.setup(:default, 'postgres://localhost/myapp')

# Let's define the model
class User
  include DataMapper::Resource
  include BCrypt

  property :id, Serial, :key => true
  property :email, String, :length => 5..70, :unique => true, :required => true, :format => :email_address
  property :password, BCryptHash
  property :account_sid, String, :length => 34
  property :auth_token, String, :length => 32
  property :app_sid, String, :length => 34

  def authenticate(attempted_password)
    if self.password == attempted_password
      true
    else
      false
    end
  end

end

# Finalize the DataMapper model.
DataMapper.finalize

# Tell DataMapper to update the database according to the definitions above.
DataMapper.auto_upgrade!

当我切换回 sqlite3 时,应用程序再次开始工作。我无法找到错误。在线搜索没有任何结果。

有没有人知道发生了什么以及如何解决这个问题并在 Heroku 上发布我的应用程序?

如果您需要更多信息,请询问。

谢谢!

【问题讨论】:

  • 是的,我使用的是 Mac,但看起来问题出在 Ruby 2.2.0 上。切换回 2.1.5 解决了这个问题。去图吧。

标签: sqlite postgresql heroku sinatra datamapper


【解决方案1】:

看起来从 2.2.0 切换回 Ruby 2.1.5 解决了本地和 Heroku 上的问题。找出问题所在。

如果有更多经验的开发者想追查这个错误并需要我提供一些信息,请询问。

【讨论】:

    【解决方案2】:

    pg gem 的旧版本与 Ruby 2.2 不兼容;您需要更新到最新版本。请参阅my answer to a similar question 了解更多详情,包括更新说明。

    【讨论】:

    • 对不起,布伦特,但我已经更新了宝石。事实上,我再次尝试确认我是Using pg 0.18.1,但错误仍然存​​在。再次切换回 2.1.5。如果您有更多详细信息,请提供。我真的很想使用 2.2.0,因为我已经阅读了有关性能改进的信息。
    • 作为数据点,我也遇到了这个问题(我有 pg gem 0.14.0,并且新升级到 Ruby 2.2),并将 pg gem 更新到 0.18.1 为我解决了这个问题。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-03-17
    • 1970-01-01
    • 1970-01-01
    • 2017-09-25
    相关资源
    最近更新 更多