Install mysql2 gem in Ubuntu 11.10 with RVM

I’m trying to get this gem installed and it keeps puking up errors. All
the searches I’ve done tell me that I need to have the
libmysqlclient-dev libraries installed. I do. But when I attempt to gem
install mysql2:

jim@caesar ~/Sites/igpt/install/shapefiles[testoo*]$ gem install mysql2
– --with-mysql-config=/usr/bin/mysql_config
Building native extensions. This could take a while…
ERROR: Error installing mysql2:
ERROR: Failed to build gem native extension.

    /home/jim/.rvm/rubies/ruby-1.8.7-p334/bin/ruby extconf.rb

–with-mysql-config=/usr/bin/mysql_config
checking for rb_thread_blocking_region()… no
checking for rb_wait_for_single_fd()… no
checking for mysql.h… yes
checking for errmsg.h… yes
checking for mysqld_error.h… yes
creating Makefile

make
gcc -I. -I.
-I/home/jim/.rvm/rubies/ruby-1.8.7-p334/lib/ruby/1.8/i686-linux -I.
-DHAVE_MYSQL_H -DHAVE_ERRMSG_H -DHAVE_MYSQLD_ERROR_H
-D_FILE_OFFSET_BITS=64 -I/usr/include/mysql -DBIG_JOINS=1
-fno-strict-aliasing -DUNIV_LINUX -DUNIV_LINUX -fPIC -g -O2 -fPIC
-Wall -funroll-loops -c result.c
result.c: In function ‘rb_mysql_result_fetch_row’:
result.c:258:31: warning: variable ‘tokens’ set but not used
[-Wunused-but-set-variable]
result.c:272:58: warning: variable ‘tokens’ set but not used
[-Wunused-but-set-variable]
result.c:315:33: warning: variable ‘tokens’ set but not used
[-Wunused-but-set-variable]
gcc -I. -I.
-I/home/jim/.rvm/rubies/ruby-1.8.7-p334/lib/ruby/1.8/i686-linux -I.
-DHAVE_MYSQL_H -DHAVE_ERRMSG_H -DHAVE_MYSQLD_ERROR_H
-D_FILE_OFFSET_BITS=64 -I/usr/include/mysql -DBIG_JOINS=1
-fno-strict-aliasing -DUNIV_LINUX -DUNIV_LINUX -fPIC -g -O2 -fPIC
-Wall -funroll-loops -c mysql2_ext.c
./client.h:16:1: warning: ‘rb_thread_blocking_region’ defined but not
used [-Wunused-function]
gcc -I. -I.
-I/home/jim/.rvm/rubies/ruby-1.8.7-p334/lib/ruby/1.8/i686-linux -I.
-DHAVE_MYSQL_H -DHAVE_ERRMSG_H -DHAVE_MYSQLD_ERROR_H
-D_FILE_OFFSET_BITS=64 -I/usr/include/mysql -DBIG_JOINS=1
-fno-strict-aliasing -DUNIV_LINUX -DUNIV_LINUX -fPIC -g -O2 -fPIC
-Wall -funroll-loops -c client.c
client.c: In function ‘rb_mysql_client_info’:
client.c:539:3: warning: variable ‘wrapper’ set but not used
[-Wunused-but-set-variable]
gcc -shared -o mysql2.so result.o mysql2_ext.o client.o -L.
-L/home/jim/.rvm/rubies/ruby-1.8.7-p334/lib
-Wl,-R/home/jim/.rvm/rubies/ruby-1.8.7-p334/lib -L. -rdynamic
-Wl,-export-dynamic -Wl,-rpath,/usr/lib/mysql -Wl,-R
-Wl,/home/jim/.rvm/rubies/ruby-1.8.7-p334/lib
-L/home/jim/.rvm/rubies/ruby-1.8.7-p334/lib -lruby
-Wl,-Bsymbolic-functions -rdynamic -L/usr/lib/mysql -lmysqlclient_r
-lrt -ldl -lcrypt -lm -lc
/usr/bin/ld: skipping incompatible
/home/jim/.rvm/rubies/ruby-1.8.7-p334/lib/libruby.so when searching for
-lruby
/usr/bin/ld: skipping incompatible
/home/jim/.rvm/rubies/ruby-1.8.7-p334/lib/libruby.so when searching for
-lruby
/usr/bin/ld: cannot find -lruby
collect2: ld returned 1 exit status
make: *** [mysql2.so] Error 1

Gem files will remain installed in
/home/jim/.rvm/gems/ruby-1.8.7-p334@rails307/gems/mysql2-0.3.11 for
inspection.
Results logged to
/home/jim/.rvm/gems/ruby-1.8.7-p334@rails307/gems/mysql2-0.3.11/ext/mysql2/gem_make.out

It just crashes out.

Any ideas from that error?

-Jim

On Wed, Jan 25, 2012 at 7:36 PM, Jim W.
[email protected]wrote:

gcc -I. -I.
result.c:315:33: warning: variable ‘tokens’ set but not used
-I/home/jim/.rvm/rubies/ruby-1.8.7-p334/lib/ruby/1.8/i686-linux -I.
-Wl,-export-dynamic -Wl,-rpath,/usr/lib/mysql -Wl,-R
/usr/bin/ld: cannot find -lruby

It just crashes out.

Any ideas from that error?

Hi, I am unable to exactly reproduce your set-up because I do not
(longer ?) see ruby ruby-1.8.7-p334 in the list on known rubies from
rvm …

Would you have any problem with doing
$ rvm get stable
$ rvm install 1.8.7

and then trying again in that context ? In rvm that should not be a
siginificant problem, since you could still keep you older version if
you
wished.

That would make it easier for others to reproduce your set-up.

I just tried with ruby-1.8.7-p330 on Ubuntu 10.04 in a fresh gemset
and the gem install mysql2 “just worked” …

HTH,

Peter

Hi,

On 25.01.2012 19:36, Jim W. wrote:

/usr/bin/ld: skipping incompatible
/home/jim/.rvm/rubies/ruby-1.8.7-p334/lib/libruby.so when searching for
-lruby
/usr/bin/ld: cannot find -lruby
collect2: ld returned 1 exit status
make: *** [mysql2.so] Error 1

In case you missed that, there’s some problem with your ruby library …
I wouldn’t know why, I just had to install ruby via rvm on another
system, worked flawlessly.

Problem with p334 maybe? I mean I just did “rvm install 1.8.7”, it gave
me p357. Further installing mysql2 looked like this:

$ gem install mysql2
Fetching: mysql2-0.3.11.gem (100%)
Building native extensions. This could take a while…
Successfully installed mysql2-0.3.11
1 gem installed
Installing ri documentation for mysql2-0.3.11…
Installing RDoc documentation for mysql2-0.3.11…

Linux ubuntu1110 3.0.0-12-generic #20-Ubuntu SMP Fri Oct 7 14:56:25 UTC
2011 x86_64 x86_64 x86_64 GNU/Linux

HTH

Jim W. [email protected] wrote:

-lruby
/usr/bin/ld: skipping incompatible
/home/jim/.rvm/rubies/ruby-1.8.7-p334/lib/libruby.so when searching for
-lruby
/usr/bin/ld: cannot find -lruby

I’m not familiar with RVM (but many people on this list are), but
I’m wondering why libruby.so is there. Do you find libruby-static.a
in /home/jim/.rvm/rubies/ruby-1.8.7-p334 as well?

Can you run “file /home/jim/.rvm/rubies/ruby-1.8.7-p334/lib/libruby.so”
and see if it’s a valid shared object? Any chance you’re running
a mixed 32/64-bit userland and you got them mixed up in your RVM
installation?

This doesn’t appear to be an issue with mysql2 specifically, but
any C extensions you might have…

Results logged to

/home/jim/.rvm/gems/ruby-1.8.7-p334@rails307/gems/mysql2-0.3.11/ext/mysql2/gem_make.out

Does gem_make.out have any extra info not in your original email?

Hi,

On 25.01.2012 20:49, Jim W. wrote:

please read
/home/jim/.rvm/log/ruby-1.8.7-p352/make.log

As suggest, that content would be helpful.

  • Markus

Peter V. wrote in post #1042534:

On Wed, Jan 25, 2012 at 7:36 PM, Jim W.
[email protected]wrote:

gcc -I. -I.
result.c:315:33: warning: variable ‘tokens’ set but not used
-I/home/jim/.rvm/rubies/ruby-1.8.7-p334/lib/ruby/1.8/i686-linux -I.
-Wl,-export-dynamic -Wl,-rpath,/usr/lib/mysql -Wl,-R
/usr/bin/ld: cannot find -lruby

It just crashes out.

Any ideas from that error?

Hi, I am unable to exactly reproduce your set-up because I do not
(longer ?) see ruby ruby-1.8.7-p334 in the list on known rubies from
rvm …

Would you have any problem with doing
$ rvm get stable
$ rvm install 1.8.7

and then trying again in that context ? In rvm that should not be a
siginificant problem, since you could still keep you older version if
you
wished.

That would make it easier for others to reproduce your set-up.

I just tried with ruby-1.8.7-p330 on Ubuntu 10.04 in a fresh gemset
and the gem install mysql2 “just worked” …

HTH,

Peter

I get:

jim@caesar ~$ rvm install 1.8.7
Installing Ruby from source to: /home/jim/.rvm/rubies/ruby-1.8.7-p352,
this may take a while depending on your cpu(s)…

ruby-1.8.7-p352 - #fetching
ruby-1.8.7-p352 - #extracted to /home/jim/.rvm/src/ruby-1.8.7-p352
(already extracted)
ruby-1.8.7-p352 - #configuring
ruby-1.8.7-p352 - #compiling
ERROR: Error running 'make ', please read
/home/jim/.rvm/log/ruby-1.8.7-p352/make.log
ERROR: There has been an error while running make. Halting the
installation.

I do have build-essential installed. Make is in my path as well.

Markus F. wrote in post #1042547:

Hi,

On 25.01.2012 20:49, Jim W. wrote:

please read
/home/jim/.rvm/log/ruby-1.8.7-p352/make.log

As suggest, that content would be helpful.

  • Markus

The last 3 lines are the most important:

/usr/bin/ld: i386 architecture of input file
`libruby-static.a(dmyext.o)’ is incompatible with i386:x86-64 output
collect2: ld returned 1 exit status
make: *** [miniruby] Error 1

I’ve been using this .rvm folder since I was on an i386 version of
Ubuntu 10.10.

I’ve since upgraded to 11.10 but left my home directory untouched. Is
that a possible issue? Should I whack RVM and reinstall?

Jim W. [email protected] wrote:

/usr/bin/ld: i386 architecture of input file
`libruby-static.a(dmyext.o)’ is incompatible with i386:x86-64 output
collect2: ld returned 1 exit status
make: *** [miniruby] Error 1

I’ve been using this .rvm folder since I was on an i386 version of
Ubuntu 10.10.

I’ve since upgraded to 11.10 but left my home directory untouched. Is
that a possible issue? Should I whack RVM and reinstall?

Yes, nuke and reinstall RVM.

Generally, you need to rebuild/relink everything not managed by the OS
package manager if you’re switching between 32/64-bit, switching between
OSes, or downgrading the OS…

Peter V. wrote in post #1042556:

On Wed, Jan 25, 2012 at 9:16 PM, Jim W.
[email protected]wrote:

I’ve since upgraded to 11.10 but left my home directory untouched. Is
that a possible issue? Should I whack RVM and reinstall?

Well, setting up a new test user ($ sudo adduser test) and a
single user install of rvm there is very cheap … That would
validate that all the system libraries are OK.

I don’t recall taking an Ubuntu from 10.04 to 11.10 and keeping
rvm on it (by coincidence, all my 11.10 machines are new set-ups,
not upgrades).

I would validate that first, before removing your rvm from your
“main” user account.

Peter

Well this is a setup… but I NEVER wipe my home partition or my VMs
partition. Everything else gets blown away.

Thank you so very much, I don’t believe I’d have found this problem
without posting to this forum.

-Jim

On Wed, Jan 25, 2012 at 9:16 PM, Jim W.
[email protected]wrote:

I’ve since upgraded to 11.10 but left my home directory untouched. Is
that a possible issue? Should I whack RVM and reinstall?

Well, setting up a new test user ($ sudo adduser test) and a
single user install of rvm there is very cheap … That would
validate that all the system libraries are OK.

I don’t recall taking an Ubuntu from 10.04 to 11.10 and keeping
rvm on it (by coincidence, all my 11.10 machines are new set-ups,
not upgrades).

I would validate that first, before removing your rvm from your
“main” user account.

Peter