[Rubyinstaller-devel] Gem compatibility and platform specific dependencies

Gordon Thiesfeld gthiesfeld at gmail.com
Fri Apr 25 00:01:21 EDT 2008

This may be better asked on the RubyGems list, but I thought I'd try
here first.  I'm working on a patch[1] for the github gem[2].  The
github command requires open3, which doesn't work on Windows because
of fork, so I have it check for platform, and require WIn32-Open3 if
on Windows.  So, I have two questions about how to go about this.

First, is Gem.win_platform?  the proper way to go about this.  I think
it's safe to say this package will always be distributed as a gem, so
Gem will always exist when I need it.

Second, is there a way to have Gem depedencies that are platform
specific?  Open3 is part of the stdlib, so no dependency there, but on
Windows we need the Win32 gem.  I've borrowed a pattern from RSpec for

    require 'win32 package'
  rescue LoadError
    warn "You must 'gem install the win32 package to do this on Windows"
    exit 1

But in the case of RSpec, it's only used for colored console output.
If you don't use that feature, you'll never know you need to have the
gem installed.  In this case, the whole thing just won't work.
That's what dependencies are all about, I'd think.  If there isn't
such a thing as platform specific dependencies, then what I'm fine
doing it this way.  I'm just wondering if there's a better way.



[1] http://github.com/vertiginous/github-gem/commit/a4f54d3b8d51549ff9922c55de160b713a761d8b
[2] http://github.com/defunkt/github-gem/tree/master

More information about the Rubyinstaller-devel mailing list