質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.48%
Ruby on Rails 6

Ruby on Rails 6は、オープンソースのWebアプリケーションフレームワークです。「同じことを繰り返さない」というRailsの基本理念のもと、他のフレームワークより少ないコードで簡単に開発できるよう設計されています。

MySQL

MySQL(マイエスキューエル)は、TCX DataKonsultAB社などが開発するRDBMS(リレーショナルデータベースの管理システム)です。世界で最も人気の高いシステムで、オープンソースで開発されています。MySQLデータベースサーバは、高速性と信頼性があり、Linux、UNIX、Windowsなどの複数のプラットフォームで動作することができます。

Ubuntu

Ubuntuは、Debian GNU/Linuxを基盤としたフリーのオペレーティングシステムです。

Q&A

解決済

1回答

2701閲覧

mysql2がインストールできない

senseIY

総合スコア281

Ruby on Rails 6

Ruby on Rails 6は、オープンソースのWebアプリケーションフレームワークです。「同じことを繰り返さない」というRailsの基本理念のもと、他のフレームワークより少ないコードで簡単に開発できるよう設計されています。

MySQL

MySQL(マイエスキューエル)は、TCX DataKonsultAB社などが開発するRDBMS(リレーショナルデータベースの管理システム)です。世界で最も人気の高いシステムで、オープンソースで開発されています。MySQLデータベースサーバは、高速性と信頼性があり、Linux、UNIX、Windowsなどの複数のプラットフォームで動作することができます。

Ubuntu

Ubuntuは、Debian GNU/Linuxを基盤としたフリーのオペレーティングシステムです。

0グッド

0クリップ

投稿2022/03/07 07:24

解決したいこと

mysql2がインストール出来ないのでインストールしたい

現在rails の環境構築をしているのですが、bundle installをすると以下のようなエラーが出来てきました。

~ Gem::Ext::BuildError: ERROR: Failed to build gem native extension. current directory: /home/senseiy/.rbenv/versions/3.0.3/lib/ruby/gems/3.0.0/gems/mysql2-0.5.3/ext/mysql2 /home/senseiy/.rbenv/versions/3.0.3/bin/ruby -I /home/senseiy/.rbenv/versions/3.0.3/lib/ruby/site_ruby/3.0.0 -r ./siteconf20220307-2102-ko1ye5.rb extconf.rb checking for rb_absint_size()... yes checking for rb_absint_singlebit_p()... yes checking for rb_wait_for_single_fd()... yes *** extconf.rb failed *** Could not create Makefile due to some reason, probably lack of necessary libraries and/or headers. Check the mkmf.log file for more details. You may need configuration options. Provided configuration options: --with-opt-dir --without-opt-dir --with-opt-include --without-opt-include=${opt-dir}/include ~ --with-mysqlclientlib --without-mysqlclientlib /home/senseiy/.rbenv/versions/3.0.3/lib/ruby/3.0.0/mkmf.rb:1050:in `block in find_library': undefined method `split' for nil:NilClass (NoMethodError) from /home/senseiy/.rbenv/versions/3.0.3/lib/ruby/3.0.0/mkmf.rb:1050:in `collect' from /home/senseiy/.rbenv/versions/3.0.3/lib/ruby/3.0.0/mkmf.rb:1050:in `find_library' from extconf.rb:87:in `<main>' To see why this extension failed to compile, please check the mkmf.log which can be found here: /home/senseiy/.rbenv/versions/3.0.3/lib/ruby/gems/3.0.0/extensions/x86_64-linux/3.0.0/mysql2-0.5.3/mkmf.log ~ Gem files will remain installed in /home/senseiy/.rbenv/versions/3.0.3/lib/ruby/gems/3.0.0/gems/mysql2-0.5.3 for inspection. Results logged to /home/senseiy/.rbenv/versions/3.0.3/lib/ruby/gems/3.0.0/extensions/x86_64-linux/3.0.0/mysql2-0.5.3/gem_make.out /home/senseiy/.rbenv/versions/3.0.3/lib/ruby/site_ruby/3.0.0/rubygems/ext/builder.rb:95:in `run' /home/senseiy/.rbenv/versions/3.0.3/lib/ruby/site_ruby/3.0.0/rubygems/ext/ext_conf_builder.rb:47:in `block in build' /home/senseiy/.rbenv/versions/3.0.3/lib/ruby/3.0.0/tempfile.rb:317:in `open' ~ /home/senseiy/.rbenv/versions/3.0.3/lib/ruby/gems/3.0.0/gems/bundler-2.2.33/lib/bundler/worker.rb:54:in `process_queue' /home/senseiy/.rbenv/versions/3.0.3/lib/ruby/gems/3.0.0/gems/bundler-2.2.33/lib/bundler/worker.rb:91:in `block (2 levels) in create_threads' An error occurred while installing mysql2 (0.5.3), and Bundler cannot continue. In Gemfile: mysql2 senseiy@senseIY:~/dictum/dictum$ less /home/senseiy/.rbenv/versions/3.0.3/lib/ruby/gems/3.0.0/extensions/x86_64-linux/3.0.0/mysql2-0.5.3/mkmf.log senseiy@senseIY:~/dictum/dictum$ less /home/senseiy/.rbenv/versions/3.0.3/lib/ruby/gems/3.0.0/extensions/x86_64-linux/3.0.0/mysql2-0.5.3/mkmf.log senseiy@senseIY:~/dictum/dictum$ bundle install Fetching gem metadata from https://rubygems.org/.......... Using rake 13.0.6 Using concurrent-ruby 1.1.9 ~ Using webpacker 4.3.0 Using sass-rails 6.0.0 Using carrierwave-audio 1.0.7 from git@github.com:tanakaworld/carrierwave-audio.git (at master@b0132d6) Using web-console 4.2.0 Gem::Ext::BuildError: ERROR: Failed to build gem native extension. current directory: /home/senseiy/.rbenv/versions/3.0.3/lib/ruby/gems/3.0.0/gems/mysql2-0.5.3/ext/mysql2 /home/senseiy/.rbenv/versions/3.0.3/bin/ruby -I /home/senseiy/.rbenv/versions/3.0.3/lib/ruby/site_ruby/3.0.0 -r ./siteconf20220307-2184-5t4wxf.rb extconf.rb checking for rb_absint_size()... yes checking for rb_absint_singlebit_p()... yes checking for rb_wait_for_single_fd()... yes *** extconf.rb failed *** Could not create Makefile due to some reason, probably lack of necessary libraries and/or headers. Check the mkmf.log file for more details. You may need configuration options. Provided configuration options: --with-opt-dir --without-opt-dir ~ --with-mysqlclientlib --without-mysqlclientlib /home/senseiy/.rbenv/versions/3.0.3/lib/ruby/3.0.0/mkmf.rb:1050:in `block in find_library': undefined method `split' for nil:NilClass (NoMethodError) from /home/senseiy/.rbenv/versions/3.0.3/lib/ruby/3.0.0/mkmf.rb:1050:in `collect' from /home/senseiy/.rbenv/versions/3.0.3/lib/ruby/3.0.0/mkmf.rb:1050:in `find_library' from extconf.rb:87:in `<main>' To see why this extension failed to compile, please check the mkmf.log which can be found here: /home/senseiy/.rbenv/versions/3.0.3/lib/ruby/gems/3.0.0/extensions/x86_64-linux/3.0.0/mysql2-0.5.3/mkmf.log extconf failed, exit code 1 Gem files will remain installed in /home/senseiy/.rbenv/versions/3.0.3/lib/ruby/gems/3.0.0/gems/mysql2-0.5.3 for inspection. Results logged to /home/senseiy/.rbenv/versions/3.0.3/lib/ruby/gems/3.0.0/extensions/x86_64-linux/3.0.0/mysql2-0.5.3/gem_make.out ~ s/3.0.0/gems/bundler-2.2.33/lib/bundler/worker.rb:54:in `process_queue' /home/senseiy/.rbenv/versions/3.0.3/lib/ruby/gems/3.0.0/gems/bundler-2.2.33/lib/bundler/worker.rb:91:in `block (2 levels) in create_threads' An error occurred while installing mysql2 (0.5.3), and Bundler cannot continue. In Gemfile: mysql2

エラー文に

Could not create Makefile due to some reason, probably lack of necessary libraries and/or headers. Check the mkmf.log file for more details. You may need configuration options. To see why this extension failed to compile, please check the mkmf.log which can be found here: /home/senseiy/.rbenv/versions/3.0.3/lib/ruby/gems/3.0.0/extensions/x86_64-linux/3.0.0/mysql2-0.5.3/mkmf.log extconf failed, exit code 1

と出てきたのでlessコマンドで中身を確認しました。

have_func: checking for rb_absint_size()... -------------------- yes "gcc -o conftest -I/home/senseiy/.rbenv/versions/3.0.3/include/ruby-3.0.0/x86_64-linux -I/home/senseiy/.rbenv/versions/3.0.3/include/ruby-3.0.0/ruby/backward -I/home/senseiy/.rbenv/versions/3.0.3/include/ruby-3.0.0 -I. -I/home/senseiy/.rbenv/versions/3.0.3/include -O3 -ggdb3 -Wall -Wextra -Wdeprecated-declarations -Wduplicated-cond -Wimplicit-function-declaration -Wimplicit-int -Wmisleading-indentation -Wpointer-arith -Wwrite-strings -Wimplicit-fallthrough=0 -Wmissing-noreturn -Wno-cast-function-type -Wno-constant-logical-operand -Wno-long-long -Wno-missing-field-initializers -Wno-overlength-strings -Wno-packed-bitfield-compat -Wno-parentheses-equality -Wno-self-assign -Wno-tautological-compare -Wno-unused-parameter -Wno-unused-value -Wsuggest-attribute=format -Wsuggest-attribute=noreturn -Wunused-variable -fPIC conftest.c -L. -L/home/senseiy/.rbenv/versions/3.0.3/lib -Wl,-rpath,/home/senseiy/.rbenv/versions/3.0.3/lib -L. -L/home/senseiy/.rbenv/versions/3.0.3/lib -fstack-protector-strong -rdynamic -Wl,-export-dynamic -Wl,-rpath,/home/senseiy/.rbenv/versions/3.0.3/lib -L/home/senseiy/.rbenv/versions/3.0.3/lib -lruby -lm -lc" checked program was: /* begin */ 1: #include "ruby.h" 2: 3: int main(int argc, char **argv) 4: { 5: return !!argv[argc]; 6: } /* end */ "gcc -o conftest -I/home/senseiy/.rbenv/versions/3.0.3/include/ruby-3.0.0/x86_64-linux -I/home/senseiy/.rbenv/versions/3.0.3/include/ruby-3.0.0/ruby/backward -I/home/senseiy/.rbenv/versions/3.0.3/include/ruby-3.0.0 -I. -I/home/senseiy/.rbenv/versions/3.0.3/include -O3 -ggdb3 -Wall -Wextra -Wdeprecated-declarations -Wduplicated-cond -Wimplicit-function-declaration -Wimplicit-int -Wmisleading-indentation -Wpointer-arith -Wwrite-strings -Wimplicit-fallthrough=0 -Wmissing-noreturn -Wno-cast-function-type -Wno-constant-logical-operand -Wno-long-long -Wno-missing-field-initializers -Wno-overlength-strings -Wno-packed-bitfield-compat -Wno-parentheses-equality -Wno-self-assign -Wno-tautological-compare -Wno-unused-parameter -Wno-unused-value -Wsuggest-attribute=format -Wsuggest-attribute=noreturn -Wunused-variable -fPIC conftest.c -L. -L/home/senseiy/.rbenv/versions/3.0.3/lib -Wl,-rpath,/home/senseiy/.rbenv/versions/3.0.3/lib -L. -L/home/senseiy/.rbenv/versions/3.0.3/lib -fstack-protector-strong -rdynamic -Wl,-export-dynamic -Wl,-rpath,/home/senseiy/.rbenv/versions/3.0.3/lib -L/home/senseiy/.rbenv/versions/3.0.3/lib -lruby -lm -lc" checked program was: /* begin */ 1: #include "ruby.h" 2: 3: /*top*/ 4: extern int t(void); 5: int main(int argc, char **argv) 6: { 7: if (argc > 1000000) { 8: int (* volatile tp)(void)=(int (*)(void))&t; 9: printf("%d", (*tp)()); 10: } 11: 12: return !!argv[argc]; 13: } 14: int t(void) { void ((*volatile p)()); p = (void ((*)()))rb_absint_size; return !p; } /* end */ -------------------- have_func: checking for rb_absint_singlebit_p()... -------------------- yes

ですが、このファイルを見ても何をすればいいか分かりません。

https://teratail.com/questions/314208

この方と同じエラーだと思います。この方の場合はログをみて解決出来たようですが、どこにインストールすべきファイルが書いてあるのか分かりません。何かしらアドバイスがあればよろしくお願いいたします。

その他

・wsl2のubuntuを使っています
・rubyのバージョンは3.0.3です
・mysqlは 
https://takake-blog.com/wsl2-ubuntu2004-mysql/
この方の記事を参考にインストールしました。
・railsのバージョンを確認しても、Could not find mysql2-0.5.3 in any of the sources
Run bundle install to install missing gems.と出てきます。ですが、bundle installは失敗してしまいます。

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

guest

回答1

0

自己解決

yarn install --check-files
上記のコマンドを実行したところ解決いたしました。

投稿2022/03/07 08:37

senseIY

総合スコア281

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.48%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問