Unable to start rails server - mysql

I have installed rails and mysql. I have also installed mysql2 gem. I created a rails application by the command
rails new try_cms -d mysql
It was created successfully. But when I try to run the WEBrick server using rails server command I get the following errors.
/Library/Ruby/Gems/1.8/gems/mysql2-0.2.6/lib/mysql2/mysql2.bundle: dlopen(/Library/Ruby/Gems/1.8/gems/mysql2-0.2.6/lib/mysql2/mysql2.bundle, 9): Library not loaded: libmysqlclient.16.dylib (LoadError)
Referenced from: /Library/Ruby/Gems/1.8/gems/mysql2-0.2.6/lib/mysql2/mysql2.bundle
Reason: image not found - /Library/Ruby/Gems/1.8/gems/mysql2-0.2.6/lib/mysql2/mysql2.bundle
from /Library/Ruby/Gems/1.8/gems/mysql2-0.2.6/lib/mysql2.rb:7
from /Library/Ruby/Gems/1.8/gems/bundler-1.0.9/lib/bundler/runtime.rb:68:in `require'
from /Library/Ruby/Gems/1.8/gems/bundler-1.0.9/lib/bundler/runtime.rb:68:in `require'
from /Library/Ruby/Gems/1.8/gems/bundler-1.0.9/lib/bundler/runtime.rb:66:in `each'
from /Library/Ruby/Gems/1.8/gems/bundler-1.0.9/lib/bundler/runtime.rb:66:in `require'
from /Library/Ruby/Gems/1.8/gems/bundler-1.0.9/lib/bundler/runtime.rb:55:in `each'
from /Library/Ruby/Gems/1.8/gems/bundler-1.0.9/lib/bundler/runtime.rb:55:in `require'
from /Library/Ruby/Gems/1.8/gems/bundler-1.0.9/lib/bundler.rb:114:in `require'
from /Users/dilippednekar/Sites/try_cms/config/application.rb:7
from /Library/Ruby/Gems/1.8/gems/railties-3.0.3/lib/rails/commands.rb:28:in `require'
from /Library/Ruby/Gems/1.8/gems/railties-3.0.3/lib/rails/commands.rb:28
from /Library/Ruby/Gems/1.8/gems/railties-3.0.3/lib/rails/commands.rb:27:in `tap'
from /Library/Ruby/Gems/1.8/gems/railties-3.0.3/lib/rails/commands.rb:27
from script/rails:6:in `require'
from script/rails:6
Thanks in advance.

Try running this (see similar question here)
sudo install_name_tool -change libmysqlclient.16.dylib /usr/local/mysql/lib/libmysqlclient.16.dylib /Library/Ruby/Gems/1.8/gems/mysql2-0.2.6/lib/mysql2/mysql2.bundle

Just ran into this problem myself. Make sure you update the version numbers.
sudo install_name_tool -change libmysqlclient.18.dylib /usr/local/mysql/lib/libmysqlclient.18.dylib /Library/Ruby/Gems/1.8/gems/mysql2-0.2.7/lib/mysql2/mysql2.bundle

For some reason the mysql2.bundle file was not in my mysql2 gem. I ran
gem uninstall mysql2
and the gem was uninstalled. Then I immediately ran
sudo gem install mysql2
Then
sudo install_name_tool -change libmysqlclient.16.dylib /usr/local/mysql/lib/libmysqlclient.16.dylib /Library/Ruby/Gems/1.8/gems/mysql2-0.2.6/lib/mysql2/mysql2.bundle
Finally rails s launched the server!

I had similar problems. The solutio that worked for me was found here.

If you want something a little less intrusive, just set the DYLD_LIBRARY_PATH environment variable in your MySQL's lib direction.
export DYLD_LIBRARY_PATH=$MYSQL_HOME/lib

I was just hit with this using Rails 3.1.0, ruby-1.9.2-p290 and mysql2 0.3.7. My solution was to downgrade to mysql 2.8.1. Everything looks good so far (I wasn't even able to start the environment).

sudo apt-get install libmysqlclient15-dev libmysqlclient15off libmysql-ruby

Related

mysql doesn't seem to work with my new rails app

I can't seem to get mysql to work with my new rails app at all... terminal copy below:
Janes-MacBook-Pro:development janelee$ cd hellomysql
Janes-MacBook-Pro:hellomysql janelee$ rails server
/Users/janelee/.rvm/gems/ruby-1.8.7-p174/gems/mysql2-0.3.11/lib/mysql2/mysql2.bundle: dlopen(/Users/janelee/.rvm/gems/ruby-1.8.7-p174/gems/mysql2-0.3.11/lib/mysql2/mysql2.bundle, 9): no suitable image found. Did find: (LoadError)
/Users/janelee/.rvm/gems/ruby-1.8.7-p174/gems/mysql2-0.3.11/lib/mysql2/mysql2.bundle: mach-o, but wrong architecture - /Users/janelee/.rvm/gems/ruby-1.8.7-p174/gems/mysql2-0.3.11/lib/mysql2/mysql2.bundle
from /Users/janelee/.rvm/gems/ruby-1.8.7-p174/gems/mysql2-0.3.11/lib/mysql2.rb:9
from /Users/janelee/.rvm/gems/ruby-1.8.7-p174/gems/bundler-1.0.22/lib/bundler/runtime.rb:68:in `require'
from /Users/janelee/.rvm/gems/ruby-1.8.7-p174/gems/bundler-1.0.22/lib/bundler/runtime.rb:68:in `require'
from /Users/janelee/.rvm/gems/ruby-1.8.7-p174/gems/bundler-1.0.22/lib/bundler/runtime.rb:66:in `each'
from /Users/janelee/.rvm/gems/ruby-1.8.7-p174/gems/bundler-1.0.22/lib/bundler/runtime.rb:66:in `require'
from /Users/janelee/.rvm/gems/ruby-1.8.7-p174/gems/bundler-1.0.22/lib/bundler/runtime.rb:55:in `each'
from /Users/janelee/.rvm/gems/ruby-1.8.7-p174/gems/bundler-1.0.22/lib/bundler/runtime.rb:55:in `require'
from /Users/janelee/.rvm/gems/ruby-1.8.7-p174/gems/bundler-1.0.22/lib/bundler.rb:122:in `require'
from /Users/janelee/Development/hellomysql/config/application.rb:7
from /Users/janelee/.rvm/gems/ruby-1.8.7-p174/gems/railties-3.2.1/lib/rails/commands.rb:53:in `require'
from /Users/janelee/.rvm/gems/ruby-1.8.7-p174/gems/railties-3.2.1/lib/rails/commands.rb:53
from /Users/janelee/.rvm/gems/ruby-1.8.7-p174/gems/railties-3.2.1/lib/rails/commands.rb:50:in `tap'
from /Users/janelee/.rvm/gems/ruby-1.8.7-p174/gems/railties-3.2.1/lib/rails/commands.rb:50
from script/rails:6:in `require'
from script/rails:6
Janes-MacBook-Pro:hellomysql janelee$ rake db:migrate
rake aborted!
dlopen(/Users/janelee/.rvm/gems/ruby-1.8.7-p174/gems/mysql2-0.3.11/lib/mysql2/mysql2.bundle, 9): no suitable image found. Did find:
/Users/janelee/.rvm/gems/ruby-1.8.7-p174/gems/mysql2-0.3.11/lib/mysql2/mysql2.bundle: mach-o, but wrong architecture - /Users/janelee/.rvm/gems/ruby-1.8.7-p174/gems/mysql2-0.3.11/lib/mysql2/mysql2.bundle
(See full trace by running task with --trace)
and I tried this too:
Janes-MacBook-Pro:hello janelee$ gem uninstall sqlite3
You have requested to uninstall the gem:
sqlite3-1.3.5
i18n-0.6.0 depends on [sqlite3 (>= 0)]
If you remove this gems, one or more dependencies will not be met.
Continue with Uninstall? [Yn] y
Successfully uninstalled sqlite3-1.3.5
Janes-MacBook-Pro:hello janelee$ ARCHFLAGS="-arch x86_32" sudo gem install sqlite3
Password:
Building native extensions. This could take a while...
Successfully installed sqlite3-1.3.5
1 gem installed
Janes-MacBook-Pro:hello janelee$ rake db:migrate
rake aborted!
dlopen(/Users/janelee/.rvm/gems/ruby-1.8.7-p174/gems/sqlite3-1.3.5/lib/sqlite3/sqlite3_native.bundle, 9): no suitable image found. Did find:
/Users/janelee/.rvm/gems/ruby-1.8.7-p174/gems/sqlite3-1.3.5/lib/sqlite3/sqlite3_native.bundle: mach-o, but wrong architecture - /Users/janelee/.rvm/gems/ruby-1.8.7-p174/gems/sqlite3-1.3.5/lib/sqlite3/sqlite3_native.bundle
(See full trace by running task with --trace)
and this:
Janes-MacBook-Pro:hello janelee$ gem uninstall sqlite3
You have requested to uninstall the gem:
sqlite3-1.3.5
i18n-0.6.0 depends on [sqlite3 (>= 0)]
If you remove this gems, one or more dependencies will not be met.
Continue with Uninstall? [Yn] y
Successfully uninstalled sqlite3-1.3.5
Janes-MacBook-Pro:hello janelee$ ARCHFLAGS="-arch x86_64" sudo gem install sqlite3
Building native extensions. This could take a while...
Successfully installed sqlite3-1.3.5
1 gem installed
Janes-MacBook-Pro:hello janelee$ rake db:migrate
rake aborted!
dlopen(/Users/janelee/.rvm/gems/ruby-1.8.7-p174/gems/sqlite3-1.3.5/lib/sqlite3/sqlite3_native.bundle, 9): no suitable image found. Did find:
/Users/janelee/.rvm/gems/ruby-1.8.7-p174/gems/sqlite3-1.3.5/lib/sqlite3/sqlite3_native.bundle: mach-o, but wrong architecture - /Users/janelee/.rvm/gems/ruby-1.8.7-p174/gems/sqlite3-1.3.5/lib/sqlite3/sqlite3_native.bundle
(See full trace by running task with --trace)
What else should I try before reinstall Lion?
Look into using Ruby Version Manager (called rvm) and then update Ruby. Try using ver 1.9 of ruby or higher. Don't reinstall your OS. If anything, remove rails, remove ruby. Install rvm, install ruby 1.9, install rails. If you follow that recipe, all should be well.
Configuring Rails to work with MySQL will happen through changing the file:
myappname/config/database.yml
Good information is here: How do I set MySQL as the default database in Rails 3?
... and here: Create a new Ruby on Rails application using MySQL instead of SQLite
Get used to looking at the Rails guides. Examples like this: http://guides.rubyonrails.org/getting_started.html#configuring-a-database are all you need to get going.

rails server command unable to find libraries

I've installed rails, the mysql2 gem, and mysql and have created a project called simple_cms using rails new simple_cms -d mysql. Now when I execute rails server to start WEBricks, I get this bucket of joy:
/Library/Ruby/Gems/1.8/gems/mysql2-0.3.11/lib/mysql2/mysql2.bundle: dlopen(/Library/Ruby/Gems/1.8/gems/mysql2-0.3.11/lib/mysql2/mysql2.bundle, 9): Library not loaded: /usr/local/mysql/lib/libmysqlclient.16.dylib (LoadError)
Referenced from: /Library/Ruby/Gems/1.8/gems/mysql2-0.3.11/lib/mysql2/mysql2.bundle
Reason: image not found - /Library/Ruby/Gems/1.8/gems/mysql2-0.3.11/lib/mysql2/mysql2.bundle
from /Library/Ruby/Gems/1.8/gems/mysql2-0.3.11/lib/mysql2.rb:9
from /Library/Ruby/Gems/1.8/gems/bundler-1.0.21/lib/bundler/runtime.rb:68:in `require'
from /Library/Ruby/Gems/1.8/gems/bundler-1.0.21/lib/bundler/runtime.rb:68:in `require'
from /Library/Ruby/Gems/1.8/gems/bundler-1.0.21/lib/bundler/runtime.rb:66:in `each'
from /Library/Ruby/Gems/1.8/gems/bundler-1.0.21/lib/bundler/runtime.rb:66:in `require'
from /Library/Ruby/Gems/1.8/gems/bundler-1.0.21/lib/bundler/runtime.rb:55:in `each'
from /Library/Ruby/Gems/1.8/gems/bundler-1.0.21/lib/bundler/runtime.rb:55:in `require'
from /Library/Ruby/Gems/1.8/gems/bundler-1.0.21/lib/bundler.rb:122:in `require'
from /Users/tyre77/Dropbox/Broetry In Motion/RailsTestApp/simple_cms/config/application.rb:7
from /Library/Ruby/Gems/1.8/gems/railties-3.2.1/lib/rails/commands.rb:53:in `require'
from /Library/Ruby/Gems/1.8/gems/railties-3.2.1/lib/rails/commands.rb:53
from /Library/Ruby/Gems/1.8/gems/railties-3.2.1/lib/rails/commands.rb:50:in `tap'
from /Library/Ruby/Gems/1.8/gems/railties-3.2.1/lib/rails/commands.rb:50
from script/rails:6:in `require'
from script/rails:6
I have changed my .bash_profile to look like this: (not sure if relevant)
PS1="\u \w$ "
alias ll="ls -lahG"
export PATH="/usr/local/bin:/usr/local/sbin:/usr/local/mysql/bin:/$PATH"
# include .bashrc if it exists
if [ -f $HOME/.bashrc ]; then
. $HOME/.bashrc
fi
# startup virtualenv-burrito
if [ -f $HOME/.venvburrito/startup.sh ]; then
. $HOME/.venvburrito/startup.sh
fi
See:
Unable to start rails server but my mysql version is different and that doesn't solve it even with changing 0.2.6 to 0.3.11
The issue is that Ruby can't find the libraries necessary to build the MySQL gem, there are many ways to fix this but since it looks like you're just starting up on Ruby, I think it's worth to prepare your environment so you don't see this kind of stuff again, here are the steps:
First I would recommend you to install Homebrew, with Homebrew installed, install MySQL:
brew install mysql
This will install MySQL in your machine including the necessary libraries to build the MySQL gem when you need it.
Then you should to install RVM to install your rubies (before installing RVM you need to run brew install git). Once you install RVM, you can start installing any rubies you would like to.
And then you ask, why can't you use the built in Ruby? Rails will drop support for the Ruby 1.8.* branch on 4.0 and the community in general uses RVM (or rbenv) to install and manage rubies installed to your machine.

rails server error ? (rails 3)

/Library/Ruby/Gems/1.8/gems/mysql2-0.3.2/lib/mysql2/mysql2.bundle: dlopen(/Library/Ruby/Gems/1.8/gems/mysql2-0.3.2/lib/mysql2/mysql2.bundle, 9): Library not loaded: libmysqlclient.18.dylib (LoadError)
Referenced from: /Library/Ruby/Gems/1.8/gems/mysql2-0.3.2/lib/mysql2/mysql2.bundle
Reason: image not found - /Library/Ruby/Gems/1.8/gems/mysql2-0.3.2/lib/mysql2/mysql2.bundle
from /Library/Ruby/Gems/1.8/gems/mysql2-0.3.2/lib/mysql2.rb:8
from /Library/Ruby/Gems/1.8/gems/bundler-1.0.12/lib/bundler/runtime.rb:68:in `require'
from /Library/Ruby/Gems/1.8/gems/bundler-1.0.12/lib/bundler/runtime.rb:68:in `require'
from /Library/Ruby/Gems/1.8/gems/bundler-1.0.12/lib/bundler/runtime.rb:66:in `each'
from /Library/Ruby/Gems/1.8/gems/bundler-1.0.12/lib/bundler/runtime.rb:66:in `require'
from /Library/Ruby/Gems/1.8/gems/bundler-1.0.12/lib/bundler/runtime.rb:55:in `each'
from /Library/Ruby/Gems/1.8/gems/bundler-1.0.12/lib/bundler/runtime.rb:55:in `require'
from /Library/Ruby/Gems/1.8/gems/bundler-1.0.12/lib/bundler.rb:120:in `require'
from /Users/imran/simple_cms/config/application.rb:7
from /Library/Ruby/Gems/1.8/gems/railties-3.0.7/lib/rails/commands.rb:28:in `require'
from /Library/Ruby/Gems/1.8/gems/railties-3.0.7/lib/rails/commands.rb:28
from /Library/Ruby/Gems/1.8/gems/railties-3.0.7/lib/rails/commands.rb:27:in `tap'
from /Library/Ruby/Gems/1.8/gems/railties-3.0.7/lib/rails/commands.rb:27
from script/rails:6:in `require'
from script/rails:6
Does anyone know how i can fix this?? Thanks in advance ;-)
now i'm getting this?
dyld: lazy symbol binding failed: Symbol not found:
_mysql_get_client_info Referenced from: /Library/Ruby/Gems/1.8/gems/mysql2-0.3.2/lib/mysql2/mysql2.bundle
Expected in: flat namespace
dyld: Symbol not found: _mysql_get_client_info Referenced from:
/Library/Ruby/Gems/1.8/gems/mysql2-0.3.2/lib/mysql2/mysql2.bundle
Expected in: flat namespace
Trace/BPT trap
may be this post is similiar with your problem :
Library not loaded: libmysqlclient.16.dylib error when trying to run 'rails server' on OS X 10.6 with mysql2 gem
Try this:
export DYLD_LIBRARY_PATH="$DYLD_LIBRARY_PATH:/usr/local/mysql/lib/"
Put this in your .profile (or .bashrc) and type this command
my_term> source .profile
replace '/usr/local/mysql/lib/' by where you MySQL client is installed
Updated MySQL again from installer (say, mysql-5.5.10-osx10.6-x86_64).
Then MySQL2 gem:
$ sudo gem install mysql2 --
--with-mysql-config=/usr/local/mysql-5.5.10-osx10.6-x86_64/bin/mysql_config
It worked for me.
For permanent fix, try to create a soft link by command -
sudo ln -s /usr/local/mysql/lib/libmysqlclient.16.dylib /usr/lib/libmysqlclient.16.dylib
http://rorguide.blogspot.com/2011/07/getting-error-library-not-loaded.html
I also had this problem and any suggestions I found here or in other questions didn't get me anywhere, but running as root did (with sudo rails s). I guess that when running as root, it uses the right path to the mysql library, but changing it with install_name_tool as described in one of the links here doesn't work, too. As long as I don't find the issue, I need to start my rails app with sudo.

Ruby: mysql2-Gem not working (Mac OS X Snow Leopard, Ruby 1.9.2)

I just compiled ruby and installes rubygems, mysql2 and rails, which worked quite well. But I get the following error message, whenever I try to start the rails server:
/usr/local/ruby/lib/ruby/gems/1.9.1/gems/mysql2-0.2.6/lib/mysql2.rb:7:in `require': dlopen(/usr/local/ruby/lib/ruby/gems/1.9.1/gems/mysql2-0.2.6/lib/mysql2/mysql2.bundle, 9): Library not loaded: libmysqlclient.18.dylib (LoadError)
Referenced from: /usr/local/ruby/lib/ruby/gems/1.9.1/gems/mysql2-0.2.6/lib/mysql2/mysql2.bundle
Reason: image not found - /usr/local/ruby/lib/ruby/gems/1.9.1/gems/mysql2-0.2.6/lib/mysql2/mysql2.bundle
from /usr/local/ruby/lib/ruby/gems/1.9.1/gems/mysql2-0.2.6/lib/mysql2.rb:7:in `'
from /usr/local/ruby/lib/ruby/gems/1.9.1/gems/bundler-1.0.10/lib/bundler/runtime.rb:68:in `require'
from /usr/local/ruby/lib/ruby/gems/1.9.1/gems/bundler-1.0.10/lib/bundler/runtime.rb:68:in `block (2 levels) in require'
from /usr/local/ruby/lib/ruby/gems/1.9.1/gems/bundler-1.0.10/lib/bundler/runtime.rb:66:in `each'
from /usr/local/ruby/lib/ruby/gems/1.9.1/gems/bundler-1.0.10/lib/bundler/runtime.rb:66:in `block in require'
from /usr/local/ruby/lib/ruby/gems/1.9.1/gems/bundler-1.0.10/lib/bundler/runtime.rb:55:in `each'
from /usr/local/ruby/lib/ruby/gems/1.9.1/gems/bundler-1.0.10/lib/bundler/runtime.rb:55:in `require'
from /usr/local/ruby/lib/ruby/gems/1.9.1/gems/bundler-1.0.10/lib/bundler.rb:120:in `require'
from /Users/filzo/Documents/rails/blog/config/application.rb:7:in `'
from /usr/local/ruby/lib/ruby/gems/1.9.1/gems/railties-3.0.5/lib/rails/commands.rb:28:in `require'
from /usr/local/ruby/lib/ruby/gems/1.9.1/gems/railties-3.0.5/lib/rails/commands.rb:28:in `block in '
from /usr/local/ruby/lib/ruby/gems/1.9.1/gems/railties-3.0.5/lib/rails/commands.rb:27:in `tap'
from /usr/local/ruby/lib/ruby/gems/1.9.1/gems/railties-3.0.5/lib/rails/commands.rb:27:in `'
from script/rails:6:in `require'
from script/rails:6:in `'
I tried several possible solutions (e.g. this: http://railsforum.com/viewtopic.php?pid=23125#23125 with libmysqlclient.18.dylib); but nothing worked for me. I hope you can help me.
EDIT:
It seems like this fixed the problem for me:
sudo install_name_tool -change libmysqlclient.18.dylib /usr/local/mysql/lib/libmysqlclient.18.dylib /usr/local/ruby/lib/ruby/gems/1.9.1/gems/mysql2-0.2.6/lib/mysql2/mysql2.bundle
Anyway; is it a bug in the MySQL or the ruby-code?
One of the simple and best way is to create a soft link by command -
sudo ln -s /usr/local/mysql/lib/libmysqlclient.18.dylib /usr/lib/libmysqlclient.18.dylib
http://rorguide.blogspot.com/2011/07/getting-error-library-not-loaded.html
This appears to be a known (and unfixed!) bug in the MySQL binary distribution.
Whilst running install_name_tool on your mysql2.bundle files will work, if you remove and rebuild them you're back to square one. Also, you'll have to apply this fix to anything else that links against it. A better solution is to fix the problem in the library itself:
$ sudo install_name_tool -id \
/usr/local/mysql/lib/libmysqlclient.18.dylib \
/usr/local/mysql-5.5.12-osx10.6-x86_64/lib/libmysqlclient.18.dylib
Removing and rebuilding the mysql2 gem:
$ gem uninstall mysql2
$ gem install mysql2
...will pick up the change to the library, and everything should work correctly, without having to tinker with any environment variables.
If you are using RVM (an excellent choice) on Mac OS X - here is the magic command that finally worked for me.
sudo install_name_tool -change libmysqlclient.18.dylib /usr/local/mysql/lib/libmysqlclient.18.dylib /Users/*USERNAME*/.rvm/gems/ruby-1.9.2-p180/gems/mysql2-0.2.6/lib/mysql2/mysql2.bundle
Replace USERNAME in the syntax appropriately as per your current setup.
And if your version of mysql gem is different change that as well.
A better alternative to install_name tool is to add a path the the mysql lib to your DYLD_LIBRARY_PATH environment variable. In /etc/profile:
export DYLD_LIBRARY_PATH=/usr/local/mysql/lib
Or, as I have the Oracle Instant Client installed as well, do:
export ORACLE_HOME="/usr/local/oracle/instantclient_10_2"
export DYLD_LIBRARY_PATH=$ORACLE_HOME
export DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH:/usr/local/mysql/lib
Try to make this symbolic link, so rake can find the correct MySQL client lib.
ln -s /usr/local/mysql/lib/libmysqlclient.18.dylib /usr/lib/libmysqlclient.18.dylib
I'm not sure if this will help or not, but I'm using OS X 10.7.1 Lion. In my case, I opened a terminal window, went to /Library/Ruby/Gems/1.8/gems/mysql2-0.3.7 and as soon as I did RVM barked saying it encountered a new or modified .rvmrc file. The contents of that file was:
rvm use 1.9.2#mysql2 --create
It asked if I wanted to trust this .rvmc file. I said yes, and it returned the following:
Using /Users/dan/.rvm/gems/ruby-1.9.2-p290 with gemset mysql2
Once it did, I ran the following command:
sudo install_name_tool -change libmysqlclient.18.dylib /usr/local/mysql/lib/libmysqlclient.18.dylib /Library/Ruby/Gems/1.8/gems/mysql2-0.3.7/lib/mysql2/mysql2.bundle
Once I did, I was set to go. Hope this helps!

issue in installing mysql2 gem with rails3 on mac

Installing mysql2 (0.2.6) with native extensions /Library/Ruby/Site/1.8/rubygems/installer.rb:483:in `build_extensions': ERROR: Failed to build gem native extension. (Gem::Installer::ExtensionBuildError)
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby extconf.rb
mkmf.rb can't find header files for ruby at /System/Library/Frameworks/Ruby.framework /Versions/1.8/usr/lib/ruby/ruby.h
Gem files will remain installed in /Library/Ruby/Gems/1.8/gems/mysql2-0.2.6 for inspection.
Results logged to /Library/Ruby/Gems/1.8/gems/mysql2-0.2.6/ext/mysql2/gem_make.out
from /Library/Ruby/Site/1.8/rubygems/installer.rb:446:in `each'
from /Library/Ruby/Site/1.8/rubygems/installer.rb:446:in `build_extensions'
from /Library/Ruby/Site/1.8/rubygems/installer.rb:198:in `install'
from /Library/Ruby/Gems/1.8/gems/bundler-1.0.10/lib/bundler/source.rb:96:in `install'
from /Library/Ruby/Gems/1.8/gems/bundler-1.0.10/lib/bundler/installer.rb:55:in `run'
from /Library/Ruby/Gems/1.8/gems/bundler-1.0.10/lib/bundler/spec_set.rb:12:in `each'
from /Library/Ruby/Gems/1.8/gems/bundler-1.0.10/lib/bundler/spec_set.rb:12:in `each'
from /Library/Ruby/Gems/1.8/gems/bundler-1.0.10/lib/bundler/installer.rb:44:in `run'
from /Library/Ruby/Gems/1.8/gems/bundler-1.0.10/lib/bundler/installer.rb:8:in `install'
from /Library/Ruby/Gems/1.8/gems/bundler-1.0.10/lib/bundler/cli.rb:226:in `install'
from /Library/Ruby/Gems/1.8/gems/bundler-1.0.10/lib/bundler/vendor/thor/task.rb:22:in `send'
from /Library/Ruby/Gems/1.8/gems/bundler-1.0.10/lib/bundler/vendor/thor/task.rb:22:in `run'
from /Library/Ruby/Gems/1.8/gems/bundler-1.0.10/lib/bundler/vendor/thor/invocation.rb:118:in `invoke_task'
from /Library/Ruby/Gems/1.8/gems/bundler-1.0.10/lib/bundler/vendor/thor.rb:246:in `dispatch'
from /Library/Ruby/Gems/1.8/gems/bundler-1.0.10/lib/bundler/vendor/thor/base.rb:389:in `start'
from /Library/Ruby/Gems/1.8/gems/bundler-1.0.10/bin/bundle:13
from /usr/bin/bundle:19:in `load'
from /usr/bin/bundle:19
EDIT
Mohit-Jains-MacBook-Pro:casecreed mohit$ locate mysql_config
/Applications/XAMPP/xamppfiles/bin/mysql_config
/usr/local/mysql-5.5.9-osx10.6-x86_64/bin/mysql_config
/usr/local/mysql-5.5.9-osx10.6-x86_64/man/man1/mysql_config.1
and after doing what u suggested...
ie
sudo gem install mysql2 -- –with-mysql-config=/usr/local/mysql-5.5.9-osx10.6-x86_64/bin/mysql_config
here is the error..
Mohit-Jains-MacBook-Pro:casecreed mohit$ rake db:create
(in /Users/mohit/projects/casecreed)
rake aborted!
dlopen(/Library/Ruby/Gems/1.8/gems/mysql2-0.2.6/lib/mysql2/mysql2.bundle, 9): Library not loaded: libmysqlclient.16.dylib
Referenced from: /Library/Ruby/Gems/1.8/gems/mysql2-0.2.6/lib/mysql2/mysql2.bundle
Reason: image not found - /Library/Ruby/Gems/1.8/gems/mysql2-0.2.6/lib/mysql2/mysql2.bundle
/Users/mohit/projects/casecreed/Rakefile:4
(See full trace by running task with --trace
EDIT2
screenshot of whole process after answer was modified..
Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
Couldn't create database for {"reconnect"=>false, "encoding"=>"utf8", "username"=>"root", "adapter"=>"mysql2", "database"=>"the_casecreed_test", "host"=>"localhost", "pool"=>5, "password"=>nil}, charset: utf8, collation: utf8_unicode_ci
Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
Couldn't create database for {"reconnect"=>false, "encoding"=>"utf8", "username"=>"root", "adapter"=>"mysql2", "database"=>"the_casecreed_development", "host"=>"localhost", "pool"=>5, "password"=>nil}, charset: utf8, collation: utf8_unicode_ci
EDIT3
development.yml
EDIT4
Even not able to connect to mysql.
Check this screenshot.
EDIT5
This is the solution but i am not able to understand, why mysql server was not starting..
Screenshot
Try the following, which seems to have worked for others:
From the Terminal, run locate mysql_config and identify the path to the mysql_config binary
Use that path in the following command to install the gem:sudo gem install mysql2 -- –with-mysql-config=/path/you/identified/above/mysql_config
[Edit]
In response to the new error, e.g.:
Mohit-Jains-MacBook-Pro:casecreed mohit$ rake db:create
(in /Users/mohit/projects/casecreed)
rake aborted!
dlopen(/Library/Ruby/Gems/1.8/gems/mysql2-0.2.6/lib/mysql2/mysql2.bundle, 9): Library not loaded: libmysqlclient.16.dylib
Referenced from: /Library/Ruby/Gems/1.8/gems/mysql2-0.2.6/lib/mysql2/mysql2.bundle
Reason: image not found - /Library/Ruby/Gems/1.8/gems/mysql2-0.2.6/lib/mysql2/mysql2.bundle
/Users/mohit/projects/casecreed/Rakefile:4
(See full trace by running task with --trace
I believe this is due to mysql2 not using the full path to libmysqlclient.16.dylib. Others have had luck with:
sudo install_name_tool -change libmysqlclient.16.dylib /usr/local/mysql/lib/libmysqlclient.16.dylib /Library/Ruby/Gems/1.8/gems/mysql2-0.2.6/lib/mysql2/mysql2.bundle
However, be sure to replace /usr/local/mysql/lib/libmysqlclient.16.dylib with the path to your own libmysqlclient.16.dylib. I'm not positive what it would be, but you may be able to find it with locate (if not, check around in the lib directory for /usr/local/mysql-5.5.9-osx10.6-x86_64).
download 64 bit from here and then try to install mysql2 gem
http://dev.mysql.com/downloads/mysql/
it will work..
Try installing mysql from macports
sudo ports install mysql5
It took ages to complete, but once done run
gem install mysql2
and everything should work just fine