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

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

新規登録して質問してみよう
ただいま回答率
85.50%
MySQL

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

Ruby on Rails

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

Q&A

解決済

1回答

3318閲覧

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

NN77

総合スコア59

MySQL

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

Ruby on Rails

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

0グッド

0クリップ

投稿2018/12/15 00:32

編集2018/12/15 00:37

経緯

-開発環境はmac×Virtualbox×Vagrant×MySQL
-SQLiteからMySQLに切り替えようとしたところ。
-以下の通り進め、「Railsアプリの作成」の内容のところまで完了しています。
https://nishinatoshiharu.com/rails-mysql-starter/

発生した問題

$ rails new アプリケーション名 -d mysql -TB
でアプリケーションを作成まで無事行なえ、
コントローラーを作成しようとしたところ以下のmysql2のエラーが出たので、

$ rails g controller hogehoge index show Could not find gem 'mysql2 (< 0.6.0, >= 0.4.4)' in any of the gem sources listed in your Gemfile. Run `bundle install` to install missing gems.

参考にしたurl(https://nishinatoshiharu.com/rails-mysql-starter/)に記載されていた通り、以下を実施しようとしたところ、つまづいてしました。

$ bundle config --local build.mysql2 "--with-ldflags=-L/usr/local/opt/openssl/lib --with-cppflags=-I/usr/local/opt/openssl/include" $ bundle install --path=vendor/bundle

エラー内容は以下です。
対処法について、お力添えいただけないでしょうか?

$ bundle config --local build.mysql2 "--with-ldflags=-L/usr/local/opt/openssl/lib --with-cppflags=-I/usr/local/opt/openssl/include"

まで行なったところで、

You are replacing the current local value of build.mysql2, which is currently nil

と出たのですがそのままbundle installしたところ、以下のようなエラーとなってしまいました。(長くて申し訳ありません)

$ bundle install --path=vendor/bundle The dependency tzinfo-data (>= 0) will be unused by any of the platforms Bundler is installing for. Bundler is installing for ruby but the dependency is only for x86-mingw32, x86-mswin32, x64-mingw32, java. To add those platforms to the bundle, run `bundle lock --add-platform x86-mingw32 x86-mswin32 x64-mingw32 java`. Fetching gem metadata from https://rubygems.org/......... Fetching gem metadata from https://rubygems.org/. Resolving dependencies..... Fetching rake 12.3.2 Installing rake 12.3.2 Fetching concurrent-ruby 1.1.3 Installing concurrent-ruby 1.1.3 Fetching i18n 1.2.0 Installing i18n 1.2.0 Fetching minitest 5.11.3 Installing minitest 5.11.3 Fetching thread_safe 0.3.6 Installing thread_safe 0.3.6 Fetching tzinfo 1.2.5 Installing tzinfo 1.2.5 Fetching activesupport 5.2.2 Installing activesupport 5.2.2 Fetching builder 3.2.3 Installing builder 3.2.3 Fetching erubi 1.7.1 Installing erubi 1.7.1 Fetching mini_portile2 2.3.0 Installing mini_portile2 2.3.0 Fetching nokogiri 1.8.5 Installing nokogiri 1.8.5 with native extensions Fetching rails-dom-testing 2.0.3 Installing rails-dom-testing 2.0.3 Fetching crass 1.0.4 Installing crass 1.0.4 Fetching loofah 2.2.3 Installing loofah 2.2.3 Fetching rails-html-sanitizer 1.0.4 Installing rails-html-sanitizer 1.0.4 Fetching actionview 5.2.2 Installing actionview 5.2.2 Fetching rack 2.0.6 Installing rack 2.0.6 Fetching rack-test 1.1.0 Installing rack-test 1.1.0 Fetching actionpack 5.2.2 Installing actionpack 5.2.2 Fetching nio4r 2.3.1 Installing nio4r 2.3.1 with native extensions Fetching websocket-extensions 0.1.3 Installing websocket-extensions 0.1.3 Fetching websocket-driver 0.7.0 Installing websocket-driver 0.7.0 with native extensions Fetching actioncable 5.2.2 Installing actioncable 5.2.2 Fetching globalid 0.4.1 Installing globalid 0.4.1 Fetching activejob 5.2.2 Installing activejob 5.2.2 Fetching mini_mime 1.0.1 Installing mini_mime 1.0.1 Fetching mail 2.7.1 Installing mail 2.7.1 Fetching actionmailer 5.2.2 Installing actionmailer 5.2.2 Fetching activemodel 5.2.2 Installing activemodel 5.2.2 Fetching arel 9.0.0 Installing arel 9.0.0 Fetching activerecord 5.2.2 Installing activerecord 5.2.2 Fetching mimemagic 0.3.2 Installing mimemagic 0.3.2 Fetching marcel 0.3.3 Installing marcel 0.3.3 Fetching activestorage 5.2.2 Installing activestorage 5.2.2 Fetching bindex 0.5.0 Installing bindex 0.5.0 with native extensions Fetching msgpack 1.2.4 Installing msgpack 1.2.4 with native extensions Fetching bootsnap 1.3.2 Installing bootsnap 1.3.2 with native extensions Using bundler 1.16.4 Fetching byebug 10.0.2 Installing byebug 10.0.2 with native extensions Fetching coffee-script-source 1.12.2 Installing coffee-script-source 1.12.2 Fetching execjs 2.7.0 Installing execjs 2.7.0 Fetching coffee-script 2.4.1 Installing coffee-script 2.4.1 Fetching method_source 0.9.2 Installing method_source 0.9.2 Fetching thor 0.20.3 Installing thor 0.20.3 Fetching railties 5.2.2 Installing railties 5.2.2 Fetching coffee-rails 4.2.2 Installing coffee-rails 4.2.2 Fetching ffi 1.9.25 Installing ffi 1.9.25 with native extensions Fetching multi_json 1.13.1 Installing multi_json 1.13.1 Fetching jbuilder 2.8.0 Installing jbuilder 2.8.0 Fetching rb-fsevent 0.10.3 Installing rb-fsevent 0.10.3 Fetching rb-inotify 0.9.10 Installing rb-inotify 0.9.10 Fetching ruby_dep 1.5.0 Installing ruby_dep 1.5.0 Fetching listen 3.1.5 Installing listen 3.1.5 Fetching mysql2 0.5.2 Installing mysql2 0.5.2 with native extensions Gem::Ext::BuildError: ERROR: Failed to build gem native extension. current directory: /vagrant/hokatsu_no_mikata_3/vendor/bundle/ruby/2.5.0/gems/mysql2-0.5.2/ext/mysql2 /usr/bin/ruby2.5 -r ./siteconf20181214-4011-movy1.rb extconf.rb --with-ldflags=-L/usr/local/opt/openssl/lib --with-cppflags=-I/usr/local/opt/openssl/include checking for rb_absint_size()... yes checking for rb_absint_singlebit_p()... yes checking for rb_wait_for_single_fd()... yes checking for -lmysqlclient... no ----- mysql client is missing. You may need to 'apt-get install libmysqlclient-dev' or 'yum install mysql-devel', and try again. ----- *** 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-opt-lib --without-opt-lib=${opt-dir}/lib --with-make-prog --without-make-prog --srcdir=. --curdir --ruby=/usr/bin/$(RUBY_BASE_NAME)2.5 --with-mysql-dir --without-mysql-dir --with-mysql-include --without-mysql-include=${mysql-dir}/include --with-mysql-lib --without-mysql-lib=${mysql-dir}/lib --with-mysql-config --without-mysql-config --with-mysql-dir --without-mysql-dir --with-mysql-include --without-mysql-include=${mysql-dir}/include --with-mysql-lib --without-mysql-lib=${mysql-dir}/lib --with-mysqlclientlib --without-mysqlclientlib To see why this extension failed to compile, please check the mkmf.log which can be found here: /vagrant/hokatsu_no_mikata_3/vendor/bundle/ruby/2.5.0/extensions/x86_64-linux/2.5.0/mysql2-0.5.2/mkmf.log extconf failed, exit code 1 Gem files will remain installed in /vagrant/hokatsu_no_mikata_3/vendor/bundle/ruby/2.5.0/gems/mysql2-0.5.2 for inspection. Results logged to /vagrant/hokatsu_no_mikata_3/vendor/bundle/ruby/2.5.0/extensions/x86_64-linux/2.5.0/mysql2-0.5.2/gem_make.out An error occurred while installing mysql2 (0.5.2), and Bundler cannot continue. Make sure that `gem install mysql2 -v '0.5.2' --source 'https://rubygems.org/'` succeeds before bundling. In Gemfile: mysql2

既に行なってみた対応

ネットで色々検索をしてみて、
xcodeの問題かとも思ったのですが、
https://loumo.jp/wp/archive/20170524130019/
こちらを実施してみても以下のようにうまくいかず、問題を解決できずにおります。

$ xcode-select --install xcode-select: command not found

何とぞよろしくお願いします。

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

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

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

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

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

guest

回答1

0

ベストアンサー

mysql client is missing. You may need to 'apt-get install libmysqlclient-dev' or

'yum install mysql-devel', and try again.

に従い

Vagrantで動いてるOSが

  • Centos系ならばsudo yum install mysql-devl
  • Ubuntu系ならばsudo apt-get install libmysqlclient-dev
  • その他ならば対応するパッケージマネージャなどでlibmysqlclientを導入してください

投稿2018/12/15 01:52

asm

総合スコア15147

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

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

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

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

ただいまの回答率
85.50%

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

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

質問する

関連した質問