Agile Web Development

Build it. Launch it. Love it.

gems with architecture

Adapted from technoweenies freeze gems plugin. This version adds two features:

  1. gems are unpacked into vendor/gems to make clear what they are
  2. it’s possible to have multiple versions of gems with architecture dependent features

Usage

freeze

  rake gems:freeze GEM=gemname [VERSION=version] [ARCH=detect|archname] [TO=dirname]

Running the above task will unpack the named gem into RAILS_ROOT/vendor/gems/ARCH/

If ARCH is unspecified, and the gem has no extensions, the gem will be unpacked into gems/ruby If ARCH is unspecified, and the gem has extensions, ARCH will be detected and the gem will be unpacked into gems/ARCH.

unfreeze

  rake gems:unfreeze GEM=gemname

will remove the named gem from all ARCHS

loading

The init.rb file loads gems from gems/ARCH and then gems/ruby, automatically. This means that you can have two different versions of a gem, for different architectures, and the correct one will be loaded.

Example

hpricot builds native extensions, while syntax does not. Here’s how this gems:freeze plugin handles that.

On my dev platform (a mac):

  rake gems:freeze GEM=hpricot
  rake gems:freeze GEM=syntax

results in the following lqyout:

  vendor/
    gems/
      i686-apple-darwin8.9.1/
        hpricot-0.5/
      ruby/
        syntax-1.0.0/

I can add these to svn, or whatever. On my deployment platform (Fedora box), the hpricot gem will not be loaded, because the arch is for the mac. So i need to add the linux version of hpricot:

So I log into the fedora box, and do:

  rake gems:freeze GEM=hpricot

which results in adding:

  vendor/
    gems/
      i386-redhat-linux-gnu/
        hpricot-0.5/

I can add this to my scm, and the correct version will be loaded on each machine.

Vitals

Home http://plugins.ardes.com/doc/gems
Repository http://svn.ardes.com/rails_plugins/gems
License Rails' (MIT)
Tags Tag_red
Rating (2 votes)
Owner Ian White
Created 30 May 2007

Comments

  • Pål
    1 August 2007

    Hi, Your plugin is not compatible with the current gem version (0.9.4), i can recommend gemsonrails instead- it provides the same functionality. http://gemsonrails.rubyforge.org/

  • Avatar
    Ian
    12 September 2007

    Thanks for the comment.

    It's now compatible. And btw, it does a bit more that gemsonrails AFAIK. It allows you to keep fifferent versions of the same gem for different ARCHS. If you develop and stage on different ARCHs then this will be useful

  • CCo
    27 September 2007

    Hello, I'm trying to use your plugin to freeze RMagick gems, but I encounter serious issues each step of the way. I have the require statement in my environment file (require 'RMagick'), but I get RMagick.so could not be found when I don't have RMagick installed on the server. Any ideas?

  • Avatar
    24 January 2008

    To make this plugin work with RubyGems 1.0.1, you must add the following to the vendor/plugins/gems/tasks/gems_tasks.rake file:

    require 'rubygems/command_manager'

  • Avatar
    18 February 2008

    Hey, and thanks for the great improvements! I'm having one problem with gems_with_architecture. Rails doesn't load the gems from vendor/gems. Pleasy help me with this problem - do I need to require the gems or should they be automatically loaded..

Add a comment