Create an account

Very important

  • To access the important data of the forums, you must be active in each forum and especially in the leaks and database leaks section, send data and after sending the data and activity, data and important content will be opened and visible for you.
  • You will only see chat messages from people who are at or below your level.
  • More than 500,000 database leaks and millions of account leaks are waiting for you, so access and view with more activity.
  • Many important data are inactive and inaccessible for you, so open them with activity. (This will be done automatically)


Thread Rating:
  • 700 Vote(s) - 3.55 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Error installing mysql2: Failed to build gem native extension

#1
I am having some problems when trying to install `mysql2` gem for Rails. When I try to install it by running `bundle install` or `gem install mysql2` it gives me the following error:

> Error installing mysql2: ERROR: Failed to build gem native extension.

How can I fix this and successfully install `mysql2`?
Reply

#2
Have you tried using

gem install mysql -- --with-mysql-lib=/usr/lib/mysql/lib

to specify the location of thebase directory as well as the path to the MySQL libraries that are necessary to complete the gem installation?

Sources:
[MySQL Gem Install ERROR: Failed to build gem native extension][1]
[MySQL Forums :: Ruby :: Help needed with installing MySQL binding for Ruby][2]


[1]:

[To see links please register here]

[2]:

[To see links please register here]

Reply

#3
I got this error too. Solved by installing development packages. I'm using arch and it was:

sudo pacman -S base-devel

which installed:

m4, autoconf, automake, bison, fakeroot, flex, libmpc, ppl, cloog-ppl, elfutils, gcc,
libtool, make, patch, pkg-config

but I think it actually needed make and gcc. Error output said (on my machine, among other):

"You have to install development tools first."

So it was an obvious decision and it helped.
Reply

#4
I was running into this error on my mac and found that I needed to upgrade from mysql 32bit to mysql 64 bit to get this error to go away. I was running OSX 10.6 on an intel macbook pro with ruby 1.9.2 and rails3.0.0

I also needed to install xcode in order to get unix utilities like "make" that are required to compile the gem.

once this was done I was able to run gem install mysql and gem install mysql2 without error.
Reply

#5
I got the gem built on Mac OS X 10.6.6 by
1) Ensuring the Developer tools package is installed
2) Downloading the current MySQL package (5.5.8 in my case) from Source
3) Installing the cmake tool from cmake.org
4) Following the instructions in section 2.11 of INSTALL-SOURCE from the mysql distribution files
5) `sudo gem install mysql2 -- --srcdir=/usr/local/mysql/include`
The gem built successfully, but there are two errors in the documentation that rdoc and ri complain about.
But now when I try to require 'mysql2' I get a

LoadError: no such file to load -- mysql2/mysql2

I was hoping the error I would get was that the libmysqlclient.16.dylib couldn't be found because we figured that out in another post (search for install_name_tool).

My $PATH has /usr/local/mysql in it (that's where my source and built files are located), so I'm a little stumped. If anyone has any thoughts, I'll check back after a few hours of sleep.
Reply

#6
If still getting error then follow the steps of mysql2 gem installation on Rails 3 on -

[To see links please register here]


where most of the user were able to install mysql2 gem.
Reply

#7
This solved my problem once in Windows:

subst X: "C:\Program files\MySQL\MySQL Server 5.5"
gem install mysql2 -v 0.x.x --platform=ruby -- --with-mysql-dir=X: --with-mysql-lib=X:\lib\opt
subst X: /D
Reply

#8
After you get the mysql-dev issues corrected, you may need to remove the bad mysql2 install. Look carefully at the messages after $ bundle install. You may need to

rm -rf vendor/cache/
rm -rf ./Zentest

This will clear out the bad mysql2 installation so that a final $ bundle install can create a good one.
Reply

#9
*here is a solution for the **windows users**, hope it helps!*

<h2>Using MySQL with Rails 3 on Windows</h2>

- **Install railsinstaller** -> *www.railsinstaller.org* (I installed it to c:\Rails)

- **Install MySQL** (I used MySQL 5.5) -> *dev.mysql.com/downloads/installer/*

> **--- for mySQL installation ---**
<br /><br /> If you dont already have **these two files** installed you might need them to get your MySQL going<br /><br />
vcredist_x86.exe ->

[To see links please register here]

dotNetFx40_Full_x86_x64.exe ->

[To see links please register here]

<br /><br />
Use default install
Developer Machine

> **-MySQL Server Config-**<br />
port: 3306<br />
windows service name: MySQL55<br />
mysql root pass: root (you can change this later)<br />
(username: root)<br />
**-MySQL Server Config-**

> **--- for mySQL installation ---**

<br />

> **--- Install the mysql2 Gem ---**<br /><br />
Important: **Do this with Git Bash Command Line**(this was installed with railsinstaller) -> start/Git Bash<br /><br />
<i>**gem install mysql2 -- '--with-mysql-lib="c:\Program Files\MySQL\MySQL Server 5.5\lib" --with-mysql-include="c:\Program Files\MySQL\MySQL Server 5.5\include"'**</i>
<br />
Now the gem should have installed correctly
<br />
Lastly copy the libmysql.dll file from<br />
C:\Program Files\MySQL\MySQL Server 5.5\lib<br />
to<br />
C:\Rails\Ruby1.9.2\bin<br /><br />
**--- Install the mysql2 Gem ---**

<br />
*You will now be able to use your Rails app with MySQL, if you are not sure how to create a Rails 3 app with MySQL read on...*
<hr />

**--- Get a Rails 3 app going with MySQL ---**<br /><br />
Open command prompt(not Git Bash) -> start/cmd<br />
Navigate to your <Sites> folder (c:\Sites)<br />
Create new rails app<br />

rails new world

Delete the file c:\Sites\world\public\index.html<br />
Edit the file c:\Sites\world\config\routes.rb<br />
add this line -> root :to => 'cities#index'<br /><br />

Open command prompt (generate views and controllers)<br />

rails generate scaffold city ID:integer Name:string CountryCode:string District:string Population:integer
<br />
Edit the file c:\Sites\world\app\models\city.rb to look like this

class City < ActiveRecord::Base
set_table_name "city"
end


Edit the file c:\Sites\world\config\database.yml to look like this

development:
adapter: mysql2
encoding: utf8
database: world
pool: 5
username: root
password: root
socket: /tmp/mysql.sock

add to gemfile

gem 'mysql2'

Open **command prompt** windows cmd, not Git Bash(run your app!)<br />
Navigate to your app folder (c:\Sites\world)<br />

rails s

Open your browser here -> *http://localhost:3000*


**--- Get a Rails 3 app going with MySQL ---**
Reply

#10
download the right version of mysqllib.dll then copy it to ruby bin really works for me. Follow this link plases [

[To see links please register here]

][1]


[1]:

[To see links please register here]

Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

©0Day  2016 - 2023 | All Rights Reserved.  Made with    for the community. Connected through