2014年5月6日火曜日

Ruby on RailsからMySQL接続に発生するエラー

Ruby on RailsからMySQLに接続しようとして下記エラーが発生
[xxxxxxxx@yyyyyyyy zzzzz]$rake environment -v -t RAILS_ENV=development db:schema:dump
Could not find gem 'mysql2 (>= 0) ruby' in the gems available on this machine.
Run `bundle install` to install missing gems.
[xxxxxxxx@yyyyyyyy zzzzz]$bundle install
Fetching gem metadata from https://rubygems.org/...........
Fetching additional metadata from https://rubygems.org/..
Resolving dependencies...
Using rake (10.3.1)
Using i18n (0.6.9)
Using minitest (4.7.5)
Using multi_json (1.10.0)
Using thread_safe (0.3.3)
Using tzinfo (0.3.39)
Using activesupport (4.0.4)
Using builder (3.1.4)
Using erubis (2.7.0)
Using rack (1.5.2)
Using rack-test (0.6.2)
Using actionpack (4.0.4)
Using mime-types (1.25.1)
Using polyglot (0.3.4)
Using treetop (1.4.15)
Using mail (2.5.4)
Using actionmailer (4.0.4)
Using activemodel (4.0.4)
Using activerecord-deprecated_finders (1.0.3)
Using arel (4.0.2)
Using activerecord (4.0.4)
Using bundler (1.5.2)
Using coffee-script-source (1.7.0)
Using execjs (2.0.2)
Using coffee-script (2.2.0)
Using thor (0.19.1)
Using railties (4.0.4)
Using coffee-rails (4.0.1)
Using hike (1.2.3)
Using jbuilder (1.5.3)
Using jquery-rails (3.1.0)
Using json (1.8.1)
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.
/Users/rmswimkkrr/.rvm/rubies/ruby-2.0.0-p353/bin/ruby extconf.rb
checking for ruby/thread.h... yes
checking for rb_thread_call_without_gvl() in ruby/thread.h... yes
checking for rb_thread_blocking_region()... yes
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/rmswimkkrr/.rvm/rubies/ruby-2.0.0-p353/bin/ruby
--with-mysql-dir
--without-mysql-dir
--with-mysql-include
--without-mysql-include=${mysql-dir}/include
--with-mysql-lib
--without-mysql-lib=${mysql-dir}/
--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}/
--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
Gem files will remain installed in /Users/rmswimkkrr/.rvm/gems/ruby-2.0.0-p353@railstutorial_rails_4_0/gems/mysql2-0.3.15 for inspection.
Results logged to /Users/rmswimkkrr/.rvm/gems/ruby-2.0.0-p353@railstutorial_rails_4_0/gems/mysql2-0.3.15/ext/mysql2/gem_make.out
An error occurred while installing mysql2 (0.3.15), and Bundler cannot continue.
Make sure that `gem install mysql2 -v '0.3.15'` succeeds before bundling.
view raw gistfile1.ps1 hosted with ❤ by GitHub

MySQLをインストールしてから再度実行でうまくいきました。(参考)
[xxxxxxxx@yyyyyyyy zzzzz]$bash <(curl -Ls http://git.io/eUx7rg)
Downloading MySQL Installers ... may take a few moments
######################################################################## 100.0%
...
...
Installing MySQL, administrator password required ...
Password:
installer: Package name is MySQL 5.6.17-community for Mac OS X
installer: Installing at base path /
installer: The install was successful.
...
...
Installing MySQL start up items...
installer: Package name is MySQL Startup Item
installer: Installing at base path /
installer: The install was successful.
...
...
Click Install to install the MySQL preferance pane
...
...
...
Starting MySQL
.. SUCCESS!
Setting MySQL root Password to Tke4suoj
Placing password on desktop...
...
...
BASE PERFORMANCE MY.CNF IS JUST A GENERIC SUGGESTION FOR PERFORMANCE
YOUR RESULTS MAY VARY AND YOU MAY WANT TO FURTHER TUNE YOUR MY.CNF SETTINGS
BASE PERFORMANCE MY.CNF INCREASES BUFFERS/MEMORY USAGE
8GB+ RAM IS RECOMMENDED FOR BASE PERFORMANCE MY.CNF
...
DO YOU WANT TO LOAD A BASE PERFORMANCE MY.CNF FILE? [y/N]y
Shutting down MySQL
.. SUCCESS!
Starting MySQL
.. SUCCESS!
DO YOU WANT TO AUTOMATICALLY INSTALL SEQUEL PRO? [Y/n]n
ALL DONE! Install Sequel Pro or phpmyadmin to administer MySQL
Log off and log back in for 'mysql' to be recognized as a command in terminal
[xxxxxxxx@yyyyyyyy zzzzz]$gem install mysql2
Building native extensions. This could take a while...
Successfully installed mysql2-0.3.15
1 gem installed
[xxxxxxxx@yyyyyyyy zzzzz]$bundle install
Fetching gem metadata from https://rubygems.org/...........
Fetching additional metadata from https://rubygems.org/..
Resolving dependencies...
Using rake (10.3.1)
Using i18n (0.6.9)
Using minitest (4.7.5)
Using multi_json (1.10.0)
Using thread_safe (0.3.3)
Using tzinfo (0.3.39)
Using activesupport (4.0.4)
Using builder (3.1.4)
Using erubis (2.7.0)
Using rack (1.5.2)
Using rack-test (0.6.2)
Using actionpack (4.0.4)
Using mime-types (1.25.1)
Using polyglot (0.3.4)
Using treetop (1.4.15)
Using mail (2.5.4)
Using actionmailer (4.0.4)
Using activemodel (4.0.4)
Using activerecord-deprecated_finders (1.0.3)
Using arel (4.0.2)
Using activerecord (4.0.4)
Using bundler (1.5.2)
Using coffee-script-source (1.7.0)
Using execjs (2.0.2)
Using coffee-script (2.2.0)
Using thor (0.19.1)
Using railties (4.0.4)
Using coffee-rails (4.0.1)
Using hike (1.2.3)
Using jbuilder (1.5.3)
Using jquery-rails (3.1.0)
Using json (1.8.1)
Using mysql2 (0.3.15)
Using tilt (1.4.1)
Using sprockets (2.11.0)
Using sprockets-rails (2.0.1)
Using rails (4.0.4)
Using rdoc (4.1.1)
Using sass (3.2.19)
Using sass-rails (4.0.3)
Using sdoc (0.4.0)
Using turbolinks (2.2.2)
Using uglifier (2.5.0)
Your bundle is complete!
Use `bundle show [gemname]` to see where a bundled gem is installed.
view raw gistfile1.sh hosted with ❤ by GitHub


libmysqlclient.18.dylibがないと言われた場合。
参考

0 件のコメント:

コメントを投稿