[Rubyinstaller-devel] Gem compatibility and platform specific dependencies

Gordon Thiesfeld gthiesfeld at gmail.com
Fri Apr 25 02:02:11 EDT 2008

On Thu, Apr 24, 2008 at 11:21 PM, Luis Lavena <luislavena at gmail.com> wrote:
> On Fri, Apr 25, 2008 at 1:01 AM, Gordon Thiesfeld <gthiesfeld at gmail.com> wrote:
>  > 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.
>  >
>  I think is safe to assume Gem.win_platform? is available since you're
>  implementing that into a project that get's distributed/installed as
>  gem.
>  The only problem is that win_platform? will be 'true' even for cygwin
>  implementation, which will render win32/open3 useless and I can smell
>  that will crash :-P

Oh yeah, I forgot about cygwin.  I guess open3 works on cygwin?  Is
this the proper regex, then?

RUBY_PLATFORM =~ /mswin|mingw/

>  >  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
>  >  this:
>  >
>  To our bad, there isn't a way to do that, you can create a
>  "windows-specific" version and in that gem include the dependencies,
>  but without a real need to do that, I think workaround in the code
>  should be used.

I was hoping I'd missed something simple, like:

add_dependency() if Gem.win_platform?

But if it's not there I'm not going to ask for it.  At least not in this case.

>  >   begin
>  >     require 'win32 package'
>  >   rescue LoadError
>  >     warn "You must 'gem install the win32 package to do this on Windows"
>  >     exit 1
>  >   end
>  >
>  >  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.
>  >
>  A good workaround will be poke the ruby-core developers to merge
>  win32/open3 package in and reduce our code cluttery, but I don't see
>  that will happen anytime soon :-P

I don't follow ruby-core that much, has this ever been suggested?  I'm
sure it must have at some point.

>  >  Thanks,
>  Thanks to you Gordon!
>  BTW: just pushed installer3 into the repository:
>  http://rubyinstaller.rubyforge.org/svn/trunk/installer3/

Should I switch from bzr to svn, or hold out for the git repo announcement ;-)

-- Gordon

More information about the Rubyinstaller-devel mailing list