0
user@sv1 [/home/user/]# env|grep GEM
GEM_HOME=/home/user/.gems/2.1
GEM_PATH=/home/user/.gems/2.1

user@sv1 [/home/user/]# gem install mysql2
Building native extensions.  This could take a while...
Successfully installed mysql2-0.3.18
1 gem installed

that installs mysql2.so in multiple locations:
user@sv1 [/home/user/]# find /home/user/.gems -name mysql2.so
/home/user/.gems/2.1/extensions/x86_64-linux/2.1.0-static/mysql2-0.3.18/mysql2/mysql2.so
/home/user/.gems/2.1/gems/mysql2-0.3.18/ext/mysql2/mysql2.so
/home/user/.gems/2.1/gems/mysql2-0.3.18/lib/mysql2/mysql2.so

user@sv1 [/home/user/]# ls -l /home/user/.gems/2.1/extensions/x86_64-linux/2.1.0-static/mysql2-0.3.18/mysql2/mysql2.so
-rwxr-xr-x 1 user user 64842 mar 18 16:13 /home/user/.gems/2.1/extensions/x86_64-linux/2.1.0-static/mysql2-0.3.18/mysql2/mysql2.so
user@sv1 [/home/user/]# ls -l /home/user/.gems/2.1/gems/mysql2-0.3.18/ext/mysql2/mysql2.so
-rwxr-xr-x 1 user user 64842 mar 18 16:13 /home/user/.gems/2.1/gems/mysql2-0.3.18/ext/mysql2/mysql2.so

now I want to rebuild this extension so I do:
user@sv1 [/home/user/]# gem install mysql2
Building native extensions.  This could take a while...
Successfully installed mysql2-0.3.18
1 gem installed

user@sv1 [/home/user/]# ls -l /home/user/.gems/2.1/extensions/x86_64-linux/2.1.0-static/mysql2-0.3.18/mysql2/mysql2.so
-rwxr-xr-x 1 user user 64842 mar 18 16:13 /home/user/.gems/2.1/extensions/x86_64-linux/2.1.0-static/mysql2-0.3.18/mysql2/mysql2.so
user@sv1 [/home/user/]# ls -l /home/user/.gems/2.1/gems/mysql2-0.3.18/ext/mysql2/mysql2.so
-rwxr-xr-x 1 user user 87485 mar 18 16:16 /home/user/.gems/2.1/gems/mysql2-0.3.18/ext/mysql2/mysql2.so

as you can see /home/user/.gems/2.1/extensions/x86_64-linux/2.1.0-static/mysql2-0.3.18/mysql2/mysql2.so was not rebuild. what is worse this file actualy is used when "require 'mysql2'" in ruby code. This blocks rebuilding/updateing a gem. Of course I can solve it by removing this old file and "gem install" then but this causes a lot of new variables to remember and a lot of hard to diagnose problems. How do i rebuild all files of the gem (mysql2.so here) with a gem command? Or maybe its a bug in a "gem" program?

This problem is not specific to mysql2 gem as other gems are behaving same way.

One might say that its not necessary to rebuild a gem when its version did not change - but it is when libs that its linked to was updated/changed (for example libmysqlclient for mysql2 gem)

0

You may be looking for the pristine option:

gem pristine mysql -v 0.3.18

or without the -v I believe it will just work on the most recent version but there is also the --all option.

See gem help pristine for documentation:

Restores installed gems to pristine condition from files located in the gem
cache

Using pristine also includes rebuilding any gem extensions which will re-link the binaries with the current libs.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.