How to install Mongrel, Mysql, and Postgres gems in OpenSolaris Ruby -


Rubygems is the preferred package manager for Ruby, and Ruby packages are called gems. While most of the gems out there are written in Ruby, there are a few that have C or C++ code in them for performance(like Fastthread for Mongrel), or Features(like the MySQL connector for Ruby).
Such gems need a C/C++ compiler to successfully be installed. Apart from that, they also need an appropriately configured rbconfig.rb file in the Ruby installation.
The rbconfig.rb file is typically present in lib/ruby/site_ruby/1.8/rubygems.rb - on OpenSolaris, it is present as /usr/ruby/1.8/lib/ruby/site_ruby/1.8/rubygems.rb
The rbconfig.rb file contains, among other things, information about which compiler(ie., the location) was used to build Ruby, compiler flags, linker flags, path to the C++ compiler, location of ginstall etc.,
This is strictly not necessary for C applications, ie., you can install a native gem compiled with CompilerB on a version of Ruby that was compiled with CompilerA, but the advantage of having the build time compiler flags captured is that you can optimize the extensions just as the Ruby binary was optimized(and the folks who built Ruby for you hopefully have done some reasearch in this area).
On OpenSolaris, there's a bug by which some paths in the rbconfig.rb file actually point to a compiler location that was used by the build infrastructure, and this location is normally not present on the system.
This is a bug that is being fixed, and the right paths should work out of the box. Until that fix shows up in the repository, here's how to make sure your Ruby installation works well.

If you have Sun Studio installed on the machine, use this rbconfig.rb to use Studio(it assumes you've installed Studio into /opt/SUNWspro - which is where it goes into, by default).

If you prefer gcc, use this rbconfig.rb instead (it assumes gcc is in /usr/sfw/bin/gcc - which is a symlink from /usr/bin/gcc).

After you've replaced the original rbconfig.rb file, installing native gems should be easy.
If you used the gcc version, then all you have to do is utter "gem install mysql -- --with-mysql-dir=/usr/mysql/5.0", "gem install postgres", or "gem install mongrel" to install these packages.
Note that the "--with-mysql-dir" option is necessary. OpenSolaris has two versions of MySQL, the ancient version(4.x.y) is in the default link path, which you don't want to link to, MySQL 5.x.y is in /usr/mysql/5.0

Also, I assumed that Sun Studio is in it's default path of /opt/SUNWspro. The rbconfig.rb files are for Solaris running on an x86/x64 platform. If you're using SPARC, modify your file with appropriate values for INSTALL, CC, CFLAGS, CPPFLAGS, LDFLAGS, and CPP from my files.

Comments:

Does the rbconfig.rb bug exist on opensolaris 2008.05 also? Does the new packaging system (IPG?) fix it?

Posted by realneel on May 20, 2008 at 02:29 PM PDT #

Unfortunately it's not fixed in the IPS repository(or in Solaris Nevada).

That should change pretty soon, though.

Posted by Prashant Srinivasan on May 22, 2008 at 09:18 AM PDT #

Thanks for this post.

Since you're doing solaris / ruby, I figured I'd ask my question. I'm running sol10 sparc on a T1000.

I have an issue with rubygems where it just takes forever to run! If I truss the "gem install rails" process, I get something like this:

(lots of getcontext)
/1: getcontext(0xFFBCD9F0)
/1: getcontext(0xFFBCCF98)
/1: getcontext(0xFFBCC950)
/1: getcontext(0xFFBCC950)
/1: getcontext(0xFFBCD620)
/1: getcontext(0xFFBCD618)
/1: getcontext(0xFFBCD9F0)
/1: getcontext(0xFFBCCF98)
/1: getcontext(0xFFBCC950)
\^C/2: nanosleep(0xFEB7BF88, 0xFEB7BF80) = 0

If you've seen this before, how did you solve the issue?

I've tried compiling from source, installing from various binaries, but no luck in clearing this particular issue.

Thanks in advance,

Jeff

Posted by Mirage on May 23, 2008 at 06:51 AM PDT #

Post a Comment:
Comments are closed for this entry.
About

prashant

Search

Archives
« April 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today