# Re: Mac OSX Ruby Configuration Question

**URL:** <https://www.ruby-forum.com/t/re-mac-osx-ruby-configuration-question/99106>\
**Category:** Ruby\
**Created:** [July 20, 2006, 10:10am UTC](https://www.ruby-forum.com/t/re-mac-osx-ruby-configuration-question/99106 "2006-07-20T10:10:53Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![daveh](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/85e7bf/32.png) [@daveh](https://www.ruby-forum.com/u/daveh)\
**Post date:** [July 20, 2006, 10:10am UTC](https://www.ruby-forum.com/t/re-mac-osx-ruby-configuration-question/99106/1 "2006-07-20T10:10:53Z")

</div>

On Jul 18, 2006, at 8:33, Ryan R. wrote:

1. Two days ago, I once again had a Ruby program fail because it’s  
running the wrong Ruby, and I eventually had to give up on this one. My  
text editing program lets me run text through shell scripts as text  
filters; so I wrote a Ruby script to pretty-format HTML. Except I can’t  
run it, because all the gems are installed into 1.8.4. The scripts  
inherit their environment from the text editor, which inherits it from  
the Finder, which does not use ~/.bash\_login, nor /etc/profile, nor  
/etc/bashrc, nor any other file which I can find on my system.

[It’s using SOMETHING, because it has  
PATH=/usr/bin:/bin:/usr/sbin:/sbin:/Users/dave, which isn’t what you  
get from “bash --noprofile”]

Configuring ~/.MacOSX/environment.plist will probably help this one.

Alas, I have no such file on my system. Nor even a ~/.MacOSX directory.

$ cd ~/.MacOSX  
-bash: cd: /Users/dave/.MacOSX: No such file or directory

Today, in 10.4, the unix way works most of the time

Note that I do not run 10.4. There was insufficient value compared to  
cost to justify upgrading from 10.3, especially since reliability is  
greatly enhanced through consistency, and running 10.4 would mean  
upgrading 4 systems to OSX 10.4, and one to OSX 10.4 Server, a  
monumental expense. So I’m keeping all my systems synchronized on 10.3  
for now.

I believe that most of the time, it is best to recommend the unix way of  
doing things as that knowledge will both continue to be useful on OS X  
and is transferable to other unices.

Unlike most of the people on this list, I have every intention of  
avoiding “other Unixes.” A solution that is specific to OSX with  
greater reliability is significantly more valuable to me than one that  
applies to Unix in general but only works “most of the time” on OSX.

Your Mileage May Vary.

---

<div class="post-metadata">

**Author:** ![daveh](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/85e7bf/32.png) [@daveh](https://www.ruby-forum.com/u/daveh)\
**Post date:** [July 20, 2006, 2:41pm UTC](https://www.ruby-forum.com/t/re-mac-osx-ruby-configuration-question/99106/2 "2006-07-20T14:41:31Z")

</div>

On Jul 20, 2006, at 4:08 AM, Dave H. wrote:

> Configuring ~/.MacOSX/environment.plist will probably help this one.
> 
> Alas, I have no such file on my system. Nor even a ~/.MacOSX  
> directory.  
> The developer link provided previously seems like you just have to  
> create the directory/file yourself.

> Unlike most of the people on this list, I have every intention of  
> avoiding “other Unixes.” A solution that is specific to OSX with  
> greater reliability is significantly more valuable to me than one  
> that applies to Unix in general but only works “most of the time”  
> on OSX.  
> You might find more information OSX-centric mailing lists, then.  
> Good luck!  
> -Mat

---

<div class="post-metadata">

**Author:** ![daveh](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/85e7bf/32.png) [@daveh](https://www.ruby-forum.com/u/daveh)\
**Post date:** [July 20, 2006, 3:00pm UTC](https://www.ruby-forum.com/t/re-mac-osx-ruby-configuration-question/99106/3 "2006-07-20T15:00:33Z")

</div>

On Thursday, July 20, 2006, at 5:08 PM, Dave H. wrote:

> On Jul 18, 2006, at 8:33, Ryan R. wrote:
> 
> > Configuring ~/.MacOSX/environment.plist will probably help this one.
> 
> Alas, I have no such file on my system. Nor even a ~/.MacOSX directory.

From the link that was posted:

Q: How do I set environment for all processes launched by a specific  
user?

A: It is actually fairly simple process to set environment variables for  
processes launched by a specific user.

There is a special environment file which loginwindow searches for each  
time a user logs in. The environment file is: ~/.MacOSX/  
environment.plist (be careful it’s case sensitive). Where ‘~’ is the  
home directory of the user we are interested in.

You will have to create the .MacOSX directory yourself using terminal  
(by typing mkdir .MacOSX).

You will also have to create the environment file yourself. The  
environment file is actually in XML/plist format (make sure to add the  
.plist extension to the end of the filename or this won’t work). An  
example environment file is shown below. The file was created using /  
Developer/Applications/PropertyListEditor.app

---

<div class="post-metadata">

**Author:** ![daveh](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/85e7bf/32.png) [@daveh](https://www.ruby-forum.com/u/daveh)\
**Post date:** [July 21, 2006, 12:08am UTC](https://www.ruby-forum.com/t/re-mac-osx-ruby-configuration-question/99106/4 "2006-07-21T00:08:23Z")

</div>

On Jul 20, 2006, at 5:39, Mat S. wrote:

> On Jul 20, 2006, at 4:08 AM, Dave H. wrote:
> 
> > On Jul 18, 2006, at 8:33, Ryan R. wrote:
> > 
> > > Configuring ~/.MacOSX/environment.plist will probably help this one.  
> > > Alas, I have no such file on my system. Nor even a ~/.MacOSX  
> > > directory.  
> > > The developer link provided previously seems like you just have to  
> > > create the directory/file yourself.

[sheepishly takes the time to RTFM] I just assumed that “configuring”  
meant editing an existing file. Oops.

> > A solution that is specific to OSX with greater reliability is  
> > significantly more valuable to me than one that applies to Unix in  
> > general but only works “most of the time” on OSX.

And look, here’s a more-reliable OSX-specific solution dropped in my  
lap.

Thanks Ryan, and how the _heck_ did you ever find out about that in the  
first place?

---

<div class="post-metadata">

**Author:** ![daveh](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/85e7bf/32.png) [@daveh](https://www.ruby-forum.com/u/daveh)\
**Post date:** [July 21, 2006, 11:13pm UTC](https://www.ruby-forum.com/t/re-mac-osx-ruby-configuration-question/99106/5 "2006-07-21T23:13:11Z")

</div>

On Friday, July 21, 2006, at 7:07 AM, Dave H. wrote:

> Thanks Ryan, and how the _heck_ did you ever find out about that in the  
> first place?

Pain, frustration, aggravation, more frustration, and more pain. I have  
no idea why it is not more extensively advertised in the apple docs.  
But given how long it took me to find it out, it will probably be the  
one piece of information I will take to my grave - long after I have  
lost track of my own name, I will still know about that  
environment.plist file.

Best,

-r

---

<div class="post-metadata">

**Author:** ![daveh](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/85e7bf/32.png) [@daveh](https://www.ruby-forum.com/u/daveh)\
**Post date:** [July 22, 2006, 3:22am UTC](https://www.ruby-forum.com/t/re-mac-osx-ruby-configuration-question/99106/6 "2006-07-22T03:22:42Z")

</div>

On Saturday, July 22, 2006, at 9:20 AM, Dave H. wrote:

> #!/usr/bin/env ruby
> 
> This works beautifully from the command line, but gives me 1.6.8 ruby  
> when I call the script from TextWrangler.
> 
> I modified my environment.plist to contain the following:
> 
> ```
> <key>PATH</key>
> <string>/Library/Ruby/Bin:$PATH</string>
> 
> ```

You’re going about it backwards. If you have PATH in your  
environment.plist file, then it is the ultimate source for your path -  
so you should put in a fully qualified set of default paths, something  
like

PATH  
/Library/Ruby/bin:/bin:/sbin:/usr/bin:/usr/sbin

and then if you modify your PATH in .bash\_profile (or wherever) like so

export PATH=/monkey/bin:$PATH

then you will end up with an ultimate path of

/monkey/bin:/Library/Ruby/bin:/bin:/sbin:/usr/bin:/usr/sbin

at the end of the day

-r

---

<div class="post-metadata">

**Author:** ![daveh](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/85e7bf/32.png) [@daveh](https://www.ruby-forum.com/u/daveh)\
**Post date:** [July 24, 2006, 2:03am UTC](https://www.ruby-forum.com/t/re-mac-osx-ruby-configuration-question/99106/7 "2006-07-24T02:03:43Z")

</div>

On Jul 21, 2006, at 18:20, Ryan R. wrote:

> You’re going about it backwards. If you have PATH in your  
> environment.plist file, then it is the ultimate source for your path -

Well, the ultimate source for that user. What I want is for it to  
respect the path as set by /etc/profile for all users, or better yet,  
just find out where the Ur-path comes from, so that I can include Ruby  
on the path for every shell ever created anywhere on the system  
(interactively or not) by anything except when specifically excluded.

Particularly when I’m working on my server, I frequently need to switch  
back and forth between my “regular” account, my “administrator”  
accounts (local and domain), and the super-user account, and having all  
my handy scripts, aliases, and whatnot vanish between them is  
inconvenient. 😕

Hmm. If there were a way to “include” my home account’s  
environment.plist in  
/etc/profile . . . yikes.

But this is now way off topic, so I guess I’ll go fiddle with RDoc some  
more. 🙂

---

<div class="post-metadata">

**Author:** ![daveh](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/85e7bf/32.png) [@daveh](https://www.ruby-forum.com/u/daveh)\
**Post date:** [July 22, 2006, 2:21am UTC](https://www.ruby-forum.com/t/re-mac-osx-ruby-configuration-question/99106/8 "2006-07-22T02:21:21Z")

</div>

On Jul 21, 2006, at 14:12, Ryan R. wrote:

> > And look, here’s a more-reliable OSX-specific solution dropped in my  
> > lap.

Too bad it didn’t actually work.

What I want to be able to do is auto-path to ruby, by having shell  
scripts start with

```
#!/usr/bin/env ruby

```

This works beautifully from the command line, but gives me 1.6.8 ruby  
when I call the script from TextWrangler.

I modified my environment.plist to contain the following:

```
     <key>PATH</key>
     <string>/Library/Ruby/Bin:$PATH</string>

```

So what did I get for a path?

```
"/Library/Ruby/Bin:$PATH"

```

No variable expansion. Sigh. I assigned BASH\_ENV the value  
“/etc/profile”, which is good for other things, but doesn’t help this  
case, because unless I specify /bin/bash, it uses an implicit /bin/sh,  
which has no mechanism for specifying profiles when run  
non-interactively.

So I’m back to #!/Library/ruby/bin/ruby for now, and scheming to throw  
old ruby out of /usr/bin so new ruby can sit there instead the next  
time this comes up. Alas.
