Error when trying to install mysql support for rails - mysql

Ruby version : 1.8.7 (2013-06-27 patchlevel 374) [x86_64-linux]
Rails version : 2.3.5
OS: Cloud Linux 64 bit
I am trying to install mysql gem inorder to get support rails, the command is as follows,
gem install mysql -- --with-mysql-config=/usr/lib64/mysql/mysql_config
am getting the following error,
Building native extensions. This could take a while...
ERROR: Error installing mysql:
ERROR: Failed to build gem native extension.
/usr/local/rvm/rubies/ruby-1.8.7-p374/bin/ruby extconf.rb --with-mysql- config=/usr/lib64/mysql/mysql_config
extconf.rb:5: command not found: /usr/lib64/mysql/mysql_config --cflags
*** 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/local/rvm/rubies/ruby-1.8.7-p374/bin/ruby
--with-mysql-config
Gem files will remain installed in /usr/local/rvm/gems/ruby-1.8.7-p374/gems/mysql-2.9.1 for inspection.
Results logged to /usr/local/rvm/gems/ruby-1.8.7-p374/gems/mysql-2.9.1/ext/mysql_api/gem_make.out
I even tried looking for mkmf.log, but cannot find it.
I am trying to implement a RoR project, which already ran in Cent OS 5.9 64bit. This RoR is designed to be run in the above versions of Ruby & Rails, upgrading will create issues. Please help and direct me.

Seems like you are missing dev parts of libraries.
Do you have libmysqlclient installed?
What is the output of the locate command for the config file?
locate mysql_config

Related

Ruby On Rails, MySQL windows 8.1 64bit mysql gem frustrating

(as an aside its telling me I have code in here and have to format it as such, so if anything looks strange its because it wouldn't let me post it otherwise.)
I've actually reinstalled windows 8 three times in the last two days and actually created a dual boot with Ubuntu with how frustrating this problem has been. (decided learning a whole new operating system was more annoying then trying to fix the windows problem)
So, i'm new to coding in general, but I've been fooling around with ruby and rails and decided to try and get the database stuff working and every time I run into the same sorts of problems, this seems to be some sort of windows 64 bit MySQL ruby version confusion.
I'm using windows 6.1 64 with ruby 2.0.0p353 (2013-11-22) [x64-mingw32] rails 4.0.2 with MySQL 5.6
I've installed the devkit and did the test using ruby -rubygems -e "require 'json'; puts JSON.load('[42]').inspect" and it returned 42 and that whole installation seemed to go fine.
rails installed ruby installed, all -v showing the version I listed.
now when I go to install MySQL gem it gives me this.
Temporarily enhancing PATH to include DevKit...
Building native extensions. This could take a while...
ERROR: Error installing mysql:
ERROR: Failed to build gem native extension.
C:/Ruby200-x64/bin/ruby.exe extconf.rb
checking for main() in -llibmysql... 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.
I read up and tried doing this after installing the MySQL c connector. And it returns as follows.
C:\Users\ryan>gem install mysql2 --platform=ruby -- '--with-mysql-dir="C:/mysql-
connector-c-6.1.3-win32/"'
Temporarily enhancing PATH to include DevKit...
Building native extensions with: '--with-mysql-dir="C:/mysql-connector-c-6.1.3-w
in32/"'
This could take a while...
ERROR: Error installing mysql2:
ERROR: Failed to build gem native extension.
C:/Ruby200-x64/bin/ruby.exe extconf.rb --with-mysql-dir="C:/mysql-connector-
c-6.1.3-win32/"
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
-----
Cannot find include dir at C:/mysql-connector-c-6.1.3-win32//include
-----
*** 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.
I have devoted days to this problem, and reinstalled more things than I care to admit. Does anyone have any ideas how I could possibly fix this... ?
ok this is what its spitting out now..
C:\Users\ryan>gem install mysql --platform=ruby -- --with-mysql-dir=c:\mysql-con
nector-c-6.1.3-win32
Temporarily enhancing PATH to include DevKit...
Building native extensions with: '--with-mysql-dir=c:\mysql-connector-c-6.1.3-wi
n32'
This could take a while...
ERROR: Error installing mysql:
ERROR: Failed to build gem native extension.
C:/Ruby200-x64/bin/ruby.exe extconf.rb --with-mysql-dir=c:\mysql-connector-c
-6.1.3-win32
checking for main() in -llibmysql... 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=C:/Ruby200-x64/bin/ruby
--with-mysql-dir
--with-mysql-include
--without-mysql-include=${mysql-dir}/include
--with-mysql-lib
--without-mysql-lib=${mysql-dir}/
--with-libmysqllib
--without-libmysqllib
Gem files will remain installed in C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/mysql
-2.9.1 for inspection.
Results logged to C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/mysql-2.9.1/ext/mysql_
api/gem_make.out
gave up and installed windows 7 32 bit on a second harddrive and just use that for rails stuff.
Set that up using an amazing video on youtube I randomly found, but it worked perfectly.
https://www.youtube.com/watch?feature=player_embedded&v=-eFwV8lRu1w
no joke I was close to giving up! It seems like lots of rails problems are oriented around 64 bit windows anyway, but 8.1 can't be helping anything.
It's almost a silly answer to say just give up, and i'm sure its possible to get the most recent version of rails and ruby working on windows 8.1 64 right at this moment, but I think with the effort required it is actually easier for a new person to just install a 32 bit version of, preferably, an earlier version of windows.
I had faced same issue.
You can find solution here.
http://blog.mmediasys.com/2011/07/07/installing-mysql-on-windows-7-x64-and-using-ruby-with-it/
Here in the blog a invalid path for mysql-connector-c-noinstall-6.0.2-win32
gem install mysql --platform=ruby -- --with-mysql-dir=C:/mysql-connector-c-noinstall-6.0.2-win32
So for this you have to check your folder structure for mysql-connector then use it.
Thanks

Install gem mysql2 with lampp

I'm trying to get gem running with apache server installed in /opt (LAMPP bundle).
There was an error when I tried to install mysql2 gem. After searching I did following:
aptitude install libmysql-ruby libmysqlclient-dev ruby-dev
And then:
gem install mysql2 -- --with-mysql-config=/opt/lampp/bin/mysql_config --with-mysql-dir=/opt/lampp/lib/mysql --with-mysql-lib=/opt/lampp/lib/mysql/ --with-mysql-include=/usr/include/mysql
Here's the response:
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.h... no
checking for mysql/mysql.h... yes
checking for errmsg.h... no
-----
errmsg.h is missing. please check your installation of mysql 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/ruby1.9.1
--with-mysql-config
Gem files will remain installed in /var/lib/gems/1.9.1/gems/mysql2-0.3.13 for inspection.
Results logged to /var/lib/gems/1.9.1/gems/mysql2-0.3.13/ext/mysql2/gem_make.out
So, the trouble is errmsg.h library. After installing dev packages ruby found few other missing libraries, e.g. 'mysql.h', but not this one. I have no idea what to do now... I saw many anwers for similar questions here, but none of them was helpful.
Any help will be appreciated.
I finally gave up. Lampp is good for start, but now I need many things that are not bundled and installing them is more and more complicated. I moved everything to virtual machine and it works flawless.
well I know it's quite a long time ago... but I had the same trouble nowadays. you just had do use the include folder of lampp nativly to find all needed dependencies.
so the wording would look like
gem install mysql2 -- --with-mysql-config=/opt/lampp/bin/mysql_config --with-mysql-dir=/opt/lampp/mysql --with-mysql-lib=/opt/lampp/lib/mysql/ --with-mysql-include=/opt/lampp/include/

Error While Installing MYSQL Gems in Ruby

I just need a big help while i was facing this for past 3 months.
I am using windows 8 machine.
I was trying to install ruby in rails.Everything got success.
but while installing mysql gem i can face many errors which i have copied and pasted below
C:\Users\Mounarajan P A>gem install mysql
Temporarily enhancing PATH to include DevKit...
Building native extensions. This could take a while...
ERROR: Error installing mysql:
ERROR: Failed to build gem native extension.
C:/Ruby200-x64/bin/ruby.exe extconf.rb
checking for main() in -llibmysql... 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=C:/Ruby200-x64/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-libmysqllib
--without-libmysqllib
Gem files will remain installed in C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/mysql
-2.9.1 for inspection.
Results logged to C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/mysql-2.9.1/ext/mysql_
api/gem_make.out
Actually we should have the native development libraries when installing native extensions. For ubuntu it is libmysql2-dev, the same way find what is the dev lib for windows and install it. That could be solve your problem
Do you mean to use the mysql gem? I thought mysql2 is now the standard/recommended gem to use with mysql databases.
Anyhow, this link might help you to get it installed:
Unable to install mysql2 gem on windows 7

MySQL bundle install

I have looked through multiple questions on stackoverflow and they all gave different solutions to the problem. I git cloned a rails project, ran bundle install, and created a new gemset in rvm using 1.9.3 ruby and figured rails 3.2.13 will also get installed with the bundle install command. In the past I solved this issue by using this guide, http://www.randomactsofsentience.com/2013/05/gem-install-mysql2-missing-mysqlh-on-os.html. I couldn't find mysql folder in user/local, the guide said I need to edit a file and get rid of somelines to resolve the mysql.h missing issue. This file no longer exist? I couldn't find it? maybe I am missing dependencies but I found linux installation ways of these dependencies? maybe I need to install mysql5.5 instead of the latest version but not sure how to specify that? which one of these will solve this for me?
Installing mysql2 (0.3.11)
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.
/Users/judyngai/.rvm/rubies/ruby-1.9.3-p429/bin/ruby extconf.rb
checking for rb_thread_blocking_region()... yes
checking for rb_wait_for_single_fd()... yes
checking for mysql.h... no
checking for mysql/mysql.h... no
-----
mysql.h is missing. please check your installation of mysql 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
--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/judyngai/.rvm/rubies/ruby-1.9.3-p429/bin/ruby
--with-mysql-config
--without-mysql-config
Gem files will remain installed in /Users/judyngai/.rvm/gems/ruby-1.9.3-p429#spreeversion /gems/mysql2-0.3.11 for inspection.
Results logged to /Users/judyngai/.rvm/gems/ruby-1.9.3-p429#spreeversion/gems/mysql2-0.3.11/ext/mysql2/gem_make.out
An error occurred while installing mysql2 (0.3.11), and Bundler cannot continue.
Make sure that `gem install mysql2 -v '0.3.11'` succeeds before bundling.
You need to set up mysql development headers (thus, .h file extension) first before bundle / gem can build your native mysql extension. Which OS are you on? So I can extend my answer...
E.g. on debian, it would be: apt-get install libmysqlclient-dev (on other systems, it might be named different, like mysql-devel). If you're on OSX, there's that very informative answer on bundle install problem: mysql.h is missing that might help you. And for windows, this might help: Missing mysql.h and trying to find mysql-devel.

gem update mysql2 failed with rails 3.1.0 and win7 [duplicate]

I have the Ruby version ruby 1.9.2p0 (2010-08-18) [i386-mingw32] installed in Windows7.
and the gem vesion 1.3.7
When i tried to install mysql gem, it is showing Failed to build gem native extension error, why is this? my mysql version is 5.1.36(WampServer)
E:\RubyApps\test_app2>gem install mysql2
Building native extensions. This could take a while...
ERROR: Error installing mysql2:
ERROR: Failed to build gem native extension.
E:/Ruby192/bin/ruby.exe extconf.rb
checking for rb_thread_blocking_region()... *** 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=E:/Ruby192/bin/ruby
E:/Ruby192/lib/ruby/1.9.1/mkmf.rb:368:in `try_do': The complier failed to genera
te an executable file. (RuntimeError)
You have to install development tools first.
from E:/Ruby192/lib/ruby/1.9.1/mkmf.rb:435:in `try_link0'
from E:/Ruby192/lib/ruby/1.9.1/mkmf.rb:440:in `try_link'
from E:/Ruby192/lib/ruby/1.9.1/mkmf.rb:552:in `try_func'
from E:/Ruby192/lib/ruby/1.9.1/mkmf.rb:797:in `block in have_func'
from E:/Ruby192/lib/ruby/1.9.1/mkmf.rb:693:in `block in checking_for'
from E:/Ruby192/lib/ruby/1.9.1/mkmf.rb:280:in `block (2 levels) in postp
one'
from E:/Ruby192/lib/ruby/1.9.1/mkmf.rb:254:in `open'
from E:/Ruby192/lib/ruby/1.9.1/mkmf.rb:280:in `block in postpone'
from E:/Ruby192/lib/ruby/1.9.1/mkmf.rb:254:in `open'
from E:/Ruby192/lib/ruby/1.9.1/mkmf.rb:276:in `postpone'
from E:/Ruby192/lib/ruby/1.9.1/mkmf.rb:692:in `checking_for'
from E:/Ruby192/lib/ruby/1.9.1/mkmf.rb:796:in `have_func'
from extconf.rb:9:in `<main>'
Gem files will remain installed in E:/Ruby192/lib/ruby/gems/1.9.1/gems/mysql2-0.
2.3 for inspection.
Results logged to E:/Ruby192/lib/ruby/gems/1.9.1/gems/mysql2-0.2.3/ext/mysql2/ge
m_make.out
E:\RubyApps\test_app2>
If you are having this same problem in Linux, basically you just need to install a few libraries first. This worked for me.
> sudo apt-get install libmysql-ruby libmysqlclient-dev
> gem install mysql
source: http://heatware.net/ruby-rails/solved-installing-mysql-gem-extconf-rb-failed-error/
Since this keeps coming up on google as on of the top results, I should point out that this answers is from almost 2 years ago. Here is a more updated answer: How to use "mysql2" gem in Rails 3 application on Windows 7?
According to the developer there is a already a reported bug for it and he is working on parting mysql2 over to Windows. As of now - it's still in the works. Use the older mysql driver for now - or use sqlite for local development.
This is from the googlegroups discussion
Blockquote
Hey Erwann,
There's a ticket on the mysql2 issue tracker for Win32 support already
at http://github.com/brianmario/mysql2/issues#issue/8 . You can follow
it for progress; I'm doing my best to get things working smoothly for
you guys. Hang tight! :)
Just for the record: The problem should be solved!
The mysql2 gem v.0.2.6 is out, having win32 support.
gem install mysql2 worked without problems now.
See: http://github.com/brianmario/mysql2/issues/issue/8#issue/8/comment/479748
it works,
c:> gem install mysql2 -- '--with-mysql-lib="C:\Prog
ram Files\MySQL\MySQL Connector C 6.0.2\lib\opt" --with-mysql-include="C:\Progra
m Files\MySQL\MySQL Connector C 6.0.2\include"'
Temporarily enhancing PATH to include DevKit...
Building native extensions. This could take a while...
Successfully installed mysql2-0.3.6
1 gem installed
Installing ri documentation for mysql2-0.3.6...
Enclosing class/module 'mMysql2' for class Client not known
Installing RDoc documentation for mysql2-0.3.6...
Enclosing class/module 'mMysql2' for class Client not known
Note:
I. If there is no lib and include directory in your mysql then install mysql connector c
II. First install DevKit then only you can install mysql2 plugin in windows
https://github.com/oneclick/rubyinstaller/wiki/Development-Kit
You can try
gem install mysql2 -v '0.0.00' -- --with-ldflags=-L/usr/local/opt/openssl/lib --with-cppflags=-I/usr/local/opt/openssl/include
Have you installed the DevKit correctly? If doubt, cross check the steps of installation on -
http://rorguide.blogspot.com/2011/03/installing-mysql2-gem-on-ruby-192-and.html
I was able to install mysql2 gem after following these steps.
Under Cygwin, I had to be sure to install not just libmysqlclient18, but also libmysqlclient-devel. Then "gem install mysql2" went fine.
There is also, of course, a ruby-mysql2 package in Cygwin.
key: the line that says You have to install development tools first.
ref: devkit
use
gem install mysql
for windows, till mysql2 get it right.