# Get system name

**URL:** <https://www.ruby-forum.com/t/get-system-name/150894>\
**Category:** Ruby\
**Created:** [October 14, 2008, 7:30pm UTC](https://www.ruby-forum.com/t/get-system-name/150894 "2008-10-14T19:30:45Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kless](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/cc9497/32.png) [@Kless](https://www.ruby-forum.com/u/Kless)\
**Post date:** [October 14, 2008, 7:30pm UTC](https://www.ruby-forum.com/t/get-system-name/150894/1 "2008-10-14T19:30:45Z")

</div>

Is there any method that returns the operating sytem being used?

---

<div class="post-metadata">

**Author:** ![Kless](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/cc9497/32.png) [@Kless](https://www.ruby-forum.com/u/Kless)\
**Post date:** [October 14, 2008, 7:37pm UTC](https://www.ruby-forum.com/t/get-system-name/150894/2 "2008-10-14T19:37:48Z")

</div>

Check out the Ruby Constants… PLATFORM could be one.

---

<div class="post-metadata">

**Author:** ![Kless](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/cc9497/32.png) [@Kless](https://www.ruby-forum.com/u/Kless)\
**Post date:** [October 14, 2008, 8:03pm UTC](https://www.ruby-forum.com/t/get-system-name/150894/3 "2008-10-14T20:03:54Z")

</div>

Victor G. 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

---

<div class="post-metadata">

**Author:** ![Kless](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/cc9497/32.png) [@Kless](https://www.ruby-forum.com/u/Kless)\
**Post date:** [October 14, 2008, 8:45pm UTC](https://www.ruby-forum.com/t/get-system-name/150894/4 "2008-10-14T20:45:59Z")

</div>

On 14 oct, 19:03, The Higgs bozo [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Victor G. wrote:
> 
> > Check out the Ruby Constants… PLATFORM could be one.
> 
> The constant is RUBY\_PLATFORM.  
> I haven’t that constant, but ‘target\_os’.

---

<div class="post-metadata">

**Author:** ![Kless](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/cc9497/32.png) [@Kless](https://www.ruby-forum.com/u/Kless)\
**Post date:** [October 14, 2008, 8:08pm UTC](https://www.ruby-forum.com/t/get-system-name/150894/5 "2008-10-14T20:08:23Z")

</div>

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  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)wrote:

> –  
> Angels and ministers of grace defend us!

- Hamlet, Act I, Scene 4

---

<div class="post-metadata">

**Author:** ![Kless](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/cc9497/32.png) [@Kless](https://www.ruby-forum.com/u/Kless)\
**Post date:** [October 14, 2008, 9:17pm UTC](https://www.ruby-forum.com/t/get-system-name/150894/6 "2008-10-14T21:17:20Z")

</div>

Kless wrote:

> On 14 oct, 19:03, The Higgs bozo [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:
> 
> > Victor G. 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’

---

<div class="post-metadata">

**Author:** ![Kless](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/cc9497/32.png) [@Kless](https://www.ruby-forum.com/u/Kless)\
**Post date:** [October 14, 2008, 9:26pm UTC](https://www.ruby-forum.com/t/get-system-name/150894/7 "2008-10-14T21:26:34Z")

</div>

On Oct 14, 12:03 pm, The Higgs bozo [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Victor G. 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

---

<div class="post-metadata">

**Author:** ![Kless](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/cc9497/32.png) [@Kless](https://www.ruby-forum.com/u/Kless)\
**Post date:** [October 17, 2008, 12:08pm UTC](https://www.ruby-forum.com/t/get-system-name/150894/8 "2008-10-17T12:08:22Z")

</div>

On 14 oct, 20:55, The Higgs bozo [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) 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”

---

<div class="post-metadata">

**Author:** ![Kless](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/cc9497/32.png) [@Kless](https://www.ruby-forum.com/u/Kless)\
**Post date:** [October 14, 2008, 9:55pm UTC](https://www.ruby-forum.com/t/get-system-name/150894/9 "2008-10-14T21:55:59Z")

</div>

Daniel B. wrote:

> On Oct 14, 12:03ï¿½pm, The Higgs bozo [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:
> 
> > Victor G. 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”] ?
