gpt4 book ai didi

ruby-on-rails - 您的 Gemfile 不止一次列出了 gem。可能会导致错误

转载 作者:数据小太阳 更新时间:2023-10-29 07:28:43 24 4
gpt4 key购买 nike

我目前在运行 bundle install 时收到以下消息

Your Gemfile lists the gem sqlite3 (= 1.3.5) more than once.
You should probably keep only one of them.
While it's not a problem now, it could cause errors if you change the version of just one of them later.

Your Gemfile lists the gem rspec-rails (= 2.10.0) more than once.
You should probably keep only one of them.
While it's not a problem now, it could cause errors if you change the version of just one of them later.

Your Gemfile lists the gem rspec-rails (= 2.10.0) more than once.
You should probably keep only one of them.
While it's not a problem now, it could cause errors if you change the version of just one of them later.

Your Gemfile lists the gem pg (= 0.12.2) more than once.
You should probably keep only one of them.
While it's not a problem now, it could cause errors if you change the version of just one of them later.

我在 Heroku 中使用 Postgresql,我相信我在开发和测试中都使用了 Postgresql。我最近从 sqlite 迁移/切换到 postgresql。

我还需要 :development 或 :development, :test 中的 sqlite3 gem 吗?

最后,:development 和 :development, :test 之间有区别吗?

数据库.yml

development:
adapter: postgresql
encoding: unicode
database: xxxxxx_development
pool: 5
username: xxxxxx
password:

test:
adapter: postgresql
encoding: unicode
database: xxxxxx_development
pool: 5
username: xxxxxx
password:

gem 文件

gem 'rails', '3.2.11'
gem "bootstrap-sass"
gem 'will_paginate'
gem 'bootstrap-will_paginate', '0.0.6'

gem 'pg', '0.12.2'
gem 'pg_search'

group :development, :test do
gem 'sqlite3', '1.3.5'
gem 'rspec-rails', '2.10.0'
gem 'guard-rspec', '0.5.5'
end

group :development do
gem 'sqlite3', '1.3.5'
gem 'rspec-rails', '2.10.0'
end

# Test gems on Macintosh OS X
group :test do
gem 'rspec-rails', '2.10.0'
end

group :production do
gem 'pg', '0.12.2'
gem 'rack-google_analytics'
end

最佳答案

您在这里重复将 sqlite 放入开发组:

group :development, :test do
gem 'sqlite3', '1.3.5'
gem 'rspec-rails', '2.10.0'
gem 'guard-rspec', '0.5.5'
end

group :development do
gem 'sqlite3', '1.3.5'
gem 'rspec-rails', '2.10.0'
end

您可以删除此处列出的第二个开发组,因为它不会添加任何内容 - 您已经在第一个语句中将它们置于开发和测试中。类似地,将 pg 放在任何组之外,它在所有组中都可用,因此将它添加到生产中是一个重复列表。

您的 gemfile 的重写可能是:

gem 'rails', '3.2.11'
gem "bootstrap-sass"
gem 'will_paginate'
gem 'bootstrap-will_paginate', '0.0.6'

# gem 'pg', '0.12.2'
gem 'pg_search'

group :development, :test do
gem 'sqlite3', '1.3.5'
gem 'rspec-rails', '2.10.0'
end

group :test do
gem 'guard-rspec', '0.5.5'
end

group :production do
gem 'pg', '0.12.2'
gem 'rack-google_analytics'
end

此外,来自一位感到痛苦的人的一个友好提示:尝试在开发中使用与生产相同的数据库。我知道一开始在本地设置 postgres 可能会很棘手,但一旦它在那里,它就非常可靠并且非常易于使用。由于 PG 和 SQLite 实现之间的差异(例如,在字段 iirc 中搜索文本),您将面临更少的错误风险。

没有sqlite:

gem 'rails', '3.2.11'
gem "bootstrap-sass"
gem 'will_paginate'
gem 'bootstrap-will_paginate', '0.0.6'

gem 'pg', '0.12.2'
gem 'pg_search'

group :development, :test do
gem 'rspec-rails', '2.10.0'
end

group :test do
gem 'guard-rspec', '0.5.5'
end

group :production do
gem 'rack-google_analytics'
end

关于ruby-on-rails - 您的 Gemfile 不止一次列出了 gem。可能会导致错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21621604/

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