format internet:

…please wait (42% completed)…

Archive for the ‘jruby’ Category

Multiple rubygems versions, GEM_HOME and GEM_PATH

Posted by javier ramirez on September 28, 2009

Installing rubygems is failrly easy and it’s great to have a package manager so you can forget about manually installing and upgrading the components you use. After installing a gem, you can require it from any ruby script and use it hassle-free. Well, given your ruby interpreter can find it.

When you install rubygems, a lot of default configuration is done behind the scenes. If you must see to believe, you can run

gem environment

do you believe me now?

Unless you are on windows, you have probably experienced already that gems can get installed in different locations. If using a superuser account, the global configuration will be used, but with a regular account gems install under your home directory.

If you are not careful about how you install your gems, or if you are using rake gems:install from regular accounts, you might end up installing the same version of a gem twice. That’s not only WET (not DRY, bear with me here) but it eats up your poor HD.

Things can get a lot worse than that. Suppose you are working with both JRuby and Ruby MRI. When you use rubygems from JRuby, it will try to use a different gem location by default. So, depending on how you are installing gems, you could have up to three different copies of exactly the same version.

And if you are on ubuntu and you upgrade from an old version of rubygems to the latest one —you will have to if you install Rails 2.3.4; if you are having problems you can read right here how to update it— you might be surprised that your gems are being installed *again*. The reason is under older versions the default location was “/var/lib/gems” and the latest one defaults to “/usr/lib/ruby/gems”.

Well, four different copies of ActiveRecord 2.3.4 are three and a half more copies than I wanted, mind you.

So.. how can we stop this gem install frenzy? Easy. Don’t use the defaults. Each of your installations is using default values, but they can be easily overridden with command line parameters or much more conveniently with environment variables.

Remember the title of this post? Can you see anything there that would make a good candidate for environment variables? That’s right, all the rubygems versions honor the GEM_HOME and GEM_PATH variables, so if they are set they will be used.

Depending on your OS, you can set these variables in different places. I’m on ubuntu and a bit lazy, so I chose the easiest, which is by adding this to my .bashrc file.

export GEM_HOME=/var/lib/gems/1.8
export GEM_PATH=/var/lib/gems/1.8

And now, no matter what I’m using: Ruby MRI, JRuby, or the latest rubygems, my already installed gems will be used, and the new ones will be put in the same place.

Saving the world is a hard job, but someone has to do it.


Posted in 1771, development, jruby, ruby, ruby, ruby on rails, ruby on rails | Tagged: , , , , , , | 7 Comments »

Video of my talk “Jruby On Rails” at the Sun Open Communities Forum

Posted by javier ramirez on August 23, 2009

I just knew the video of my talk about JRuby on Rails at the Sun Open communities Forum is already online. Funny how a google alert let me know this video has been published even before the official web page of the event was updated.

The talk is in Spanish and the slides I used are available at slideshare.

If you are a Java developer interested in JRuby and you are going to be in Madrid in September, stay tuned because it’s very likely I will be speaking again about JRuby in SIMO

Posted in conferences, jruby, ruby, ruby on rails | 4 Comments »

My slides for “Jruby on Rails: Ruby on Rails sobre la JVM”

Posted by javier ramirez on June 25, 2009

It was interesting to be at the Sun Open Communities Forum and meet people I used to work with (or even teach to) as back in time as in 1996.

It was also interesting to have the opportunity to introduce Ruby and Ruby on Rails to Java developers and show them how they could use it from the familiar JVM.

As usual, I uploaded to slideshare the slides I used in my presentation.

The layout might be a bit enterprisey for my standards, but I was representing my company, so I used the company template. Anyway, the presentation is under Creative Commons, so feel free to use it in any way you can imagine, as long as you respect the “non commercial attribution share alike” license.

Posted in conferences, development, javier ramirez, jruby, madrid, ruby, ruby on rails | Tagged: , , | Leave a Comment »

Speaking about JRuby on Rails at the Sun Open Communities Forum

Posted by javier ramirez on June 9, 2009

I’ve been invited to speak about JRuby on Rails at the Sun Open Communities Forum. This event is the evolution of the former editions of OpenJavaDay/OpenSolarisDay, revamped to include more Open Source communities.

Apart from the predictable “all-things-java” sessions, this year there are some interesting labs and talks about MySQL Scalability, REST, AJAX, the cloud, development frameworks and different languages running on the JVM.

Most of the talks, including mine, will be delivered in Spanish, but there will be some in English too.

My session will be

JRuby on Rails. Ruby on Rails on the JVM

And the excerpt I’ve sent for the talk goes something like this

Ruby is a dynamic programming language with a focus on simplicity and productivity. Ruby on Rails is a web framework optimized for programmer happiness and sustainable productivity. The JVM is one of the world’s most heavily-optimized pieces of software. The combination of these three elements provides a superb platform for building web applications.

In my session I will explain the highlights of Ruby, how Ruby on Rails has changed the rules of web development, and how JRuby allows for the integration of Ruby (on Rails) and Java.

Inscription is free and if you cannot attend, there will be live streaming as well. Notice you also have to inscribe (checking the “Lo seguiré por internet” radio button) if you want to watch the streaming.

Posted in conferences, development, internet, javier ramirez, jruby, madrid, madridonrails, ruby, ruby on rails | 1 Comment »