Install Ruby on Fedora

These are my notes from getting Ruby and rails installed on Fedora 8. I was setting up a Redmine test server at the time so I also had to install the ruby mysql gem for native mysql access.

I fell into every trap possible so here’s how I got around various issues.

So first off if you’re using an old version of Fedora, make sure you have access to the latest yum updates repo by getting the new signing key installed (see link in my post here). Then

yum install ruby ruby-libs ruby-mode ruby-rdoc ruby-irb ruby-ri ruby-docs ruby-devel

By default that installed ruby 1.8.6 which was fine for my needs.

Next we need to install the gem utility to manage gems for us.

wget http://production.cf.rubygems.org/rubygems/rubygems-1.4.1.tgz
tar -zxf rubygems-1.4.1.tgz
cd rubygems-1.4.1
ruby setup.rb

If that all works you should see this message

 
RubyGems 1.4.1 installed
 
=== 1.4.1 / 2010-12-31
 
Since apparently nobody reads my emails, blog posts or the README:
 
DO NOT UPDATE RUBYGEMS ON RUBY 1.9! See UPGRADING.rdoc for details.
 
Bug fix:
 
* Specification#load was untainting a frozen string (via `gem build *.spec`)
 
 
------------------------------------------------------------------------------
 
RubyGems installed the following executables:
        /usr/bin/gem

Next I installed rails (here I needed a specific version to match ruby 1.8.6 that I’d installed earlier)

gem install rails -v=2.3.5

So far so good. Then I wanted to add the mysql native gem

gem install mysql

Which resulted in this message:

Fetching: mysql-2.8.1.gem (100%)
Building native extensions.  This could take a while...
ERROR:  Error installing mysql:
        ERROR: Failed to build gem native extension.
 
/usr/bin/ruby extconf.rb
can't find header files for ruby.
 
 
Gem files will remain installed in /usr/lib/ruby/gems/1.8/gems/mysql-2.8.1 for inspection.
Results logged to /usr/lib/ruby/gems/1.8/gems/mysql-2.8.1/ext/mysql_api/gem_make.out

Okay so a quick search around and it looked like I needed the ruby-devel package (which I’ve included in the first yum command above to save you this problem), if you’ve arrived here because you’re having this problem then you’ll need to

yum -y install ruby-devel

So again I attempted to install the mysql gem

gem install mysql

This time the error was slightly different:

Building native extensions.  This could take a while...
ERROR:  Error installing mysql:
        ERROR: Failed to build gem native extension.
 
/usr/bin/ruby extconf.rb
checking for mysql_ssl_set()... no
checking for rb_str_set_len()... no
checking for rb_thread_start_timer()... no
checking for mysql.h... no
checking for mysql/mysql.h... no
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers.  Check the mkmf.log file for more
details.  You may need configuration options.
 
Provided configuration options:
        --with-opt-dir
        --without-opt-dir
        --with-opt-include
        --without-opt-include=${opt-dir}/include
        --with-opt-lib
        --without-opt-lib=${opt-dir}/lib
        --with-make-prog
        --without-make-prog
        --srcdir=.
        --curdir
        --ruby=/usr/bin/ruby
        --with-mysql-config
        --without-mysql-config
 
 
Gem files will remain installed in /usr/lib/ruby/gems/1.8/gems/mysql-2.8.1 for inspection.
Results logged to /usr/lib/ruby/gems/1.8/gems/mysql-2.8.1/ext/mysql_api/gem_make.out

So now it turns out I need the mysql headers too so:

yum -y install mysql-devel

So finally:

gem install mysql

and then at last:

Building native extensions.  This could take a while...
Successfully installed mysql-2.8.1
1 gem installed
Installing ri documentation for mysql-2.8.1...
 
No definition for next_result
 
No definition for field_name
 
No definition for field_table
 
No definition for field_def
 
No definition for field_type
 
No definition for field_length
 
No definition for field_max_length
 
No definition for field_flags
 
No definition for field_decimals
 
No definition for time_inspect
 
No definition for time_to_s
 
No definition for time_get_year
 
No definition for time_get_month
 
No definition for time_get_day
 
No definition for time_get_hour
 
No definition for time_get_minute
 
No definition for time_get_second
 
No definition for time_get_neg
 
No definition for time_get_second_part
 
No definition for time_set_year
 
No definition for time_set_month
 
No definition for time_set_day
 
No definition for time_set_hour
 
No definition for time_set_minute
 
No definition for time_set_second
 
No definition for time_set_neg
 
No definition for time_set_second_part
 
No definition for time_equal
 
No definition for error_errno
 
No definition for error_sqlstate
Installing RDoc documentation for mysql-2.8.1...
 
No definition for next_result
 
No definition for field_name
 
No definition for field_table
 
No definition for field_def
 
No definition for field_type
 
No definition for field_length
 
No definition for field_max_length
 
No definition for field_flags
 
No definition for field_decimals
 
No definition for time_inspect
 
No definition for time_to_s
 
No definition for time_get_year
 
No definition for time_get_month
 
No definition for time_get_day
 
No definition for time_get_hour
 
No definition for time_get_minute
 
No definition for time_get_second
 
No definition for time_get_neg
 
No definition for time_get_second_part
 
No definition for time_set_year
 
No definition for time_set_month
 
No definition for time_set_day
 
No definition for time_set_hour
 
No definition for time_set_minute
 
No definition for time_set_second
 
No definition for time_set_neg
 
No definition for time_set_second_part
 
No definition for time_equal
 
No definition for error_errno
 
No definition for error_sqlstate

That’s it! I hope this helps.

Share

One thought on “Install Ruby on Fedora”

Leave a Reply

Your email address will not be published. Required fields are marked *