ruby-on-rails - 无法部署:Gem::LoadError:为数据库适配器指定 'postgresql',但未加载 gem

标签 ruby-on-rails heroku bundler pg

我最近遇到了这个错误。昨天还在工作。我确实pg gem !该 gem 不在一个组中。

C:\Users\Chloe\workspace\>git push heroku
Counting objects: 34, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (34/34), done.
Writing objects: 100% (34/34), 9.32 KiB | 1.17 MiB/s, done.
Total 34 (delta 28), reused 0 (delta 0)
remote: Compressing source files... done.
remote: Building source:
remote:
remote: -----> Ruby app detected
remote: -----> Compiling Ruby/Rails
remote: -----> Using Ruby version: ruby-2.3.1
remote: ###### WARNING:
remote:        Removing `Gemfile.lock` because it was generated on Windows.
remote:        Bundler will do a full resolve so native gems are handled properly.
remote:        This may result in unexpected gem versions being used in your app.
remote:        In rare occasions Bundler may not be able to resolve your dependencies at all.
remote:        https://devcenter.heroku.com/articles/bundler-windows-gemfile
remote:
remote: -----> Installing dependencies using bundler 1.15.2
remote:        Running: bundle install --without development:test --path vendor/bundle --binstubs vendor/bundle/bin -j4
remote:        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`.
remote:        Fetching gem metadata from https://rubygems.org/.........
remote:        Fetching version metadata from https://rubygems.org/..
remote:        Fetching dependency metadata from https://rubygems.org/.
remote:        Resolving dependencies...
remote:        Using rake 12.3.0
remote:        Using concurrent-ruby 1.0.5
remote:        Using minitest 5.11.1
remote:        Using thread_safe 0.3.6
remote:        Using builder 3.2.3
remote:        Using erubis 2.7.0
remote:        Using mini_portile2 2.3.0
remote:        Using crass 1.0.3
remote:        Using rack 2.0.3
remote:        Using nio4r 2.2.0
remote:        Using websocket-extensions 0.1.3
remote:        Using mini_mime 1.0.0
remote:        Using arel 7.1.4
remote:        Using public_suffix 3.0.1
remote:        Using aws_cf_signer 0.1.3
remote:        Using bcrypt 3.1.11
remote:        Using bundler 1.15.2
remote:        Using rubyzip 1.2.1
remote:        Using climate_control 0.2.0
remote:        Using unf_ext 0.0.7.4
remote:        Using mime-types-data 3.2016.0521
remote:        Using netrc 0.11.0
remote:        Using coffee-script-source 1.12.2
remote:        Using execjs 2.7.0
remote:        Using method_source 0.9.0
remote:        Using thor 0.20.0
remote:        Using orm_adapter 0.5.0
remote:        Using multipart-post 2.0.0
remote:        Using ffi 1.9.18
remote:        Using temple 0.8.0
remote:        Using tilt 2.0.8
remote:        Using sexp_processor 4.10.0
remote:        Using multi_json 1.13.0
remote:        Using mimemagic 0.3.2
remote:        Fetching pg 1.0.0
remote:        Using puma 3.11.0
remote:        Using rb-fsevent 0.10.2
remote:        Using turbolinks-source 5.1.0
remote:        Using i18n 0.9.1
remote:        Using tzinfo 1.2.4
remote:        Using nokogiri 1.8.1
remote:        Using websocket-driver 0.6.5
remote:        Using mail 2.7.0
remote:        Using addressable 2.5.2
remote:        Using city-state 0.0.13
remote:        Using rack-test 0.6.3
remote:        Using warden 1.2.7
remote:        Using sprockets 3.7.1
remote:        Using rack-proxy 0.6.3
remote:        Using unf 0.1.4
remote:        Using cocaine 0.5.8
remote:        Using coffee-script 2.4.1
remote:        Using uglifier 4.1.3
remote:        Using mime-types 3.1
remote:        Using faraday 0.13.1
remote:        Using rb-inotify 0.9.10
remote:        Using ruby_parser 3.10.1
remote:        Using haml 5.0.4
remote:        Using turbolinks 5.1.0
remote:        Using activesupport 5.0.6
remote:        Using loofah 2.1.1
remote:        Using domain_name 0.5.20170404
remote:        Using stripe 3.9.1
remote:        Using sass-listen 4.0.0
remote:        Using rails-dom-testing 2.0.3
remote:        Using globalid 0.4.1
remote:        Using activemodel 5.0.6
remote:        Using jbuilder 2.7.0
remote:        Using rails-html-sanitizer 1.0.3
remote:        Using html2haml 2.2.0
remote:        Using http-cookie 1.0.3
remote:        Using sass 3.5.5
remote:        Using activejob 5.0.6
remote:        Using activerecord 5.0.6
remote:        Using paperclip 5.1.0
remote:        Using actionview 5.0.6
remote:        Using rest-client 2.0.2
remote:        Using actionpack 5.0.6
remote:        Using cloudinary 1.8.2
remote:        Using actioncable 5.0.6
remote:        Using actionmailer 5.0.6
remote:        Using railties 5.0.6
remote:        Using sprockets-rails 3.2.1
remote:        Using paperclip-cloudinary 1.3.1
remote:        Using coffee-rails 4.2.2
remote:        Using responders 2.4.0
remote:        Using haml-rails 1.0.0
remote:        Using jquery-rails 4.3.1
remote:        Using rails 5.0.6
remote:        Using sass-rails 5.0.7
remote:        Using devise 4.4.0
remote:        Using nested_form_fields 0.8.2
remote:        Using rails-reverse-proxy 0.9.1
remote:        Using devise-i18n 1.5.0
remote:        Installing pg 1.0.0 with native extensions
remote:        Bundle complete! 27 Gemfile dependencies, 94 gems now installed.
remote:        Gems in the groups development and test were not installed.
remote:        Bundled gems are installed into ./vendor/bundle.
remote:        Bundle completed (9.80s)
remote:        Cleaning up the bundler cache.
remote:        Removing pg (0.21.0)
remote:        The latest bundler is 1.16.1, but you are currently running 1.15.2.
remote:        To update, run `gem install bundler`
remote: -----> Installing node-v6.11.1-linux-x64
remote: -----> Detecting rake tasks
remote: -----> Preparing app for Rails asset pipeline
remote:        Running: rake assets:precompile
remote:        rake aborted!
remote:        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).
remote:        /tmp/build_a9d764dc04e2c3ac37be31055ec0e201/vendor/bundle/ruby/2.3.0/gems/activerecord-5.0.6/lib/active_record/connection_adapters/connection_specification.rb:176:in `rescue in spec'
... stacktrace ...
remote:        Tasks: TOP => environment
remote:        (See full trace by running task with --trace)
remote:  !
remote:  !     Precompiling assets failed.
remote:  !
remote:  !     Push rejected, failed to compile Ruby app.
remote:
remote:  !     Push failed
remote: Verifying deploy...
remote:
remote: !       Push rejected to project-staging.
remote:
To https://git.heroku.com/project-staging.git
 ! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/project-staging.git'

最佳答案

我解决了这个问题

https://stackoverflow.com/a/44034083/148844

gem 'pg', '~> 0.21'

关于ruby-on-rails - 无法部署:Gem::LoadError:为数据库适配器指定 'postgresql',但未加载 gem,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48194117/

相关文章:

ruby-on-rails - 如何在带有 bundler 的项目中使用 rails 分支中的分支

ruby-on-rails - 如何使用回形针复制文件

ruby-on-rails - Heroku vs EngineYard:哪个更值得?

ruby-on-rails - heroku 未定义方法为空?将我的应用程序升级到 ruby​​ 2.0 时

ruby-on-rails - 测试环境无法加载gem

ruby-on-rails - 无法通过安装调试器

ruby-on-rails - 使用 devise rails 将 SignIn 和 SignUp 放在单个页面中

ruby-on-rails - 带有 json 的 Rails 日期

ruby-on-rails - CanCan之间的区别:read and [:index, :show]?

python - Heroku 数据库 : Insert operation