代码之家  ›  专栏  ›  技术社区  ›  user938363

RAILS:ruby从2.2升级到2.3.3后未加载gem pg

  •  0
  • user938363  · 技术社区  · 6 年前

    我刚刚用Postgres9.5将我的Rails4.2.0应用程序的ruby从2.2.4升级到2.3.3。开始时 rails s ,pg适配器未加载:

    C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/activerecord-4.2.0/lib/active_record/connection_adapters/connection_specification.rb:177:in `rescue in spec': Specified 'postgresql' for data
    base 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)
    

    我做的 gem install pg gem list 显示已安装pg 1.1.3适配器。但是,在启动Rails服务器时仍然找不到pg适配器。

    档案:

    source 'http://rubygems.org'
    
    gem 'rails', '4.2.0'
    
    gem 'pg'
    
    gem 'sass-rails', '~> 5.0'
    gem 'uglifier', '>= 1.3.0'
    .........
    

    gem列表输出:

    *** LOCAL GEMS ***
    
    actionmailer (4.2.0)
    actionpack (4.2.0)
    actionview (4.2.0)
    activejob (4.2.0)
    activemodel (4.2.0)
    activerecord (4.2.0)
    activesupport (4.2.0)
    addressable (2.5.2)
    arel (6.0.4)
    bcrypt (3.1.12 x64-mingw32)
    bigdecimal (1.2.8)
    binding_of_caller (0.8.0)
    builder (3.2.3)
    bundler (1.17.1)
    byebug (10.0.2)
    capybara (3.12.0)
    coffee-rails (4.1.1)
    coffee-script (2.4.1)
    coffee-script-source (1.8.0)
    concurrent-ruby (1.1.3)
    crass (1.0.4)
    database_cleaner (1.7.0)
    debug_inspector (0.0.3)
    did_you_mean (1.0.0)
    diff-lcs (1.3)
    erubis (2.7.0)
    execjs (2.7.0)
    factory_girl (4.9.0)
    factory_girl_rails (4.9.0)
    ffi (1.9.25 x64-mingw32)
    globalid (0.4.1)
    gon (6.2.1)
    hike (1.2.3)
    i18n (0.9.5)
    io-console (0.4.5)
    jquery-rails (4.3.3)
    jquery-ui-rails (6.0.1)
    json (2.1.0, 1.8.6, 1.8.3)
    launchy (2.4.3)
    loofah (2.2.3)
    mail (2.7.1)
    mini_mime (1.0.1)
    mini_portile2 (2.3.0)
    minitest (5.11.3, 5.8.5)
    multi_json (1.13.1)
    net-telnet (0.1.1)
    nokogiri (1.8.5 x64-mingw32)
    pg (1.1.3 x64-mingw32)
    power_assert (0.2.6)
    protected_attributes (1.1.4)
    psych (2.1.0)
    public_suffix (3.0.3)
    rack (1.6.11)
    rack-test (0.6.3)
    rails (4.2.0)
    rails-deprecated_sanitizer (1.0.3)
    rails-dom-testing (1.0.9)
    rails-html-sanitizer (1.0.4)
    railties (4.2.0)
    rake (12.3.1, 10.4.2)
    rb-fsevent (0.10.3)
    rb-inotify (0.9.10)
    rdoc (4.3.0, 4.2.1)
    regexp_parser (1.3.0)
    request_store (1.4.1)
    responders (2.4.0)
    rspec-core (3.8.0)
    rspec-expectations (3.8.2)
    rspec-mocks (3.8.0)
    rspec-rails (3.8.1)
    rspec-support (3.8.0)
    sass (3.7.2)
    sass-listen (4.0.0)
    sass-rails (5.0.7)
    sdoc (0.4.2)
    simple_form (3.1.1)
    sprockets (2.12.3)
    sprockets-rails (2.3.3)
    sqlite3 (1.3.13 x64-mingw32)
    test-unit (3.1.5)
    thor (0.20.3)
    thread_safe (0.3.6)
    tilt (1.4.1)
    tzinfo (1.2.5)
    tzinfo-data (1.2018.7)
    uglifier (2.7.2)
    web-console (2.3.0)
    will_paginate (3.1.6)
    workflow (1.2.0)
    xpath (3.2.0)
    yajl-ruby (1.4.1)
    
    1 回复  |  直到 6 年前
        1
  •  2
  •   philip becker    6 年前

    https://github.com/rails/rails/issues/31673

    我认为有三种选择:

    • 升级到Rails 5.1.5或更新版本