加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

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

发布时间:2020-12-17 03:06:32 所属栏目:百科 来源:网络整理
导读:我正在运行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 th
我正在运行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 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.

我是否还需要sqlite3 gems:development或in:development,:test?

最后,开发与发展是否有区别? :开发,:测试?

database.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:

的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'
  gem 'guard-rspec','0.5.5'
end

group :development do
  gem 'sqlite3','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,'2.10.0'
end

你可以在这里删除你的第二个开发组列表,因为它没有添加任何东西 – 你已经在第一个语句中将它们放入开发和测试中.类似地,通过将??pg放在任何组之外,它可以在所有组中使用,因此将其添加到生产中是一个重复的列表.

重写你的gemfile可能是:

gem 'rails','0.0.6'

# gem 'pg','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

另外,一个感受到痛苦的人的一个友好提示:尝试在开发中使用相同的db作为生产.我知道最初在本地设置postgres可能会很棘手,但是一旦它在那里它就会坚如磐石并且非常容易使用.由于PG和SQLite实现之间的差异(例如,在字段iirc中搜索文本),您将面临更少的错误风险.

没有sqlite:

gem 'rails',:test do
  gem 'rspec-rails','0.5.5'
end

group :production do
  gem 'rack-google_analytics'
end

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读