Just Say No: Archives

Playing nicely: Notes on installing RVM + Passenger

Sam Phillips, December 30th, 2009 11:13 pm

Upon installing a new Mac for home development, I decided to try out a few new technologies – RVM was one of them. It was relatively painless in terms of commands; but it did require a bit of a mindset shift to understand how to debug it. Hopefully this will help someone; the steps below should work for linux machines too, albeit with some slight changes to paths.

RVM, Ruby Version Manager, allows you to run multiple ruby versions on the same machine. This is good if you want to test upgrades etc. For me, a pleasant side effect was being forced away from using the system version of ruby. Relying on the system version (and system gems… more on that in a bit!) seemed a little lazy, and was always a bit of a pain when unraveling dependencies and moving stuff live.

Another complementary tool, which I’ll hopefully blog about separately, is bundler. Do yourself a big favour and don’t try to install both at once; it can get a mind-boggling. Get to the point where you’re happy with one of the two, and then start on the other.

The RVM site is full of useful information, although it’s not always super easy to find what you need. The stuff on installation is vital (for the record, the gem version worked for me – in fact, rvm is the only gem I have installed on the system ruby).

Once installed, I installed ruby 1.8.7 with:

$ rvm install 1.8.7

The system was already running 1.8.7, so I figured this was probably the best place to start. The plan is run within this version by default, and to use other versions as appropriate.

Once installed, activate with:

$ rvm use 1.8.7

This will switch the ruby version for the current terminal. Only. This wasn’t immediately clear to me; if you want to switch for all terminals, add the default flag:

$ rvm use 1.8.7 --default

Fire up a new terminal, and it should now also be running the same version of ruby. Check with ‘ruby -v’:

$ ruby -v
ruby 1.8.7 (2009-12-24 patchlevel 248) [i686-darwin10.2.0]

To be sure that you’re using the version of ruby you expect, there are a few things you can check:

$ which ruby
/Users/samphillips/.rvm/ruby-1.8.7-p248/bin/ruby

If you get ‘/usr/bin/ruby’ instead, you’re still using the system version.

RubyGems is installed separately for each ruby instance. To check that the ‘gem’ command is hitting the right place, again, break out ‘which’:

$ which gem
/Users/samphillips/.rvm/ruby-1.8.7-p248/bin/gem

Another good check is ‘gem env’:

$ gem env
RubyGems Environment:
- RUBYGEMS VERSION: 1.3.5
- RUBY VERSION: 1.8.7 (2009-12-24 patchlevel 248) [i686-darwin10.2.0]
- INSTALLATION DIRECTORY: /Users/samphillips/.rvm/gems/ruby-1.8.7-p248
- RUBY EXECUTABLE: /Users/samphillips/.rvm/ruby-1.8.7-p248/bin/ruby
- EXECUTABLE DIRECTORY: /Users/samphillips/.rvm/gems/ruby-1.8.7-p248/bin
- RUBYGEMS PLATFORMS:
- ruby
- x86-darwin-10
- GEM PATHS:
- /Users/samphillips/.rvm/gems/ruby-1.8.7-p248
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :benchmark => false
- :backtrace => false
- :bulk_threshold => 1000
- :sources => ["http://gems.rubyforge.org/", "http://gemcutter.org/"]
- REMOTE SOURCES:
- http://gems.rubyforge.org/
- http://gemcutter.org/

Again, if you’re seeing references to directories like these:

- INSTALLATION DIRECTORY: /Library/Ruby/Gems/1.8
- RUBY EXECUTABLE: /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby
- EXECUTABLE DIRECTORY: /usr/bin

Then your switch hasn’t worked.

Some reasons I’ve found why switching hasn’t worked:

  • It’s apparently possible to drop the ‘use’ keyword when choosing ruby versions. I’ve learned not to do this; firstly it doesn’t give you a nice confirmation that it’s worked, and secondly it didn’t seem to work correctly (perhaps the two are related…)
  • Similarly, although you’ve assigned the ‘default’ version of ruby, running ‘rvm use default’ doesn’t seem to work properly all the time.

If keeping to the full ‘rvm use xxx –default’ command doesn’t help you, it might be worth re-installing. This is easy; switch back to the system version of ruby (’rvm use system’), delete the .rvm directory in your home directory and uninstall the gem. It seems that my mistake with my original install was a classic one:

Too much sudo

We’ve got very used to installing gems, and doing anything to do with them, with sudo. With rvm, you don’t need to do this and it will lead to confusing results, as the docs point out at length. Every time you use sudo, you’re going to be messing with the system ruby version (as this is in root’s path), and weird results will follow.

To summarise: use sudo to install the gem on system ruby, and then leave the sudo well alone.

Passenger

If you’re using with passenger + apache, first install the passenger gem against your rvm ruby version:

$ rvm use 1.8.7
$ gem install passenger
[snip]
$ passenger-install-apache2-module

Note the lack of sudo. The module installer will suggest the apache config syntax. This needs changing slightly, as per the docs

$ cat /etc/apache2/other/passenger.conf
LoadModule passenger_module /Users/samphillips/.rvm/gems/ruby-1.8.7-p248/gems/passenger-2.2.8/ext/apache2/mod_passenger.so
PassengerRoot /Users/samphillips/.rvm/gems/ruby-1.8.7-p248/gems/passenger-2.2.8
PassengerRuby /Users/samphillips/.rvm/bin/passenger_ruby

(restart apache…)

The last line will point apache at your rvm ruby version. When using passenger with rvm, switch the rvm version with the following syntax:

$ rvm use 1.9.1 --default --passenger

I was confused for a number of minutes when gems installed on my rvm version of ruby weren’t available to apache; not doing this was why.

RVM works nicely already, and has potential to do lots of good. If you’ve got any problems, hop on to #rvm on irc.freenode.net, where friendly folks will help you out.

Tagged: Sam

No Comments

November In Manchester: Twitter As A Reality Show

Sam Phillips, December 2nd, 2009 12:04 am

November In Manchester, the brainchild of my good friend Tom Mason, is a social media love story. What does this mean? It means that the eight characters have played out their story in real time, over social media. But what is ’social media’? Well, for this project, it meant Flickr, Blogger, and, fundamentally, Twitter.

Twitter is the stage on which this story was played out. What is Twitter? The best explanation I’ve heard so far is ‘one-to-many text messaging’. You send a text – 140 characters – and instead of it being sent to just one friend, it’s sent to all of your ‘followers’. They receive the text on their phones, through the Twitter website, or through Twitter software installed on their computers.

The story is not set in stone, and it happens in real time. In this way, it’s almost more of a reality show than a fictional work with a predetermined path. The characters – Persephone, James, Leonie, Darren, Regina, Paul, Melody and Lee – live in our reality. When we put together the main site, we even gave it a feel of a Big Brother microsite. This is a reality show like no other.

Persephone and Leonie went to the christmas lights being turned on in Manchester city centre, for example. It was quite the live drama! Paul and James went to a football match at Old Trafford. Leonie’s in PR, so if there’s a party or networking event going on, she’s there.

The characters also respond to other people’s tweets – meaning that, just by tweeting them and getting a reply, anybody can become a character in the story. It’s been fascinating to watch people get involved with the story.

But what is most striking about these characters is that they are very almost real people, very believably existing on Twitter – in a way that, in reality, most people don’t. Although Facebook is a mass phenomenon, and MySpace/Bebo remain a modernised version of Geocities, Twitter isn’t quite there yet. It’s the domain of geeks, marketeers and companies doing innovative customer engagement. The November In Manchester characters aren’t any of these types – they’re normal mancunians trying to get from the start to the end of a day unscathed. You can believe that they are real, and reading their tweets you can believe that other, real, people could use Twitter in this way as well.

November In Manchester is now my first example when I explain to a client, colleague, friend or grandparent what Twitter is, what it does, and what it’s for. What is Twitter for? It’s for telling your story to the rest of us.

Interested in how the November In Manchester site works? Check out November In Manchester: Joining those technical dots.

Tagged: Sam

No Comments

Subscribe to this blog's RSS feed

On Twitter:

  1. Loading...

Follow me >

Previously Rejected:

  1. Installing Bundler, Rails and MySQL on OS X Snow Leopard
  2. Playing nicely: Notes on installing RVM + Passenger
  3. November In Manchester: Twitter As A Reality Show
  4. November In Manchester: Joining those technical dots
  5. Introducing Ambitious Query Indexer – A new way to index your Rails app’s database
  6. Top 5 Least Favourite Spotify Adverts
  7. Forget the technology – is the very idea of Twitter scalable?
  8. Going back to paper as a task collection system
  9. Update Facebook status from Twitter
  10. Staying out of trouble…
  11. ALA’s 2008 Survey
  12. Ten products that Apple just rendered obsolete with iPhone 3G/2.0
  13. Professional Accreditation for Web Professionals (Or, a rant on the British Computer Society)
  14. If it’s that important… pick up the phone!
  15. Moving Google Mail, Calendar, Reader and Talk into Google Apps
  1. Bookmarks:

Valid XHTML 1.0 Transitional Valid CSS!