views:

1874

answers:

3

On RedHat Enterprise Linux 5 the latest Ruby version available via RPM is 1.8.5. My Rails app requires 1.8.6 or above so I need to compile Ruby from source.

I have tried the following to build it and it seems to build ok, but then I'm seeing gcc compilation errors when trying to run a plug-in which requires RubyInline.

There seems to be a lack of decent documentation for building Ruby from source, suitable for running Rails apps.

Here's how I compiled Ruby:

./configure --prefix=/usr --with-openssl-include=/usr/include/openssl --with-openssl-lib=/usr/lib64/openssl/engines
make
sudo make install

I wonder whether there are specific compile flags I need to build this on a 64-bit system. The actual error I'm seeing is

 error executing "gcc -shared   -fPIC -g -O2   -I /usr/lib/ruby/1.8/x86_64-linux  -I /usr/include -L/usr/lib -o \"/home/deploy/.ruby_inline/Inline_ImageScience_aa58.so\" \"/home/deploy/.ruby_inline/Inline_ImageScience_aa58.c\" -lfreeimage -lstdc++ ":

Any advice would be greatly appreciated

A: 

Create a new rpm using the required version of ruby. This should ensure that you are compiling with the correct flags and that the files end up in the correct locations.

Install the ruby src rpm and edit /usr/src/redhat/SPECS/.spec to use the 1.8.6 source and update the rpm version in the spec. Download the ruby 1.8.6 source archive and put it in /usr/src/redhat/SOURCES. Then you can build the rpm with the command rpmbuild -bb .spec

Ronny Vindenes
+1  A: 

The best way would probably be to just "steal" a Ruby 1.8.6 RPM from Fedora. The second best way would be to steal a Ruby 1.8.6 SRPM from Fedora and build it yourself.

However, there is one thing you could do: add a --disable-pthread flag to the configure line and remove --enable-pthread if it's there. --enable-pthread makes MRI significantly slower, and is only needed if you want to use Ruby/Tk and your system's Tk library was built with --enable-pthread.

Jörg W Mittag
A: 

Ruby packages for Fedora (including SRPM)

Couldn't post as a comment on the correct answer so added here - editors feel free to tidy-up.

XCondE