Installing Ruby Rails Mysql Gem on Ubuntu
Assuming you have a full working DB installed from source in /usr/local/mysql
[install a bunch of stuff]
apt-get install ruby rubygems ruby1.8-dev rake rdoc
wget http://rubyforge.org/frs/download.php/51087/mysql-ruby-2.8.1.tar.gz
[extract and cd into that directory]
ruby ./extconf.rb --with-mysql-include=/usr/local/mysql/include/mysql --with-mysql-lib=/usr/local/mysql/lib/mysql
make
make install
gem list --local
*** LOCAL GEMS ***
mysql (2.7)
~/mysql-ruby-2.8.1#
You may need to also install rails, but it’s probably checked into your repo somewhere. (this is called rails freezing);
Useful links , problems, etc.
One one server, I got this.
root@nnyc3ol08:/var/lib/gems/1.8/bin# ./update_rubygems
/usr/lib/ruby/1.8/rubygems.rb:578:in `report_activate_error': Could not find RubyGem hoe (>= 2.3.0) (Gem::LoadError)
from /usr/lib/ruby/1.8/rubygems.rb:134:in `activate'
from /usr/lib/ruby/1.8/rubygems.rb:158:in `activate'
from /usr/lib/ruby/1.8/rubygems.rb:157:in `each'
from /usr/lib/ruby/1.8/rubygems.rb:157:in `activate'
from /usr/lib/ruby/1.8/rubygems.rb:158:in `activate'
from /usr/lib/ruby/1.8/rubygems.rb:157:in `each'
from /usr/lib/ruby/1.8/rubygems.rb:157:in `activate'
from /usr/lib/ruby/1.8/rubygems.rb:49:in `gem'
from ./update_rubygems:18
So, what’d I do? I dpkg –list |grepped ruby, apt-get removed it all, and started over. (this is from memory, forgive any typeos)
$ cd /tmp
$ apt-get install ruby ruby1.8-dev
$ wget http://rubyforge.org/frs/download.php/35283/rubygems-1.1.1.tgz
$ tar xzvf rubygems-1.1.1.tgz
$ cd rubygems-1.1.1
$ ruby setup.rb
$ gem update --system
$ gem update
Also, if you’re compiled from source for mysql, means your mysql shared objects are in /usr/local/mysql/lib/mysql and not in /lib.
an error may look like this:
root@nnyc5ol06:/usr/local/ruby# rake db:migrate
(in /usr/local/ruby)
!!! The bundled mysql.rb driver has been removed from Rails 2.2. Please install the mysql gem and try again: gem install mysql.
rake aborted!
libmysqlclient.so.16: cannot open shared object file: No such file or directory - /usr/local/lib/site_ruby/1.8/x86_64-linux/mysql.so
do this to fix.
522 LD_RUN_PATH=/usr/local/mysql/lib/mysql
523 export LD_RUN_PATH
527 ruby extconf.rb --with-mysql-include=/usr/local/mysql/include/mysql --with-mysql-lib=/usr/local/mysql/lib/mysql
528 make
529 make install
http://www.kitebird.com/articles/ruby-mysql.html
http://laurentbois.com/2008/04/22/install-ruby-on-rails-on-linux-debian-etch/
http://dizzy.co.uk/ruby_on_rails/cheatsheets/rails-migrations
