【问题标题】:Rails App errors after pg gem updatepg gem更新后的Rails App错误
【发布时间】:2018-08-19 20:28:56
【问题描述】:

我将数据库的 pg gem 更新到 1.0.0 版本,现在遇到了问题。我正在尝试恢复到以前的版本,但仍然出现错误。还有其他人有同样的问题吗?

宝石文件

# Use postgresql as the database for Active Record
gem 'pg', '~> 0.21.0'

运行rake db:migrate时出错

dyld: lazy symbol binding failed: Symbol not found: _rb_fd_init
  Referenced from: /Users/topher/.rvm/gems/ruby-2.5.0/gems/pg-0.21.0/lib/pg_ext.bundle
  Expected in: flat namespace

我运行rails s时没有错误

当我将 Gemfile 更改为 pg gem 的最新版本时,我收到以下错误:

宝石文件

# Use postgresql as the database for Active Record
gem 'pg', '~> 1.0.0'

运行rake db:migrate时出错

rake aborted!
Gem::LoadError: Specified 'postgresql' for database adapter, 
     but the gem is not loaded. Add `gem 'pg'` to your Gemfile 
     (and ensure its version is at the minimum required by 
     ActiveRecord).

运行rails s时出错

Specified 'postgresql' for database adapter, but the gem is not 
    loaded. Add `gem 'pg'` to your Gemfile (and ensure its version is 
    at the minimum required by ActiveRecord). (Gem::LoadError)

还有其他人遇到这个问题并有解决办法吗?

【问题讨论】:

  • 我当然是在更改 Gemfile 后运行 bundle install
  • 你在 OS X 上吗?如果是,是哪个版本?我问这个是因为,也许,您可以通过使用 xcode-select --install 更新/选择正确的 XCode 来解决它
  • 我在 OS X. 10.13.3 上。 XCode 是版本 9.2 (9C40b)
  • Gemfile 中更改版本后尝试bundle update pg。打赌你有旧版本Gemfile.lock
  • @MartinZinovsky, bundle update pg 带来了这个结果:Bundler attempted to update pg but its version stayed the same。此外,Gemfile.lock 确实显示了pg (~> 1.0.0)

标签: ruby-on-rails ruby postgresql pg


【解决方案1】:

在进一步研究了这个问题并使用了@MartinZinovsky 在评论中所说的内容之后,我想知道这是否不是 pg gem 的问题,而是另一个 gem 没有更新,特别是 ActiveRecord。这是错误中让我思考的部分,因为它出现在两个错误中:

ensure its version is at the minimum required by ActiveRecord

因此,我没有按照 Martin 的建议执行 bundle update pg,而是执行了 bundle update 以检查并更新所有具有可用更新的 gem。执行此操作时,它实际上确实将所有“动作”和“活动”gem 以及“activerecord”gem 更新到了较新的版本。这似乎解决了问题。现在rake db:migrate 有效,rails s 也有效。这是我运行bundle update 后的输出,以防其他人遇到此问题,而不仅仅是 ActiveRecord 需要更新。也许您可以使用此列表查看我的其他更新,以找出它不适合您的原因:

运行后bundle update

$ bundle update
The dependency tzinfo-data (>= 0) will be unused by any of the platforms Bundler is installing for. Bundler is installing for ruby but the dependency is only for x86-mingw32, x86-mswin32, x64-mingw32, java. To add those platforms to the bundle, run `bundle lock --add-platform x86-mingw32 x86-mswin32 x64-mingw32 java`.
Fetching gem metadata from https://rubygems.org/.............
Fetching gem metadata from https://rubygems.org/.
Resolving dependencies.....
Using rake 12.3.0
Using concurrent-ruby 1.0.5
Using i18n 0.9.5 (was 0.9.3)
Using minitest 5.11.3
Using thread_safe 0.3.6
Using tzinfo 1.2.5 (was 1.2.4)
Using activesupport 5.1.5 (was 5.1.4)
Using builder 3.2.3
Fetching erubi 1.7.1 (was 1.7.0)
Installing erubi 1.7.1 (was 1.7.0)
Using mini_portile2 2.3.0
Using nokogiri 1.8.2
Using rails-dom-testing 2.0.3
Using crass 1.0.3
Using loofah 2.2.0 (was 2.1.1)
Using rails-html-sanitizer 1.0.3
Using actionview 5.1.5 (was 5.1.4)
Using rack 2.0.4
Using rack-test 0.8.3 (was 0.8.2)
Using actionpack 5.1.5 (was 5.1.4)
Using nio4r 2.2.0
Using websocket-extensions 0.1.3
Using websocket-driver 0.6.5
Using actioncable 5.1.5 (was 5.1.4)
Using globalid 0.4.1
Using activejob 5.1.5 (was 5.1.4)
Using mini_mime 1.0.0
Using mail 2.7.0
Using actionmailer 5.1.5 (was 5.1.4)
Using activemodel 5.1.5 (was 5.1.4)
Using arel 8.0.0
Using activerecord 5.1.5 (was 5.1.4)
Using bundler 1.16.1
Using method_source 0.9.0
Using thor 0.20.0
Using railties 5.1.5 (was 5.1.4)
Using sprockets 3.7.1
Using sprockets-rails 3.2.1
Using rails 5.1.5 (was 5.1.4)
Using actionview-encoded_mail_to 1.0.9
Using public_suffix 3.0.2 (was 3.0.1)
Using addressable 2.5.2
Using execjs 2.7.0
Fetching autoprefixer-rails 8.1.0.1 (was 7.2.5)
Installing autoprefixer-rails 8.1.0.1 (was 7.2.5)
Fetching aws-partitions 1.70.0 (was 1.61.0)
Installing aws-partitions 1.70.0 (was 1.61.0)
Using aws-sigv4 1.0.2
Using jmespath 1.3.1
Fetching aws-sdk-core 3.17.0 (was 3.15.0)
Installing aws-sdk-core 3.17.0 (was 3.15.0)
Using aws-sdk-kms 1.5.0
Fetching aws-sdk-s3 1.8.2 (was 1.8.0)
Installing aws-sdk-s3 1.8.2 (was 1.8.0)
Using bcrypt 3.1.11
Using bindex 0.5.0
Using popper_js 1.12.9
Using rb-fsevent 0.10.3 (was 0.10.2)
Using ffi 1.9.23 (was 1.9.18)
Using rb-inotify 0.9.10
Using sass-listen 4.0.0
Using sass 3.5.5
Using bootstrap 4.0.0
Using bootstrap-table-rails 1.11.1.1
Using uniform_notifier 1.11.0
Fetching bullet 5.7.4 (was 5.7.2)
Installing bullet 5.7.4 (was 5.7.2)
Using byebug 10.0.0
Using xpath 3.0.0
Using capybara 2.18.0 (was 2.17.0)
Using mime-types-data 3.2016.0521
Using mime-types 3.1
Using carrierwave 1.2.2
Using carrierwave-aws 1.3.0
Fetching childprocess 0.9.0 (was 0.8.0)
Installing childprocess 0.9.0 (was 0.8.0)
Using coffee-script-source 1.12.2
Using coffee-script 2.4.1
Using coffee-rails 4.2.2
Using orm_adapter 0.5.0
Using responders 2.4.0
Using warden 1.2.7
Using devise 4.4.1
Using unf_ext 0.0.7.5
Using unf 0.1.4
Using domain_name 0.5.20170404
Using dotenv 2.2.1
Using dotenv-rails 2.2.1
Using font-awesome-rails 4.7.0.3
Using http-cookie 1.0.3
Using multi_json 1.13.1
Using jbuilder 2.7.0
Using jquery-rails 4.3.1
Using jquery-ui-rails 6.0.1
Using json 2.1.0
Using ruby_dep 1.5.0
Using listen 3.1.5
Using mini_magick 4.8.0
Using netrc 0.11.0
Using pg 1.0.0
Fetching puma 3.11.3 (was 3.11.2)
Installing puma 3.11.3 (was 3.11.2) with native extensions
Fetching recaptcha 4.6.6 (was 4.6.5)
Installing recaptcha 4.6.6 (was 4.6.5)
Using redcarpet 2.3.0
Using rest-client 2.0.2
Using rubyzip 1.2.1
Using tilt 2.0.8
Using sass-rails 5.0.7
Using selenium-webdriver 3.10.0 (was 3.8.0)
Using spring 2.0.2
Using spring-watcher-listen 2.0.1
Using turbolinks-source 5.1.0
Using turbolinks 5.1.0
Fetching uglifier 4.1.7 (was 4.1.5)
Installing uglifier 4.1.7 (was 4.1.5)
Using web-console 3.5.1
Bundle updated!

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-01-13
    • 1970-01-01
    • 2016-05-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-08-18
    • 1970-01-01
    相关资源
    最近更新 更多