Forum: Ruby Get system name

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
125aa997aecefa6ebd4431f9b89e0bed?d=identicon&s=25 Kless (Guest)
on 2008-10-14 19:30
(Received via mailing list)
Is there any method that returns the operating sytem being used?
C1138881c3c40b21e9415a3c1fdd3a0b?d=identicon&s=25 Victor Goff (kotp)
on 2008-10-14 19:37
(Received via mailing list)
Check out the Ruby Constants... PLATFORM could be one.
Beb77c4602c3cac7a12149431366ed11?d=identicon&s=25 The Higgs bozo (higgsbozo)
on 2008-10-14 20:03
Victor Goff wrote:
> Check out the Ruby Constants... PLATFORM could be one.

The constant is RUBY_PLATFORM.

If more info is needed, check the output of this,

require 'rbconfig'
require 'pp'
pp Config::CONFIG
13d248fdecc97b72e568ce489a735609?d=identicon&s=25 Nedry (Guest)
on 2008-10-14 20:08
(Received via mailing list)
That's a great alias!  I wish I'd thought of it.
Now someone unsubscribe me from this list, dammit.  I can't figure out
how,
cause I'm a moron!

(Just kidding, don't really unsub me...)

On Tue, Oct 14, 2008 at 7:03 PM, The Higgs bozo
<higgs.bozo@gmail.com>wrote:

>
> --
Angels and ministers of grace defend us!

- Hamlet, Act I, Scene 4
125aa997aecefa6ebd4431f9b89e0bed?d=identicon&s=25 Kless (Guest)
on 2008-10-14 20:45
(Received via mailing list)
On 14 oct, 19:03, The Higgs bozo <higgs.b...@gmail.com> wrote:
> Victor Goff wrote:
> > Check out the Ruby Constants... PLATFORM could be one.
>
> The constant is RUBY_PLATFORM.
I haven't that constant, but 'target_os'.
Beb77c4602c3cac7a12149431366ed11?d=identicon&s=25 The Higgs bozo (higgsbozo)
on 2008-10-14 21:17
Kless wrote:
> On 14 oct, 19:03, The Higgs bozo <higgs.b...@gmail.com> wrote:
>> Victor Goff wrote:
>> > Check out the Ruby Constants... PLATFORM could be one.
>>
>> The constant is RUBY_PLATFORM.
> I haven't that constant, but 'target_os'.

RUBY_PLATFORM is a top-level constant, apart from Config::CONFIG.

  $ ruby -e 'p RUBY_PLATFORM'
Aee77dba395ece0a04c688b05b07cd63?d=identicon&s=25 Daniel Berger (Guest)
on 2008-10-14 21:26
(Received via mailing list)
On Oct 14, 12:03 pm, The Higgs bozo <higgs.b...@gmail.com> wrote:
> Victor Goff wrote:
> > Check out the Ruby Constants... PLATFORM could be one.
>
> The constant is RUBY_PLATFORM.

I recommend against this because of JRuby (and probably IronRuby).
JRuby, for example, will return "java" for RUBY_PLATFORM.

> If more info is needed, check the output of this,
>
> require 'rbconfig'
> require 'pp'
> pp Config::CONFIG

There you go. Take a look at Config['host_os'].

Regards,

Dan
Beb77c4602c3cac7a12149431366ed11?d=identicon&s=25 The Higgs bozo (higgsbozo)
on 2008-10-14 21:55
Daniel Berger wrote:
> On Oct 14, 12:03�pm, The Higgs bozo <higgs.b...@gmail.com> wrote:
>> Victor Goff wrote:
>> > Check out the Ruby Constants... PLATFORM could be one.
>>
>> The constant is RUBY_PLATFORM.
>
> I recommend against this because of JRuby (and probably IronRuby).
> JRuby, for example, will return "java" for RUBY_PLATFORM.
>
>> If more info is needed, check the output of this,
>>
>> require 'rbconfig'
>> require 'pp'
>> pp Config::CONFIG
>
> There you go. Take a look at Config['host_os'].

I wonder if RUBY_PLATFORM should be deprecated, then?

I've used 'target_os' in the past, a decision I rationalized thusly: on
the off chance that ruby spits out an executable of any form, I want the
platform of that executable.  In hindsight I wonder if it makes any
sense.

Is there an example of CONFIG["target_os"] != CONFIG["host_os"] ?
125aa997aecefa6ebd4431f9b89e0bed?d=identicon&s=25 Kless (Guest)
on 2008-10-17 12:08
(Received via mailing list)
On 14 oct, 20:55, The Higgs bozo <higgs.b...@gmail.com> wrote:
> Is there an example of CONFIG["target_os"] != CONFIG["host_os"] ?
Yes, my Ubuntu shows:

$ ruby -e 'require "rbconfig"; p Config::CONFIG["host_os"],
Config::CONFIG["target_os"]'

"linux-gnu"
"linux"
This topic is locked and can not be replied to.