When I started doing this, I thought that it was going to be a pain for cross-platform use. For pure-ruby libraries, there aren't any problems. Most of the systems I work on at this point are either mac (mixed intel/ppc) or linux. On linux, native extensions are built with .so extensions. On mac, they are built as .bundle files. Since that names are different, it's actually possible for gems with native components for these two platforms to live together in the same place. I wouldn't necessarily recommend this as a general solution, but depending on your situation it might work.
One issue is universal binaries on mac. It is possible to build universal native extensions. Apple has a page[1] with directions about what to do. If you use the version of ruby that ships with leopard, it builds 32bit universal extensions by default. However, these tricks only work if you build your gems with the version of ruby that ships with leopard. I bet you could probably patch rbconfig.rb (there are patches for 1.8.6-p114 in the ruby source that apple distributes[2]) for this to work with custom ruby installations. Personally, I just install the gems with the built-in version of ruby. For multiple 1.8 installations it's been working so far. [1]: http://developer.apple.com/releasenotes/OpenSource/PerlExtensionsRelNotes/index.html [2]: http://www.opensource.apple.com/darwinsource/10.5.6/ruby-67.4/ One thing Chris doesn't mention in the post is that the GEM_PATH env variable can be a list of paths. I usually set it so that my home dir is listed first, followed by the system location(s). Brian On Feb 17, 9:32 am, Rob Kaufman <[email protected]> wrote: > Hi Brian, > Thanks for the tip, that might be really interesting, especially > since I already drag my home directory around with me via git. When > you say its easy to move from machine to machine, do you have problems > with moving between architectures or operating systems? > > Thanks, > Rob > > On Fri, Feb 6, 2009 at 13:03, Brian Chapados <[email protected]> wrote: > > > FWIW, I've been keeping all of my gems in ~/.gems after reading this: > >http://ozmm.org/posts/local_gems.html > > > Your gems are easy to backup, and it's easy to use the same set of > > gems with different ruby installations. I also frequently need to work > > on systems where I don't have sudo/root access. Installing gems in my > > home dir allows makes it easy to maintain a consistent ruby > > environment. > > > Brian > > > On Feb 6, 11:08 am, Glenn Little <[email protected]> wrote: > >> In trying to get postgres working under ruby2.2.2 (an issue for > >> a separate email), I installed the ruby-pg gem: > > >> % sudo gem install ruby-pg > > >> Then I read on this page: > > >> http://rubyforge.org/forum/forum.php?forum_id=21187 > > >> that "the gem for ruby-pg is named 'pg'". Not sure what that really > >> means, but okay, I did: > > >> % sudo gem install pg > > >> Now, I cannot uninstall ruby-pg: > > >> % sudo gem uninstall ruby-pg > >> ERROR: While executing gem ... (Gem::InstallError) > >> Unknown gem ruby-pg >= 0 > > >> Same behavior if I uninstall pg first. > > >> Anyone have any ideas? In this email, in particular, how to uninstall > >> that gem so I can get a clean start? > > >> Thanks much... > > >> -glenn > > --~--~---------~--~----~------------~-------~--~----~ SD Ruby mailing list [email protected] http://groups.google.com/group/sdruby -~----------~----~----~----~------~----~------~--~---
