[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Re: Mac OSX Ruby Configuration Question

Dave Howell

7/17/2006 11:42:00 PM


On Jul 14, 2006, at 20:37, Mat Schaffer wrote:

On Jul 14, 2006, at 8:31 PM, Ryan Raaum wrote:
I would not modify anything in /usr/bin directly. Apple assumes that
the system /usr/bin is theirs and unmodified and will (and have!) change
things there in updates without warning - possibly breaking your
modifications and potentially causing serious system problems.
Installing in /usr/local and prepending it to your path is the usual
unix way of doing things.

Just to speak on this point, I've been safely using the replacement
solution for about 6 months now with no trouble at all. But the one
thing I did after I moved /usr/bin/ruby is to make a link from
/opt/local/bin/ruby (my darwinports installation) to /usr/bin/ruby.

Pathing works most of the time, but I had some problems with
RadRails/Eclipse because it doesn't appear to honor pathing provided in
profile or .login.

I have become convinced that not completely obliterating the
Apple-default Ruby is a mistake. The fact that my 1.8.4 politely put
itself next to, instead of on top of, the 1.6.8 Jaguar Ruby has
repeatedly caused malfunctions and path errors.

1) First there was the whole "hey, I installed it but it doesn't work"
thing that requires learning the voodoo of .bash_profile (yea, yea,
many of you can't even remember when you didn't know about it, but
finding the documentation that answered the question "why do I get the
wrong Ruby?" is a bitch, since it requires learning quite a bit of new
vocabulary before you can even search for the answer.)

2) I got to do it all over again when I installed RubyCocoa, since
frameworks don't give a diddly-dang what's in your .bash-profile, and
the 1.8.4 Ruby compile/install hadn't hunted down an earlier
Ruby.framework. Debugging THAT one was extremely difficult, involving
running "lsof" on my compiled program, discovering that XCode had
found, and was using, a different Ruby.framework than the one I knew
about, and trashing it.

3) 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"]

This time, I just gave up and hard-coded #!/usr/local/bin/ruby

Next time, I'll probably erase the entire 1.6.8 code base from my
system, and replace it with links to my 1.8.4.



[OK, so this time, I hard-coded
#!/Library/Ruby/bin/ruby
but that's a different kettle of fish. There's a hard link in
/usr/local/bin for the non-zero number of Ruby-related programs that
think paths are legally regulated or something. Not many people appear
to have noticed that Apple installs scripting languages in /Library or
/System/Library, not in invisible folders, except for the command-line
binaries for the languages, which are in /usr/bin. ]


2 Answers

Stefan Lang

7/18/2006 3:34:00 PM

0


On Tuesday, July 18, 2006, at 8:42 AM, Dave Howell wrote:
>
>On Jul 14, 2006, at 20:37, Mat Schaffer wrote:
>
>On Jul 14, 2006, at 8:31 PM, Ryan Raaum wrote:
>I would not modify anything in /usr/bin directly. Apple assumes that
>the system /usr/bin is theirs and unmodified and will (and have!) change
>things there in updates without warning - possibly breaking your
>modifications and potentially causing serious system problems.
>Installing in /usr/local and prepending it to your path is the usual
>unix way of doing things.
>
>Just to speak on this point, I've been safely using the replacement
>solution for about 6 months now with no trouble at all.

6 months isn't all that long :)

>But the one
>thing I did after I moved /usr/bin/ruby is to make a link from
>/opt/local/bin/ruby (my darwinports installation) to /usr/bin/ruby.
>
>Pathing works most of the time, but I had some problems with
>RadRails/Eclipse because it doesn't appear to honor pathing provided in
>.profile or .login.

You probably want ~/.MacOSX/environment.plist
(http://developer.apple.com/qa/qa2001/q...)

(This configuration file is very, very poorly advertised/documented.)

>
>I have become convinced that not completely obliterating the
>Apple-default Ruby is a mistake. The fact that my 1.8.4 politely put
>itself next to, instead of on top of, the 1.6.8 Jaguar Ruby has
>repeatedly caused malfunctions and path errors.
>
>1) First there was the whole "hey, I installed it but it doesn't work"
>thing that requires learning the voodoo of .bash_profile (yea, yea,
>many of you can't even remember when you didn't know about it, but
>finding the documentation that answered the question "why do I get the
>wrong Ruby?" is a bitch, since it requires learning quite a bit of new
>vocabulary before you can even search for the answer.)

Definitely a failure of documentation, but at least your knowledge is
now good forever on any unix system.

>2) I got to do it all over again when I installed RubyCocoa, since
>.frameworks don't give a diddly-dang what's in your .bash-profile, and
>the 1.8.4 Ruby compile/install hadn't hunted down an earlier
>Ruby.framework. Debugging THAT one was extremely difficult, involving
>running "lsof" on my compiled program, discovering that XCode had
>found, and was using, a different Ruby.framework than the one I knew
>about, and trashing it.

This is a failure of RubyCocoa documentation.

>
>3) 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.

>
>This time, I just gave up and hard-coded #!/usr/local/bin/ruby
>
>Next time, I'll probably erase the entire 1.6.8 code base from my
>system, and replace it with links to my 1.8.4.
>

In Mac OS X 10.0, the unix way didn't work all that well, and one had to
do the expedient thing much of the time. And the fink project was born
mostly because the unix guts of early OS X weren't all that great.
Today, in 10.4, the unix way works most of the time and only
occasionally does one need to go the expedient route. And today the
fink/darwinports projects are more useful as package managers rather
than required-to-make-unix-stuff-work-properly.

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. Expedient solutions may not be the
best choice going forward on OS X and are not transferable to other
unices, BUT nonetheless may be required for a power user from time to time.

>
>
>[OK, so this time, I hard-coded
> #!/Library/Ruby/bin/ruby
>but that's a different kettle of fish. There's a hard link in
>/usr/local/bin for the non-zero number of Ruby-related programs that
>think paths are legally regulated or something. Not many people appear
>to have noticed that Apple installs scripting languages in /Library or
>/System/Library, not in invisible folders, except for the command-line
>binaries for the languages, which are in /usr/bin. ]
>
>




--
Posted with http://De.... Sign up and save your mailbox.

John Johnson

7/19/2006 7:27:00 PM

0

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Ryan Raaum wrote:
> On Tuesday, July 18, 2006, at 8:42 AM, Dave Howell wrote:
>> On Jul 14, 2006, at 20:37, Mat Schaffer wrote:
>>
>> On Jul 14, 2006, at 8:31 PM, Ryan Raaum wrote:

>> Pathing works most of the time, but I had some problems with
>> RadRails/Eclipse because it doesn't appear to honor pathing provided in
>> .profile or .login.
>
> You probably want ~/.MacOSX/environment.plist
> (http://developer.apple.com/qa/qa2001/q...)
>
> (This configuration file is very, very poorly advertised/documented.)
>

That's an understatement!

Thanks for posting this. I'm sure this bookmark will be handy in the future.

Regards,
JJ

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.3 (Darwin)
Comment: My GPG/PGP Key A43E775C Fingerprint is 8946 0532 9363 BA7D DDEC
FA1B E7A4 360A A43E 775C
Comment: Using GnuPG with Mozilla - http://enigmail....

iD8DBQFEvodt56Q2CqQ+d1wRAtpnAKCbRxKKs4+r77Cv12vz5dME9/m6jgCgqoD2
Xcedm8qOUibz2hot3Q7Ue6w=
=/blM
-----END PGP SIGNATURE-----