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

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

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

Rubyはプログラミング言語のひとつで、オープンソース、オブジェクト指向のプログラミング開発に対応しています。

MySQL

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

Ruby on Rails

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

Q&A

解決済

1回答

2389閲覧

bundle install mysqlエラー

neko_53

総合スコア75

Ruby

Rubyはプログラミング言語のひとつで、オープンソース、オブジェクト指向のプログラミング開発に対応しています。

MySQL

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

Ruby on Rails

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

0グッド

0クリップ

投稿2017/08/28 01:39

編集2017/08/28 01:57

OSをSierraに変更しRubyバージョンをアップデートしたため、ruby2.1.3で作っていたアプリのバージョンアップをしようとしたところmysqlのエラーが出ました。

$ bundle install Fetching gem metadata from https://rubygems.org/........ Fetching version metadata from https://rubygems.org/.. Fetching dependency metadata from https://rubygems.org/. Resolving dependencies... Using rake 12.0.0 Using CFPropertyList 2.3.5 Using i18n 0.8.1 Using json 1.8.6 Using minitest 5.10.1 Using thread_safe 0.3.6 Using builder 3.2.3 Using erubis 2.7.0 Using mini_portile2 2.1.0 Using rack 1.6.5 Using mime-types-data 3.2016.0521 Using arel 6.0.4 Using bcrypt 3.1.11 Using debug_inspector 0.0.2 Using bundler 1.15.4 Using byebug 9.0.6 Using coderay 1.1.1 Using coffee-script-source 1.12.2 Using execjs 2.7.0 Using thor 0.19.4 Using concurrent-ruby 1.0.5 Using orm_adapter 0.5.0 Using excon 0.55.0 Using formatador 0.2.5 Using multi_json 1.12.1 Using ipaddress 0.8.3 Using xml-simple 1.1.5 Using inflecto 0.0.2 Using trollop 2.1.2 Using google-analytics-rails 1.1.0 Using method_source 0.8.2 Fetching mysql2 0.3.18 Installing mysql2 0.3.18 with native extensions Using slop 3.6.0 Using rails_serve_static_assets 0.0.5 Using rails_stdout_logging 0.0.5 Using rdoc 4.3.0 Using rmagick 2.16.0 Using sass 3.4.23 Using tilt 2.0.7 Using turbolinks-source 5.0.0 Using fission 0.5.0 Using tzinfo 1.2.3 Using nokogiri 1.7.1 Using rack-test 0.6.3 Using warden 1.2.7 Using mime-types 3.1 Using binding_of_caller 0.7.2 Using coffee-script 2.4.1 Using uglifier 3.1.13 Using sprockets 3.7.1 Using fog-core 1.43.0 Gem::Ext::BuildError: ERROR: Failed to build gem native extension. current directory: /Users/ユーザー名/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/mysql2-0.3.18/ext/mysql2 /Users/ユーザー名/.rbenv/versions/2.3.1/bin/ruby -r ./siteconf20170828-89643-199247j.rb extconf.rb --with-ldflags=-L/usr/local/opt/openssl/lib --with-cppflags=-I/usr/local/opt/openssl/include checking for ruby/thread.h... yes checking for rb_thread_call_without_gvl() in ruby/thread.h... yes checking for rb_thread_blocking_region()... no checking for rb_wait_for_single_fd()... yes checking for rb_hash_dup()... yes checking for rb_intern3()... yes checking for mysql_query() in -lmysqlclient... no checking for main() in -lm... yes checking for mysql_query() in -lmysqlclient... no checking for main() in -lz... yes checking for mysql_query() in -lmysqlclient... no checking for main() in -lsocket... no checking for mysql_query() in -lmysqlclient... no checking for main() in -lnsl... no checking for mysql_query() in -lmysqlclient... no checking for main() in -lmygcc... no checking for mysql_query() in -lmysqlclient... no *** 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=/Users/ユーザー名/.rbenv/versions/2.3.1/bin/$(RUBY_BASE_NAME) --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 --with-mlib --without-mlib --with-mysqlclientlib --without-mysqlclientlib --with-zlib --without-zlib --with-mysqlclientlib --without-mysqlclientlib --with-socketlib --without-socketlib --with-mysqlclientlib --without-mysqlclientlib --with-nsllib --without-nsllib --with-mysqlclientlib --without-mysqlclientlib --with-mygcclib --without-mygcclib --with-mysqlclientlib --without-mysqlclientlib To see why this extension failed to compile, please check the mkmf.log which can be found here: /Users/ユーザー名/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/extensions/x86_64-darwin-16/2.3.0-static/mysql2-0.3.18/mkmf.log extconf failed, exit code 1 Gem files will remain installed in /Users/ユーザー名/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/mysql2-0.3.18 for inspection. Results logged to /Users/ユーザー名/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/extensions/x86_64-darwin-16/2.3.0-static/mysql2-0.3.18/gem_make.out An error occurred while installing mysql2 (0.3.18), and Bundler cannot continue. Make sure that `gem install mysql2 -v '0.3.18'` succeeds before bundling. In Gemfile: mysql2

以下を試しましたが上記のエラーが発生したままでした。

macpro:アプリ名 ユーザー名$ 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 macpro:アプリ名 ユーザー名$ cat .bundle/config --- BUNDLE_BUILD__MYSQL2: "--with-ldflags=-L/usr/local/opt/openssl/lib --with-cppflags=-I/usr/local/opt/openssl/include"

解決策を教えていただきたいです。

ruby2.3.1
OS Sierra10.12.5

追記2017/08/28 10:48

gem listを見てみると以下のようになっていました。

actionmailer (4.2.5.1) actionpack (4.2.5.1) actionview (4.2.5.1) activejob (4.2.5.1) activemodel (4.2.5.1) activerecord (4.2.5.1) activesupport (4.2.5.1) arel (6.0.4) bcrypt (3.1.11) bigdecimal (1.2.8) binding_of_caller (0.7.2) builder (3.2.3) bundler (1.15.4, 1.15.3) byebug (9.0.6) CFPropertyList (2.3.5) coderay (1.1.1) coffee-rails (4.1.1) coffee-script (2.4.1) coffee-script-source (1.12.2) concurrent-ruby (1.0.5) debug_inspector (0.0.3, 0.0.2) devise (4.3.0) did_you_mean (1.0.0) erubis (2.7.0) excon (0.55.0) execjs (2.7.0) ffi (1.9.18) fission (0.5.0) fog-core (1.43.0) formatador (0.2.5) globalid (0.4.0) google-analytics-rails (1.1.0) i18n (0.8.6, 0.8.1) inflecto (0.0.2) io-console (0.4.5) ipaddress (0.8.3) jbuilder (2.7.0) jquery-rails (4.3.1) json (1.8.6, 1.8.3) loofah (2.0.3) mail (2.6.6) method_source (0.8.2) mime-types (3.1) mime-types-data (3.2016.0521) mini_portile2 (2.2.0, 2.1.0) minitest (5.10.3, 5.10.1, 5.8.3) multi_json (1.12.1) mysql2 (0.4.8) net-telnet (0.1.1) nokogiri (1.8.0, 1.7.1) orm_adapter (0.5.0) power_assert (0.2.6) pry (0.10.4) pry-rails (0.3.6) psych (2.0.17) rack (1.6.8, 1.6.5) rack-test (0.6.3) rails (4.2.5.1) rails-deprecated_sanitizer (1.0.3) rails-dom-testing (1.0.8) rails-html-sanitizer (1.0.3) rails_serve_static_assets (0.0.5) rails_stdout_logging (0.0.5) railties (4.2.5.1) rake (12.0.0, 10.4.2) rb-fsevent (0.10.2) rb-inotify (0.9.10) rdoc (4.3.0, 4.2.1) responders (2.4.0) rmagick (2.16.0) sass (3.5.1, 3.4.23) sass-listen (4.0.0) sass-rails (5.0.6) sdoc (0.4.2) slop (3.6.0) spring (2.0.2) sprockets (3.7.1) sprockets-rails (3.2.0) test-unit (3.1.5) thor (0.19.4) thread_safe (0.3.6) tilt (2.0.8, 2.0.7) trollop (2.1.2) turbolinks (5.0.1) turbolinks-source (5.0.3, 5.0.0) tzinfo (1.2.3) uglifier (3.2.0, 3.1.13) warden (1.2.7) web-console (2.3.0) xml-simple (1.1.5)

mysqlが0.4.8になっているのですがこの場合gemfileのmysqlのバージョンを0.4.8に変更してbundle installすれば良いのでしょうか?
一応、以下に現在のgemfileを添付します。

source 'https://rubygems.org' ruby '2.3.1' # Bundle edge Rails instead: gem 'rails', github: 'rails/rails' gem 'rails', '4.2.5.1' # Use mysql as the database for Active Record gem 'mysql2', '0.3.18' # Use SCSS for stylesheets gem 'sass-rails', '~> 5.0' # Use Uglifier as compressor for JavaScript assets gem 'uglifier', '>= 1.3.0' # Use CoffeeScript for .coffee assets and views gem 'coffee-rails', '~> 4.1.0' # See https://github.com/rails/execjs#readme for more supported runtimes # gem 'therubyracer', platforms: :ruby # Use jquery as the JavaScript library gem 'jquery-rails' # Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks gem 'turbolinks' # Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder gem 'jbuilder', '~> 2.0' # bundle exec rake doc:rails generates the API under doc/api. gem 'sdoc', '~> 0.4.0', group: :doc # Use ActiveModel has_secure_password # gem 'bcrypt', '~> 3.1.7' # Use Unicorn as the app server # gem 'unicorn' # Use Capistrano for deployment # gem 'capistrano-rails', group: :development group :development, :test do # Call 'byebug' anywhere in the code to stop execution and get a debugger console gem 'byebug' end group :development do # Access an IRB console on exception pages or by using <%= console %> in views gem 'web-console', '~> 2.0' # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring gem 'spring' end group :production, :staging do gem 'rails_12factor' end gem 'devise' gem 'carrierwave' gem 'rmagick' gem 'fog' gem 'pry-rails' gem 'google-analytics-rails' gem 'payjp'

よろしくお願いします。

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

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

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

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

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

guest

回答1

0

ベストアンサー

Ruby の MySQL Client をインストールするには、MySQL のクライアントライブラリが必要ですが、OSの再インストール?後に MySQL は、インストールされましたか?

ログでも mysqlclient ライブラリが、ないと言われています。

checking for mysql_query() in -lmysqlclient... no checking for main() in -lm... yes checking for mysql_query() in -lmysqlclient... no checking for main() in -lz... yes checking for mysql_query() in -lmysqlclient... no checking for main() in -lsocket... no checking for mysql_query() in -lmysqlclient... no checking for main() in -lnsl... no checking for mysql_query() in -lmysqlclient... no checking for main() in -lmygcc... no checking for mysql_query() in -lmysqlclient... no

投稿2017/08/28 02:41

CHERRY

総合スコア25171

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

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

neko_53

2017/08/28 03:07 編集

特に何も行なっていないです。 この場合はターミナルで $brew install mysql56 mysql 上記を行えばエラーが解消されるということでいいんでしょうか? バージョンをアップデートする前はこのようなエラーは出なかったのですがバージョンアップを行うともう一度Mysqlをインストールし直さないといけなくなるんでしょうか?
guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

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

ただいまの回答率
85.50%

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

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

質問する

関連した質問