gpt4 book ai didi

ruby-on-rails - 部署 Rails 应用程序时出错。 'can' t 激活 pg (~>0.18), 已经被 pg 1.0 激活

转载 作者:行者123 更新时间:2023-12-04 03:36:55 31 4
gpt4 key购买 nike

我正在尝试关注 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。我尝试删除所有 gem 并仅重新安装 pg 0.18。我整晚都在研究这个,找不到任何答案。我基本上是全新的,所以请帮忙!谢谢!!

在 gem 列表中,它显示:pg (0.21.0, 0.18.0)

这是我的 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.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]

最佳答案

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

基本上,我必须更多地了解 git 的工作原理。

我遗漏的部分:- 将 Gemfile 更新为如下所示:gem “pg”, “<1.0”-删除gemfile.lock- 运行捆绑安装-添加-A
-提交

^我一直听说提交,我认为这意味着你只需要对你正在做的事情做出 promise !大声笑,我想我只是错过了大多数有经验的程序员已经知道的常识。

关于ruby-on-rails - 部署 Rails 应用程序时出错。 'can' t 激活 pg (~>0.18), 已经被 pg 1.0 激活,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48444072/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com