Hello Thierry.
Can you explain it better?
Detecting Windows using RUBY_PLATFORM is not correct:
http://blog.emptyway.com/2009/11/03/proper-way-to-detect-windows-platform-in-ruby/
We can't change the RubyInstaller platform (since is part of Ruby own
internals) and neither how RubyGems identify it.
Gem authors should be in charge of correct gem platform detection.
As shortcut I had used in the past:
RUBY_PLATFORM =~ /mingw|mswin/
Which covers 32 and 64bits versions of Ruby on both mswin and mingw
distributions.
--
Luis Lavena
AREA 17
-
Perfection in design is achieved not when there is nothing more to add,
but rather when there is nothing more to take away.
Antoine de Saint-Exupéry
The only real "native" way is to check for
ENV['OS'] == 'Windows_NT'
My suggestion would be to tell all of those authors to use the new
regex, as you specified.
-r
rbconfig is part of *all* versions of Ruby, no matter what implementation.
> More specifically, I grepped my installed gems for '/win32/', and
> found this:
>
> C:\Ruby\lib\ruby\gems\1.8\gems\daemons-1.1.0\lib\daemons
> \application.rb
> SIGNAL = (RUBY_PLATFORM =~ /win32/ ? 'KILL' : 'TERM')
>
Gem author issue, is not Ruby fault, more on this:
http://blog.mmediasys.com/2008/10/21/guas-is-giving-unwanted-advice-series-1/
> C:\Ruby\lib\ruby\gems\1.8\gems\ZenTest-4.3.3\lib\autotest.rb
> WINDOZE = /win32/ =~ RUBY_PLATFORM
>
I hate to say it but some patches to ZenTest are sitting getting dust
in RubyForge.
> C:\Ruby\lib\ruby\gems\1.8\gems\ZenTest-4.3.3\lib\unit_diff.rb
> WINDOZE = /win32/ =~ RUBY_PLATFORM unless defined? WINDOZE
>
Same as above.
> I know redgreen has the same problem, by the way, but I uninstalled
> it, so it does not show.
>
> Should I report to the gem authors? What would be a "native" way to
> detect Windows on all patforms? Would RUBY_PLATFORM =~ /mingw|mswin/
> be OK?
>
The RUBY_PLATFORM regexp is good in the short term, but moving forward
and considering other implementations as JRuby, the real one is use
RbConfig::CONFIG['host_os'] option with the regexp.
HTH,
That is way too brittle and will not work when doing cross compilation
or anything like that.
Safety note: stick to RbConfig::CONFIG['host_os'], please