部署rails app时出错。 '不能激活已经由pg 1.0激活的pg(〜> 0.18)

时间:2018-01-25 13:31:05

标签: ruby-on-rails rubygems

我正在尝试关注Railsbridge Intallfest,并尝试将我的第一个rails应用程序部署到heroku。我不断收到以下错误消息:

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).

Caused by:
Gem::LoadError: can't activate pg (~> 0.18), already activated pg-
1.0.0. Make sure all dependencies are added to Gemfile.

我尝试编辑gem文件(见下文),我尝试删除gemfile.lock并再次运行bundle install。我尝试删除所有宝石,只重新安装pg 0.18。我整夜都在努力,无法找到答案。我基本上是全新的,所以请帮忙!谢谢!!

在宝石列表中,它显示了:pg(0.21.0,0.18.0)

这是我的宝石文件:

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.4'
# Use sqlite3 as the database for Active Record
group :development, :test do
gem 'sqlite3'
end

group :production do
gem 'pg', '~> 0.18'
end
# Use Puma as the app server
gem 'puma', '~> 3.7'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 5.0'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# See https://github.com/rails/execjs#readme for more supported 
runtimes
# gem 'therubyracer', platforms: :ruby

# Use CoffeeScript for .coffee assets and views
gem 'coffee-rails', '~> 4.2'
# Turbolinks makes navigating your web application faster. Read more: 
https://github.com/turbolinks/turbolinks
gem 'turbolinks', '~> 5'
# Build JSON APIs with ease. Read more: 
https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.5'
# Use Redis adapter to run Action Cable in production
# gem 'redis', '~> 3.0'
# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'

# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development

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. Read more: https://github.com/rails/spring
gem 'spring'
gem 'spring-watcher-listen', '~> 2.0.0'
end

# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]

1 个答案:

答案 0 :(得分:0)

我实际上是通过odin项目gitter chat的一些帮助找到了解决方案。

基本上,我必须更多地了解git是如何工作的。

我遗失的那篇文章: -update Gemfile看起来像这样:gem“pg”,“&lt; 1.0” -delete gemfile.lock - 运行捆绑安装 -add -A
-commit

^我一直听说提交,我认为这意味着你只需要承诺你正在做的事情!大声笑我觉得我只是错过了大多数有经验的程序员已经掌握的知识。