@mochi93kou (まるも)

Are you sure you want to delete the question?

Leaving a resolved question undeleted may help others!

【Rails/MySQL】gem mysql2をbundle install時に警告文が出る

解決したいこと

railsアプリでgem mysql2をbundle install際に警告文の解除。

発生している問題・エラー

Your Gemfile lists the gem mysql2 (>= 0) more than once.
You should probably keep only one of them.
Remove any duplicate entries and specify the gem only once.
While it's not a problem now, it could cause errors if you change the version of one of them later.

省略

Using kaminari-actionview 1.2.2
Using kaminari-activerecord 1.2.2
Using kaminari 1.2.2
Using rb-fsevent 0.11.1
Using rb-inotify 0.10.1
Using listen 3.7.1
Using mime-types-data 3.2022.0105
Using mime-types 3.4.1
Using mysql2 0.5.4

省略

Bundle complete! 31 Gemfile dependencies, 112 gems now installed.
Gems in the group 'production' were not installed.
Use `bundle info [gemname]` to see where a bundled gem is installed.

または、問題・エラーが起きている画像をここにドラッグアンドドロップ

Gemfile

group :development, :test do
  gem 'mysql2'
  gem 'byebug', platforms: [:mri, :mingw, :x64_mingw]
  gem 'rspec-rails'
  gem 'factory_bot_rails'
end

group :development do
  gem 'web-console', '>= 4.1.0'
  gem 'rack-mini-profiler', '~> 2.0'
  gem 'listen', '~> 3.3'
end

group :test do
  gem 'capybara'
  gem 'webdrivers'
  gem 'rails-controller-testing'
  gem 'rspec-request_describer' 
end

group :production do
  gem 'mysql2'
end

自分で試したこと

警告文を日本語訳してみましたが、解決方法がわかりませんでした。


Your Gemfile lists the gem mysql2 (>= 0) more than once.
You should probably keep only one of them.
Remove any duplicate entries and specify the gem only once.
While it's not a problem now, it could cause errors if you change the version of one of them later.

#日本語訳
Gemfile に gem mysql2 (>= 0) が複数回リストされています。
おそらく、そのうちの 1 つだけを保持する必要があります。
重複するエントリを削除し、gem を 1 回だけ指定します。
現在は問題ありませんが、後でバージョンを変更するとエラーが発生する可能性があります。

以上になります。

お力お貸しください。
よろしくお願いします。

0 likes

1Answer

自己解決しました。
警告文お通りGemfileにgem 'mysql2'が二つあるのが原因でした。
なのでグループを分けずに書いたところ警告文は表示されなくなりました。

0Like

Your answer might help someone💌