# How to tell if one is running 32 or 64 bit Ruby on Mac OS X?

**URL:** <https://www.ruby-forum.com/t/how-to-tell-if-one-is-running-32-or-64-bit-ruby-on-mac-os-x/159248>\
**Category:** Ruby\
**Created:** [February 2, 2009, 6:45pm UTC](https://www.ruby-forum.com/t/how-to-tell-if-one-is-running-32-or-64-bit-ruby-on-mac-os-x/159248 "2009-02-02T18:45:15Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![weyus](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/7ab992/32.png) [@weyus](https://www.ruby-forum.com/u/weyus)\
**Post date:** [February 2, 2009, 6:45pm UTC](https://www.ruby-forum.com/t/how-to-tell-if-one-is-running-32-or-64-bit-ruby-on-mac-os-x/159248/1 "2009-02-02T18:45:15Z")

</div>

All,

A friend just bought a new Mac and is trying to figure out whether they  
have 32 or 64 bit Ruby installed. This is the output of "file `which ruby`":

/usr/bin/ruby: Mach-O universal binary with 2 architectures  
/usr/bin/ruby (for architecture ppc7400): Mach-O executable ppc  
/usr/bin/ruby (for architecture i386): Mach-O executable i386

Can’t really tell from this. Does anyone know definitively if Mac OS X  
is still shipping with a 32 - bit version of Ruby or if there is a way  
to check?

Thanks,  
Wes

---

<div class="post-metadata">

**Author:** ![weyus](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/7ab992/32.png) [@weyus](https://www.ruby-forum.com/u/weyus)\
**Post date:** [February 2, 2009, 6:56pm UTC](https://www.ruby-forum.com/t/how-to-tell-if-one-is-running-32-or-64-bit-ruby-on-mac-os-x/159248/2 "2009-02-02T18:56:28Z")

</div>

On Mon, Feb 2, 2009 at 6:45 PM, Wes G. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Can’t really tell from this. Does anyone know definitively if Mac OS X  
> is still shipping with a 32 - bit version of Ruby or if there is a way  
> to check?
> 
> ## Thanks, Wes
> 
> Posted via [http://www.ruby-forum.com/](http://www.ruby-forum.com/).

Maybe  
ruby -v  
?

–  
Pozdrawiam

Rados³aw Bu³at  
[http://radarek.jogger.pl](http://radarek.jogger.pl) - mój blog

---

<div class="post-metadata">

**Author:** ![weyus](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/7ab992/32.png) [@weyus](https://www.ruby-forum.com/u/weyus)\
**Post date:** [February 2, 2009, 6:59pm UTC](https://www.ruby-forum.com/t/how-to-tell-if-one-is-running-32-or-64-bit-ruby-on-mac-os-x/159248/3 "2009-02-02T18:59:59Z")

</div>

On Mon, Feb 2, 2009 at 9:45 AM, Wes G. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> /usr/bin/ruby: Mach-O universal binary with 2 architectures  
> /usr/bin/ruby (for architecture ppc7400): Mach-O executable ppc  
> /usr/bin/ruby (for architecture i386): Mach-O executable i386

I can’t say with 100% conviction, but i386 is a 32-bit platform, so my  
guess would be that you’re running a 32-bit Ruby.

Quick way to find out: download and build (but don’t install!) Ruby,  
taking care to enable 64-bit. Then run your new ruby with -v and see  
what it outputs.

Ben

---

<div class="post-metadata">

**Author:** ![weyus](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/7ab992/32.png) [@weyus](https://www.ruby-forum.com/u/weyus)\
**Post date:** [February 2, 2009, 7:12pm UTC](https://www.ruby-forum.com/t/how-to-tell-if-one-is-running-32-or-64-bit-ruby-on-mac-os-x/159248/4 "2009-02-02T19:12:54Z")

</div>

On Tue, 3 Feb 2009 02:45:00 +0900, Wes G. wrote:

> Can’t really tell from this. Does anyone know definitively if Mac OS X  
> is still shipping with a 32 - bit version of Ruby or if there is a way  
> to check?

$ irb  
[‘foo’].pack(‘p’).size

8 on 64bit, 4 on 32bit. At least on Linux (and hopefully everywhere).

-jh

---

<div class="post-metadata">

**Author:** ![weyus](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/7ab992/32.png) [@weyus](https://www.ruby-forum.com/u/weyus)\
**Post date:** [February 2, 2009, 7:01pm UTC](https://www.ruby-forum.com/t/how-to-tell-if-one-is-running-32-or-64-bit-ruby-on-mac-os-x/159248/5 "2009-02-02T19:01:44Z")

</div>

> Maybe  
> ruby -v  
> ?

Output of ruby -v:

ruby 1.8.6 (2008-03-03 patchlevel 114) [universal-darwin9.0]

Does “universal-darwin9.0” imply 32-bit?

Wes

---

<div class="post-metadata">

**Author:** ![weyus](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/7ab992/32.png) [@weyus](https://www.ruby-forum.com/u/weyus)\
**Post date:** [February 2, 2009, 7:30pm UTC](https://www.ruby-forum.com/t/how-to-tell-if-one-is-running-32-or-64-bit-ruby-on-mac-os-x/159248/6 "2009-02-02T19:30:33Z")

</div>

Le 02 février à 18:45, Wes G. a écrit :

> Can’t really tell from this. Does anyone know definitively if Mac OS X  
> is still shipping with a 32 - bit version of Ruby or if there is a way  
> to check?

I’d try this :

ruby -rrbconfig -rpp -e ‘pp Config::CONFIG’

In my case (no MacOSX, though), I see things like this :

“arch”=\>“amd64-freebsd7”  
“sitearch”=\>“amd64-freebsd7”,  
“host\_cpu”=\>“amd64”,

Etc.

Fred

---

<div class="post-metadata">

**Author:** ![weyus](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/7ab992/32.png) [@weyus](https://www.ruby-forum.com/u/weyus)\
**Post date:** [February 2, 2009, 7:16pm UTC](https://www.ruby-forum.com/t/how-to-tell-if-one-is-running-32-or-64-bit-ruby-on-mac-os-x/159248/7 "2009-02-02T19:16:49Z")

</div>

> $ irb  
> [‘foo’].pack(‘p’).size
> 
> 8 on 64bit, 4 on 32bit. At least on Linux (and hopefully everywhere).
> 
> -jh

Thanks Jonathan!

---

<div class="post-metadata">

**Author:** ![weyus](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/7ab992/32.png) [@weyus](https://www.ruby-forum.com/u/weyus)\
**Post date:** [February 2, 2009, 9:47pm UTC](https://www.ruby-forum.com/t/how-to-tell-if-one-is-running-32-or-64-bit-ruby-on-mac-os-x/159248/8 "2009-02-02T21:47:40Z")

</div>

Wes G. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) writes:

> > Maybe  
> > ruby -v  
> > ?
> 
> Output of ruby -v:
> 
> ruby 1.8.6 (2008-03-03 patchlevel 114) [universal-darwin9.0]
> 
> Does “universal-darwin9.0” imply 32-bit?

Not really - a universal binary is one that works both on the older  
PowerPC architecture and the Intel Macs…

---

<div class="post-metadata">

**Author:** ![weyus](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/7ab992/32.png) [@weyus](https://www.ruby-forum.com/u/weyus)\
**Post date:** [February 3, 2009, 10:55am UTC](https://www.ruby-forum.com/t/how-to-tell-if-one-is-running-32-or-64-bit-ruby-on-mac-os-x/159248/9 "2009-02-03T10:55:31Z")

</div>

In article [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid),  
Wes G. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> /usr/bin/ruby: Mach-O universal binary with 2 architectures  
> /usr/bin/ruby (for architecture ppc7400): Mach-O executable ppc  
> /usr/bin/ruby (for architecture i386): Mach-O executable i386
> 
> Can’t really tell from this. Does anyone know definitively if Mac OS X  
> is still shipping with a 32 - bit version of Ruby or if there is a way  
> to check?

A 64-bit binary will show x86\_64 and ppc64:

1011 [0:41] roberto@rron:yarv/build\> file =trn  
/usr/local/bin/trn: Mach-O 64-bit executable x86\_64

(my trn is not universal but it is a 64 bit one).

---

<div class="post-metadata">

**Author:** ![weyus](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/7ab992/32.png) [@weyus](https://www.ruby-forum.com/u/weyus)\
**Post date:** [February 2, 2009, 10:52pm UTC](https://www.ruby-forum.com/t/how-to-tell-if-one-is-running-32-or-64-bit-ruby-on-mac-os-x/159248/10 "2009-02-02T22:52:56Z")

</div>

On 02.02.2009, at 21:45, Timo Geusch wrote:

> > Does “universal-darwin9.0” imply 32-bit?
> 
> Not really - a universal binary is one that works both on the older  
> PowerPC architecture and the Intel Macs…

Just to add a universal binary is a container binary, in which you  
can add several CPU architectures. Use `lipo’ if you want more  
information or add/delete architectures.

$ lipo -detailed\_info /usr/bin/ruby  
Fat header in: /usr/bin/ruby  
fat\_magic 0xcafebabe  
nfat\_arch 2  
architecture ppc7400  
cputype CPU\_TYPE\_POWERPC  
cpusubtype CPU\_SUBTYPE\_POWERPC\_7400  
offset 4096  
size 13776  
align 2^12 (4096)  
architecture i386  
cputype CPU\_TYPE\_I386  
cpusubtype CPU\_SUBTYPE\_I386\_ALL  
offset 20480  
size 17824  
align 2^12 (4096)

If you want to run it on a specific platform use `arch’  
$ arch -arch x86\_64 /usr/bin/ruby  
arch: posix\_spawnp: /usr/bin/ruby: Bad CPU type in executable  
zsh: exit 1 arch -arch x86\_64 /usr/bin/ruby  
$ arch -arch ppc /usr/bin/ruby  
^C

The manpage of `arch’ :  
-------------8\<-------------  
The arch\_name argument must be one of the currently supported  
architectures:

```
        i386 32-bit intel

        ppc 32-bit powerpc

        ppc64 64-bit powerpc

        x86_64 64-bit intel

```

-------------\>8-------------

regards, Sandor  
Sz

---

<div class="post-metadata">

**Author:** ![weyus](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/7ab992/32.png) [@weyus](https://www.ruby-forum.com/u/weyus)\
**Post date:** [April 10, 2009, 8:35pm UTC](https://www.ruby-forum.com/t/how-to-tell-if-one-is-running-32-or-64-bit-ruby-on-mac-os-x/159248/11 "2009-04-10T20:35:05Z")

</div>

> A friend just bought a new Mac and is trying to figure out whether they  
> have 32 or 64 bit Ruby installed.

As a note for linode users, you should probably install the 32 bit  
version of your OS instead of the 64 bit version so that your rails  
processes use half as much memory 🙂

Cheers!  
-=r

---

<div class="post-metadata">

**Author:** ![weyus](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/7ab992/32.png) [@weyus](https://www.ruby-forum.com/u/weyus)\
**Post date:** [February 3, 2009, 1:07pm UTC](https://www.ruby-forum.com/t/how-to-tell-if-one-is-running-32-or-64-bit-ruby-on-mac-os-x/159248/12 "2009-02-03T13:07:56Z")

</div>

Wes G. wrote:

> All,
> 
> A friend just bought a new Mac and is trying to figure out whether they  
> have 32 or 64 bit Ruby installed. This is the output of “file `which ruby`”:
> 
> /usr/bin/ruby: Mach-O universal binary with 2 architectures  
> /usr/bin/ruby (for architecture ppc7400): Mach-O executable ppc  
> /usr/bin/ruby (for architecture i386): Mach-O executable i386
> 
> Can’t really tell from this. Does anyone know definitively if Mac OS X  
> is still shipping with a 32 - bit version of Ruby or if there is a way  
> to check?

The stock Ruby 1.8.6 installation on 10.5 consists of a 4-way fat (ppc +  
ppc64 + i386 + x86\_64) framework build which you’ll find in  
/System/Library/Frameworks, with a 32-bit fat command line interpreter  
symlinked to /usr/bin/ruby. This means Ruby will run as 32-bit in 32-bit  
processes (e.g. when running scripts via /usr/bin/ruby) and as 64-bit in  
64-bit processes.

HTH

## has

Control AppleScriptable applications from Python, Ruby and ObjC:

> **[appscript](https://appscript.sourceforge.io/)**

---

<div class="post-metadata">

**Author:** ![weyus](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/7ab992/32.png) [@weyus](https://www.ruby-forum.com/u/weyus)\
**Post date:** [February 3, 2009, 2:32pm UTC](https://www.ruby-forum.com/t/how-to-tell-if-one-is-running-32-or-64-bit-ruby-on-mac-os-x/159248/13 "2009-02-03T14:32:06Z")

</div>

On Feb 3, 2009, at 7:07 AM, hengist podd wrote:

> > /usr/bin/ruby (for architecture i386): Mach-O executable i386  
> > /System/Library/Frameworks, with a 32-bit fat command line interpreter  
> > Control AppleScriptable applications from Python, Ruby and ObjC:  
> > [http://appscript.sourceforge.net](http://appscript.sourceforge.net)
> 
> –

This came up at least once before so a search of the archive may yield  
a better answer, but one possible way is to see how big a Fixnum is in  
bytes:

$ ruby -v  
ruby 1.8.6 (2008-03-03 patchlevel 114) [universal-darwin9.0]  
$ ruby -e “puts 1.size”  
4

-Rob

Rob B. [http://agileconsultingllc.com](http://agileconsultingllc.com)  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![weyus](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/7ab992/32.png) [@weyus](https://www.ruby-forum.com/u/weyus)\
**Post date:** [June 29, 2009, 7:05pm UTC](https://www.ruby-forum.com/t/how-to-tell-if-one-is-running-32-or-64-bit-ruby-on-mac-os-x/159248/14 "2009-06-29T19:05:47Z")

</div>

> The stock Ruby 1.8.6 installation on 10.5 consists of a 4-way fat (ppc +  
> ppc64 + i386 + x86\_64) framework build which you’ll find in  
> /System/Library/Frameworks, with a 32-bit fat command line interpreter  
> symlinked to /usr/bin/ruby. This means Ruby will run as 32-bit in 32-bit  
> processes (e.g. when running scripts via /usr/bin/ruby) and as 64-bit in  
> 64-bit processes.

So, /usr/bin/ruby invokes the 32-bit version, how do we invoke the  
64-bit version?

– gw
