ruby-on-rails - Heroku 在部署期间销毁 pg gem

标签 ruby-on-rails ruby heroku

我正在尝试部署一个基于 Ruby on Rails 的 Heroku 应用程序,但遇到了一些问题。虽然在过去的部署中不存在这些问题,但 Heroku 在部署后随机删除了 pg gem。这是我的 gem 文件:

source 'https://rubygems.org'

git_source(:github) do |repo_name|
  repo_name = "#{repo_name}/#{repo_name}" unless repo_name.include?("/")
  "https://github.com/#{repo_name}.git"
end

# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '~> 5.1.3'
# User rails12 factor for heroku's native ruby support tweaks
gem 'rails_12factor'
# Use wdm for Windows poll changes
gem 'wdm', '>= 0.1.0' if Gem.win_platform?
# Use Puma as the app server
gem 'puma', '~> 3.7'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 5.0'
# Use Bootstrap 3 for themeing and templating
gem 'bootstrap-sass'
# Use bootstrapformfor to allow forms to be auto-formatted as per bootstrap standards
gem 'bootstrap_form'
# Use JQuery code optimized for Bootstrap usage
gem 'jquery-rails'
# Use Dragonfly for image upload and handling
gem 'dragonfly', '~> 1.1.3'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# Use CoffeeScript for .coffee assets and views
gem 'coffee-rails', '~> 4.2'
# Turbolinks makes navigating your web application faster
gem 'turbolinks', '~> 5'
# Build JSON APIs with ease
gem 'jbuilder', '~> 2.5'
# Use Devise for account management and authorization
gem 'devise'
# Use Cancancan for permissions enforcement
gem 'cancancan'
# Use rolify for role assignment to user accounts
gem 'rolify'
# Windows does not include zoneinfo files so bundle the tzinfo-data gem
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
# Use ActiveModel has_secure_password
gem 'bcrypt', '~> 3.1.7'

group :development, :test do
  # Call 'byebug' anywhere in the code to stop execution and get a debugger console
  gem 'byebug', platforms: [:mri, :mingw, :x64_mingw]
  # Adds support for Capybara system testing and selenium driver
  gem 'capybara', '~> 2.13'
  gem 'selenium-webdriver'
end

group :development do
  # Access an IRB console on exception pages or by using <%= console %> anywhere in the code
  gem 'web-console', '>= 3.3.0'
  gem 'listen', '>= 3.0.5', '< 3.2'
  # Spring speeds up development by keeping your application running in the background
  gem 'spring'
  gem 'spring-watcher-listen', '~> 2.0.0'
  # Postgres for active record
  gem 'pg'
end

这是部署日志:

-----> Ruby app detected
-----> Compiling Ruby/Rails
-----> Using Ruby version: ruby-2.3.4
###### WARNING:
       Removing `Gemfile.lock` because it was generated on Windows.
       Bundler will do a full resolve so native gems are handled properly.
       This may result in unexpected gem versions being used in your app.
       In rare occasions Bundler may not be able to resolve your dependencies at all.
       https://devcenter.heroku.com/articles/bundler-windows-gemfile
-----> Installing dependencies using bundler 1.15.2
       Running: bundle install --without development:test --path vendor/bundle --binstubs vendor/bundle/bin -j4
       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 version metadata from https://rubygems.org/..
       Fetching dependency metadata from https://rubygems.org/.
       Resolving dependencies...
       Using rake 12.3.0
       Using concurrent-ruby 1.0.5
       Fetching minitest 5.11.1
       Using thread_safe 0.3.6
       Using builder 3.2.3
       Using erubi 1.7.0
       Using mini_portile2 2.3.0
       Using crass 1.0.3
       Using rack 2.0.3
       Fetching nio4r 2.2.0
       Using websocket-extensions 0.1.3
       Using mini_mime 1.0.0
       Using arel 8.0.0
       Fetching public_suffix 3.0.1
       Installing public_suffix 3.0.1
       Installing minitest 5.11.1
       Installing nio4r 2.2.0 with native extensions
       Using execjs 2.7.0
       Using bcrypt 3.1.11
       Using rb-fsevent 0.10.2
       Using ffi 1.9.18
       Using bootstrap_form 2.7.0
       Using bundler 1.15.2
       Using cancancan 2.1.2
       Using coffee-script-source 1.12.2
       Using method_source 0.9.0
       Using thor 0.20.0
       Using orm_adapter 0.5.0
       Fetching multi_json 1.13.1
       Using puma 3.11.0
       Using rails_serve_static_assets 0.0.5
       Using rails_stdout_logging 0.0.5
       Fetching rolify 5.2.0
       Installing multi_json 1.13.1
       Installing rolify 5.2.0
       Using tilt 2.0.8
       Fetching turbolinks-source 5.1.0
       Using i18n 0.9.1
       Using nokogiri 1.8.1
       Installing turbolinks-source 5.1.0
       Using tzinfo 1.2.4
       Using rack-test 0.8.2
       Using warden 1.2.7
       Using sprockets 3.7.1
       Using websocket-driver 0.6.5
       Using mail 2.7.0
       Fetching autoprefixer-rails 7.2.4
       Fetching uglifier 4.1.3
       Installing autoprefixer-rails 7.2.4
       Installing uglifier 4.1.3
       Using rb-inotify 0.9.10
       Using coffee-script 2.4.1
       Fetching addressable 2.5.2
       Using rails_12factor 0.0.3
       Using loofah 2.1.1
       Using activesupport 5.1.4
       Fetching turbolinks 5.1.0
       Installing turbolinks 5.1.0
       Installing addressable 2.5.2
       Using sass-listen 4.0.0
       Using rails-html-sanitizer 1.0.3
       Using rails-dom-testing 2.0.3
       Using globalid 0.4.1
       Using activemodel 5.1.4
       Using jbuilder 2.7.0
       Fetching dragonfly 1.1.4
       Fetching sass 3.5.5
       Installing dragonfly 1.1.4
       Installing sass 3.5.5
       Using activejob 5.1.4
       Using actionview 5.1.4
       Using activerecord 5.1.4
       Using actionpack 5.1.4
       Using actionmailer 5.1.4
       Using railties 5.1.4
       Using sprockets-rails 3.2.1
       Using coffee-rails 4.2.2
       Using responders 2.4.0
       Using jquery-rails 4.3.1
       Fetching devise 4.4.0
       Installing devise 4.4.0
       Using bootstrap-sass 3.3.7
       Using sass-rails 5.0.7
       Using actioncable 5.1.4
       Using rails 5.1.4
       Bundle complete! 25 Gemfile dependencies, 72 gems now installed.
       Gems in the groups development and test were not installed.
       Bundled gems are installed into ./vendor/bundle.
       Bundle completed (8.28s)
       Cleaning up the bundler cache.
       Removing rolify (5.1.0)
       Removing turbolinks (5.0.1)
       Removing autoprefixer-rails (7.1.6)
       Removing sass (3.5.3)
       Removing mime-types-data (3.2016.0521)
       Removing nio4r (2.1.0)
       Removing minitest (5.10.3)
       Removing devise (4.3.0)
       Removing mimemagic (0.3.2)
       Removing cocaine (0.5.8)
       Removing pg (0.21.0)
       Removing uglifier (3.2.0)
       Removing multi_json (1.12.2)
       Removing paperclip (5.0.0)
       Removing turbolinks-source (5.0.3)
       Removing mime-types (3.1)
       Removing climate_control (0.2.0)
       The latest bundler is 1.16.1, but you are currently running 1.15.2.
       To update, run `gem install bundler`
-----> Installing node-v6.11.1-linux-x64
-----> Detecting rake tasks
-----> Preparing app for Rails asset pipeline
       Running: rake assets:precompile
       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).
  ETCETCETC

请注意它是如何在初始捆绑后随机删除“pg”gem 的。有人能指出我正确的方向吗?

最佳答案

在您的 Gemfile 中设置您的 pg gem 以要求版本 0.2x:

gem 'pg', '~> 0.20'

发生的事情是您的系统错误地尝试使用更新的、不兼容的 pg 版本。 pg 1.0.0 于 2018 年 1 月 10 日发布,但目前不受 rails 支持。由于您没有指定要使用哪个版本的 pg,您的系统正在尝试使用新版本的 pg,删除旧版本,然后失败。

参见 this rails issue , 和 this rails issuethis fix (Revert to pg 0.21.0 as Rails does not support pg 1.0.0 yet)进行更多讨论。

关于ruby-on-rails - Heroku 在部署期间销毁 pg gem,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48219722/

相关文章:

ruby-on-rails - Rails - 将 query_reviewer 与 JSON Web 服务结合使用

ruby-on-rails - 使用 Dalli 缓存 Twitter 结果

ruby - rmagick 像素颜色值

ruby-on-rails - heroku mongohq 和 mongoid Mongo::ConnectionFailure

javascript - 我什么时候应该构建 'dist' 文件夹,什么时候不应该构建?

ruby-on-rails - Rails 请求覆盖参数

ruby - 在 RSpec 测试中模拟 ActiveRecord 关系行为

python - 是否有相当于 ruby​​ 的 "Pathname"模块的 python?

java - 将 JDA Discord 机器人上传到 heroku

ruby-on-rails - rails : Form Select From Array/List Instance Variable