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

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.

Related

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.

Finally installed MySQL for Rails in Windows 64 bit, and now

Environment:
Windows 7 64bit (Home Premium)
Ruby 1.9.2 p290 (2011-07-09) [i386-mingw32]
Rails 3.0.10
MySQL 5.5
Ruby, despite my having successfully installed the mysql2 rubygem thinks that the gem is missing when I invoke a rails command that requires it.
After having spent the evening getting the mysql rubygem installed on Windows 64 bit, I decided to (finally) get cracking on linking mysql to a local rails server. This is how I was trying to do it...
(Fairly) Exact transcript from cmd.exe
C:\rails\cookbook>gem install mysql --platform=ruby -- --with-mysql-include=c:\mysql\include --with-mysql-lib=c:\mysql\lib
Temporarily enhancing PATH to include DevKit...
Building native extensions. This could take a while...
Successfully installed mysql-2.8.1
1 gem installed
Installing ri documentation for mysql-2.8.1...
Installing RDoc documentation for mysql-2.8.1...
(I thought this was successful mysql install, should I test it somehow?)
C:\>gem install mysql2 --platform=ruby -- --with-mysql-include=c:\mysql\include --with-mysql-lib=c:\mysql\lib
Fetching: mysql2-0.3.7.gem (100%)
Temporarily enhancing PATH to include DevKit...
Building native extensions. This could take a while...
Successfully installed mysql2-0.3.7
1 gem installed
Installing ri documentation for mysql2-0.3.7...
Enclosing class/module 'mMysql2' for class Client not known
Installing RDoc documentation for mysql2-0.3.7...
Enclosing class/module 'mMysql2' for class Client not known
(Same as above - I thought this was successful mysql install)
C:\rails>rails new cookbook -d mysql
(successfully creates directories for project in c:\rails\cookbook)
C:\rails\cookbook>rails server
?[31mCould not find gem 'mysql2 (~> 0.2.11)' in any of the gem sources listed in your Gemfile.?[0m
?[33mRun `bundle install` to install missing gems.?[0m
Notes:
I noticed it wants rubygem mysql2-0.2.11, I have 0.3.7. I tried installing 0.2.11 specifically by the method I used to install the two gems above. No dice, it couldn't find a gem by the name mysql2-0.2.11 in 'any repository'
I'm stumped, any thoughts fellas (and gals)?
I believe your MySQL installation is a 64bits (like Windows), correct?
Ruby is 32bits, so you cannot link 32bits against 64bits.
I've posted a article covering the installation steps on my blog:
http://blog.mmediasys.com/2011/07/07/installing-mysql-on-windows-7-x64-and-using-ruby-with-it/
These steps use MySQL Connector/C to workaround the 32bits versus 64bits issues.
Both mysql or mysql2 gem should work with this.
Have you included mysql2 in your Gemfile and subsequently executed bundle install ?
## my sql installation (on 64 bit architecture)
download connector (download zip file and extract it to c drive)
http://dev.mysql.com/downloads/connector/c/
download mysql
http://dev.mysql.com/downloads/installer/5.6.html
command to install mysql with connector
C:\Sites\rails_project\resume>gem install mysql --platform=ruby -- --with-mysql-
dir=C:/mysql-connector-c-6.1.0-win32
After this copy libmysql.dll from connector folder and paste it to ruby>bin folder

How to install gem MySQL on Mac OS 10.6.6

Ruby already installed on Mac. So i just installed rails.
ruby 1.8.7 (2009-06-12 patchlevel 174) [universal-darwin10.0]
rails 2.3.11
gem 1.3.5
When i trying : gem install mysql i get this error:
89-235-235-64:~ vitali$ gem install mysql
WARNING: Installing to ~/.gem since /Library/Ruby/Gems/1.8 and
/usr/bin aren't both writable.
WARNING: You don't have /Users/vitali/.gem/ruby/1.8/bin in your PATH,
gem executables will not run.
Building native extensions. This could take a while...
ERROR: Error installing mysql:
ERROR: Failed to build gem native extension.
/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 /Users/vitali/.gem/ruby/1.8/gems/mysql-2.8.1 for inspection.
Results logged to /Users/vitali/.gem/ruby/1.8/gems/mysql-2.8.1/ext/mysql_api/gem_make.out
89-235-235-64:~ vitali$
Dont understand what to do. gem install mysql installing without MySQl itself or I should download and install MySQL as prorgamm? If yes, from what resource, what version, how to instal? Please help me, im newbie on mac. Big thanks!
You're almost certainly going to need MySQL installed to have the MySQL gem installed (even better is the mysql2 gem, which Rails also works with - just use mysql2 instead of mysql in your database.yml file).
I find the best way to get MySQL on my Mac whenever I format it (which, admittedly, is rarely) is to use Homebrew. So, if you don't have Homebrew installed, I'd start with that... and once that's done, it should be a matter of running sudo brew install mysql, and running the instructions it provides after the installation is done.

Installing datamapper mysql dm-mysql-adapter on redhat

I'm trying to move a small Sinatra app I have going on an Ubuntu box to a redhat box.
While installing gems, I get a "Can't build native extension" error while trying to install the gem dm-mysql-adapter.
I have mysql-devel installed, which I believe is the required library, but it doesn't seem to work.
All the info I can find online is for Ubuntu and says installing libmysqlclient-dev (which doesn't exist for Redhat; again, I believe mysql-devel is the appropriate package).
Any advice for someone using redhat?
you have the correct package "mysql-devel-5.1.48-1" but the gem installs fine on my centos5 box without the package installed, you could try the ruby-mysql gem instead.
[11:13:01][root#HOST:~]# gem search mysql
*** LOCAL GEMS ***
[11:13:03][root#HOST:~]# rpm -qa | grep -i mysql
perl-DBD-MySQL-3.0007-2.el5
mysql-5.0.77-4.el5_5.4
[11:13:11][root#HOST:~]# gem install mysql
Building native extensions. This could take a while...
Successfully installed mysql-2.8.1
1 gem installed
Installing ri documentation for mysql-2.8.1...
...
[11:13:22][root#HOST:~]#

problem installing ruby-debug-ide gem with jruby 1.4.0

I tried to follow the UsingTheJRubyDebugger instructions on the jruby wiki. (kenai.com/projects/jruby/pages/UsingTheJRubyDebugger). I got an error trying to install the ruby-debug-ide gem.
jruby -S gem install --ignore-dependencies ruby-debug-ide
JRuby limited openssl loaded. gem install jruby-openssl for full support.
http://jruby.kenai.com/pages/JRuby_Builtin_OpenSSL
Building native extensions. This could take a while...
rake aborted!
Don't know how to build task '2>&1'
(See full trace by running task with --trace)
ERROR: Error installing ruby-debug-ide:
ERROR: Failed to build gem native extension.
I'm using Vista. Has anybody gotten this to work? Any help would be greatly appreciated.
hhh
JRuby does not support native extensions. A related stackoverflow question is here.
Second try:
There is bug report and a workaroud: set rake=jruby -S rake.