https://bugs.ruby-lang.org/https://bugs.ruby-lang.org/favicon.ico?17113305112020-03-29T15:16:04ZRuby Issue Tracking SystemRuby master - Feature #16742: RbConfig.windows? and RbConfig.host_oshttps://bugs.ruby-lang.org/issues/16742?journal_id=848072020-03-29T15:16:04ZEregon (Benoit Daloze)
<ul><li><strong>Description</strong> updated (<a title="View differences" href="/journals/84807/diff?detail_id=56713">diff</a>)</li></ul> Ruby master - Feature #16742: RbConfig.windows? and RbConfig.host_oshttps://bugs.ruby-lang.org/issues/16742?journal_id=848092020-03-29T15:19:37ZEregon (Benoit Daloze)
<ul></ul><p>Also worth nothing <code>RUBY_PLATFORM =~ /(mswin|mingw)/</code> is hacky and incomplete, and there are many subtle variants of that check such as <code>RUBY_PLATFORM =~ /win32|mingw|bccwin|cygwin/</code>.<br>
<code>RbConfig.windows?</code> would be far more reliable and easier to read.</p> Ruby master - Feature #16742: RbConfig.windows? and RbConfig.host_oshttps://bugs.ruby-lang.org/issues/16742?journal_id=848102020-03-29T16:59:44Zshevegen (Robert A. Heiler)shevegen@gmail.com
<ul></ul><p>I agree that <code>RbConfig.windows?</code> seems intuitive to me, in the sense that it would or<br>
could or should refer to the windows (Microsoft) platform.</p>
<p>I also concur with the explanation given.</p>
<p>As for <code>RbConfig.host_os</code> - I have no real preference either way, but I think it would<br>
be an ok addition too; it is shorter. People who prefer the longer variant can still<br>
use the longer variant too, so no change is necessary. So that suggestion seems ok<br>
as well (to me) - but I have no real preference here (so mostly neutral), whereas<br>
I do think RbConfig.windows? I am fairly positive.</p>
<blockquote>
<p>Also worth nothing <code>RUBY_PLATFORM =~ /(mswin|mingw)/</code> is hacky and incomplete,<br>
and there are many subtle variants of that check such as<br>
<code>RUBY_PLATFORM =~ /win32|mingw|bccwin|cygwin/</code>.</p>
</blockquote>
<p>Reminds me of ms-greg (I don't recall the proper name right now, sorry).</p>
<p>But anyway, my personal opinion is that the suggestions here seem useful. I also<br>
think there is no trade off when using "<code>.windows?</code>" since I do not think it will<br>
conflict with anything else. (I have not so strong a preference to comment on<br>
<code>.host_os</code>, I leave that to others if they feel strongly about it either way.)</p> Ruby master - Feature #16742: RbConfig.windows? and RbConfig.host_oshttps://bugs.ruby-lang.org/issues/16742?journal_id=849742020-04-09T02:43:06Znobu (Nobuyoshi Nakada)nobu@ruby-lang.org
<ul><li><strong>Description</strong> updated (<a title="View differences" href="/journals/84974/diff?detail_id=56812">diff</a>)</li></ul> Ruby master - Feature #16742: RbConfig.windows? and RbConfig.host_oshttps://bugs.ruby-lang.org/issues/16742?journal_id=849892020-04-10T05:54:10Zmatz (Yukihiro Matsumoto)matz@ruby.or.jp
<ul></ul><p>The <code>#host_os</code> seems OK.</p>
<p>Regarding <code>#windows?</code>, what do you want to check using the value? Drive letter? Path separator? Case insensitivity? Process behavior? Posix compatibility? Should it be true on Cygwin? It is not clear yet.</p>
<p>Matz.</p> Ruby master - Feature #16742: RbConfig.windows? and RbConfig.host_oshttps://bugs.ruby-lang.org/issues/16742?journal_id=849902020-04-10T06:00:18Znobu (Nobuyoshi Nakada)nobu@ruby-lang.org
<ul></ul><p>Is <code>host_os</code> what you want to see?<br>
<code>RbConfig::CONFIG['host_os']</code> is bare value by config.guess, like "linux-gnu", "darwin19.4.0", etc.<br>
<code>RUBY_PLATFORM</code> consists of "target_cpu" and "target_os" instead.</p> Ruby master - Feature #16742: RbConfig.windows? and RbConfig.host_oshttps://bugs.ruby-lang.org/issues/16742?journal_id=850082020-04-10T11:53:23ZEregon (Benoit Daloze)
<ul></ul><p>For <code>RbConfig.host_os</code> I expect the same as <code>RbConfig::CONFIG['host_os']</code>, or better slightly simplified (no version, no variant information)<br>
like <code>linux</code>, <code>darwin</code>, <code>mingw</code>, <code>mswin</code>, etc (easier to check, and we could document the various possible values).</p>
<p>Similar to process.platform() on Node.js:<br>
<a href="https://nodejs.org/api/process.html#process_process_platform" class="external">https://nodejs.org/api/process.html#process_process_platform</a> (except win32 => windows)</p>
<p>For <code>RbConfig.windows?</code> that would include at least mswin and mingw.</p>
<p>Not sure about cygwin, what do you think <a class="user active user-mention" href="https://bugs.ruby-lang.org/users/11129">@MSP-Greg (Greg L)</a>?<br>
WSL would clearly be false for <code>RbConfig.windows?</code>, so I think it should be <code>false</code> for cygwin too since it also tries to hide the fact you're on Windows.</p>
<p>There are many checks for Windows for various reasons, but notably for whether some system features are supported.<br>
Some of them can be checked more directly (e.g., fork, unix sockets) but not all (e.g., proper support for creating symlinks) which explain why we see <code>RUBY_PLATFORM =~ /(mswin|mingw)/</code> in so many gems and tests and specs.</p> Ruby master - Feature #16742: RbConfig.windows? and RbConfig.host_oshttps://bugs.ruby-lang.org/issues/16742?journal_id=850512020-04-11T14:00:38ZMSP-Greg (Greg L)
<ul></ul><blockquote>
<p>it should be false for cygwin too since it also tries to hide the fact you're on Windows.</p>
</blockquote>
<p>Agreed. I think. I've never worked with the platform.</p>
<p>I've seen many gems/repos that have <code>.windows?</code>, <code>.darwin?</code>, <code>.jruby?</code>, <code>.mingw?</code>, <code>mswin?</code>, etc in their library or test code. Adding any similar predicate methods to Ruby would be helpful. Some use constants (<code>RbConfig::WINDOWS</code>, <code>RbConfig::DARWIN</code>, etc)...</p>