Rubygems: Rebuild native extensions

Rarely, you might want to rebuild all gems with native extensions, because they might be compiled against outdated system libraries, resulting in some warnings or even segfaults or other ruby errors.

You can do that using

gem pristine --all

This will reset all gems to a pristine state as if you'd reinstall them, and as a side effect, rebuild all native extensions.

The above command will also help you sorting out errors like this after a distribution upgrade:

libmysqlclient_r.so.16: cannot open shared object file: No such file or directory - /home/henning/.rvm/gems/ruby-1.8.7-p358/gems/mysql2-0.3.11/lib/mysql2/mysql2.so

(Because the library which is used to compile the gem doesn't exist anymore and you have to recompile it.)

Tobias Kraze Over 11 years ago