uninstalling the mac tiger version of ruby

L

libsfan01

My reason for wanting to uninstall is that ive tried to install the
latest version but terminal is still telling me that the version is
1.8.2 not 1.8.5 that i downloaded, so it must have gotten messed up
somewhere right?
 
G

Gene Tani

libsfan01 said:
My reason for wanting to uninstall is that ive tried to install the
latest version but terminal is still telling me that the version is
1.8.2 not 1.8.5 that i downloaded, so it must have gotten messed up
somewhere right?

There's been numbers of posts on installing Rails from Locomotive,
darwinport/Macports or source recently:

http://blog.nanorails.com/articles/2006/07/11/installing-rails-on-mac-os-x-tiger
http://blog.nanorails.com/articles/2006/10/17/installing-rails-on-mac-os-x-tiger-10-4-8
http://www.sitening.com/blog/2006/05/21/ruby-on-rails-with-os-x-tiger/

http://www.slashdotdash.net/articles/2006/11/10/apple-macbook-pro-setup-for-a-rails-coder
http://blog.pjkh.com/2007/1/15/building-rails-and-all-its-friends-on-osx
http://mandhro.com/2006/06/16/setting-up-intel-mac-for-rails-development/

http://blog.labratz.net/articles/20...he-whole-rails-stack-rmagick-libraries-on-osx

I forget which one i followed. You don't hear too much about fink
these days. And i don't know about the factory-installed ruby, but
there's stern warnings in my OS X books abotu not uninstalling the
factory-installed perl and python.
 
P

Phrogz

libsfan01 said:
My reason for wanting to uninstall is that ive tried to install the
latest version but terminal is still telling me that the version is
1.8.2 not 1.8.5 that i downloaded, so it must have gotten messed up
somewhere right?

Probably your PATH environment variable is set to use the
tiger-installed version, instead of your new version. Observe:

slim:~ gavinkistner$ /usr/bin/ruby -v
ruby 1.8.2 (2004-12-25) [powerpc-darwin8.0]

slim:~ gavinkistner$ /usr/local/bin/ruby -v
ruby 1.8.5 (2006-08-25) [powerpc-darwin8.7.0]

slim:~ gavinkistner$ env
[...snip...]
PATH=.:/usr/local/bin:/bin:/sbin:/usr/bin:/usr/sbin
[...snip...]

slim:~ gavinkistner$ which ruby
/usr/local/bin/ruby

In other words, Apple's build lives in /usr/bin, my latest stable build
lives in /usr/local/bin. If I just type "ruby", the PATH environment
variable chooses which directories to look in, and the order to look.
IIRC had to change my PATH to put my local bin directory before
/usr/bin, because I always wanted programs that I had built and
installed to supercede existing installs.

If you really want, you can go in as root and rename /usr/bin/ruby (and
irb and rdoc and others) to have a different name, like ruby182. Or you
could delete them, and hope that nothing relied on them. But I'd just
go with the PATH solution.
 
T

Timothy Hunter

libsfan01 said:
My reason for wanting to uninstall is that ive tried to install the
latest version but terminal is still telling me that the version is
1.8.2 not 1.8.5 that i downloaded, so it must have gotten messed up
somewhere right?
No, don't uninstall the version of Ruby that comes with OS X. That
version is installed in the /usr/bin directory. When you installed Ruby
yourself, you probably installed it (assuming you built it from source
and took the defaults) in /usr/local/bin. All you have to do is make
sure your $PATH variable has /usr/local/bin preceding /usr/bin. When you
execute the "ruby" command OS X will search the directories in the order
listed by $PATH and will find your ruby in /usr/local/bin.

Check it out like this. Enter this command:

/usr/bin/ruby -v

You'll probably get "ruby 1.8.2". Then enter:

/usr/local/bin/ruby -v

You'll probably get "ruby 1.8.5"

Of course, if you specified another prefix when you ran the configure
script, or if you installed Ruby from MacPorts or fink, then Ruby is
installed in a different directory.

For more information about PATH, do a "man bash" in an OS X terminal window.
 
L

libsfan01

You'll probably get "ruby 1.8.5"

Yes it seems to be the case that its looking for the wrong version.
timothy how can i change the setting of the path variable so that the
latest version is accessed? (from "usr/bin/ruby" to
"usr/local/bin/ruby")?

thanks

marc
 
L

libsfan01

You'll probably get "ruby 1.8.5"

Yes it seems to be the case that its looking for the wrong version.
timothy how can i change the setting of the path variable so that the
latest version is accessed? (from "usr/bin/ruby" to
"usr/local/bin/ruby")?

thanks

marc
 
T

Timothy Hunter

libsfan01 said:
Yes it seems to be the case that its looking for the wrong version.
timothy how can i change the setting of the path variable so that the
latest version is accessed? (from "usr/bin/ruby" to
"usr/local/bin/ruby")?

thanks

marc

PATH is an environment variable that the bash shell uses when it
searches for a command. In bash you set environment variables like this:

export VAR=value

Notice there's no leading $ in the name when it's on the left-hand side
of the assignment. When you want to get the value of an environment
variable you precede its name with a $. Now, you want to prepend
/usr/local/bin to the current value of PATH. Enter this command:

echo $PATH

This will show you the current value of PATH. Then enter:

export PATH=/usr/local/bin:$PATH

(Directories in the PATH are separated by colons.) issue "echo $PATH"
again to ensure that the change worked.

Now enter "ruby -v". You should see "ruby 1.8.5" because OS X found ruby
in /usr/local/bin.

Of course you don't want to have to redefine your PATH variable every
time you open a terminal. To get your PATH set the way you want it every
time you can add this command to a bash configuration script. The bash
shell gets its configuration from a number of scripts. I believe the
preferred one for this sort of thing is .bash_profile. The bash shell
looks for this file in your home directory. You may already have such a
file. If so, save a backup copy, open it in a text editor and add the
command on a separate line. If the file doesn't already exist, create it
and add these two lines:

#! /bin/bash
export PATH=/usr/local/bin:$PATH

Save the file, close the terminal window and open a new one. Issue "echo
$PATH" again to see your changed PATH. Issue "ruby -v" and ensure that
you're getting "ruby 1.8.5".

Warning: be careful. If you screw up your path many things in OS X will
stop working. If you encounter problems (like commands not working) just
delete your .bash_profile (or restore it to its previous state) and try
again. Always close the terminal window and open a new window after
making a change.

For more info search for bash on the web or issue the "man bash" command
in a terminal window.
 
A

Aaron Massey

I have a similar problem. I installed a manually compiled version of
ruby, rails and gem at /usr/local/bin. They all work fine and I have my
environment variables setup so that I can use them in a Terminal without
problems. However, when I start WEBrick, it is defaulting to the Mac OS
X version of rails. Where can I set the version of ruby that WEBrick
should be using?

Thanks in advance!
 
J

John Joyce

I posted something about it on my blog recently, after a recent OS X
update screwed up my $PATH
That's something you need to spend the time looking into.
The one-click installer may or may not replace the old Ruby, but the
Hivelogic install directions will get you what you want.
Don't worry though, only 1 more likely update to OS X 10.4 (10.4.11)
and 10.5 will be out with a working Ruby.
You should install the mongrel gem though. It makes a much more
responsive test server with the built in apache. (and you don't have
to turn apache off to use it, and most hosts providing shell access
and ruby/rails will be on apache anyway.
The book Rails Solutions, from Friends of ED, has an excellent
install/setup for Ruby and Rails in it.
 
A

Aaron Massey

Thanks for the responses! Obviously, removing the Apple installation of
ruby and replacing it with simlinks works.

I ended up installing mongrel and using that to solve the problem though
if only because I don't like blowing away files that Apple might simply
replace in future updates.

I did want to point out that the other recommendation I received does
not work. It was actually what I did when I originally installed ruby
manually, so perhaps it is useful to post a sample session that shows
the problem more clearly:

/* my local install ruby is first in my path */
bash $ which ruby
/usr/local/bin/ruby

/* note the versions of my manual install and of the default */
bash $ /usr/local/bin/ruby -v
ruby 1.8.6 (2007-03-13 patchlevel 0) [powerpc-darwin8.10.0]
bash $ /usr/bin/ruby -v
ruby 1.8.2 (2004-12-25) [powerpc-darwin8.0]

/* see which one WEBrick is picking? */
bash $ ./script/server
=> Booting WEBrick...
=> Rails application started on http://0.0.0.0:3000
=> Ctrl-C to shutdown server; call with --help for options
[2007-09-20 19:37:03] INFO WEBrick 1.3.1
[2007-09-20 19:37:03] INFO ruby 1.8.2 (2004-12-25) [powerpc-darwin8.0]
[2007-09-20 19:37:03] INFO WEBrick::HTTPServer#start: pid=795 port=3000


For some reason, even though I have /usr/local/bin listed first in my
path (as Hivelogic suggests in their manual install instructions) the
WEBrick server still uses the Apple default ruby installation. It could
be a weirdness with the way Apple sets up their default $PATH variable
or it could be that WEBrick simply ignores local environment variables.

I can't determine which is the case because I really don't know much
about WEBrick and I can't find where OS X sets up its default
environment variables. (Though, I would like to know if anyone knows
off the top of their head...)

If it is a problem with WEBrick, I would be willing to file a bug or
whatever to help the developers. Obviously, I would like to confirm it
before wasting their time. I guess it's kind of a simple bug, but this
is the sort of thing that looks like it would have high visibility with
new rails developers on Mac OS X. Maybe it only shows up as a problem
until Apple releases their next OS, but there could be folks stuck on OS
X 10.4.x for a while afterwards that might run into this. It could also
manifest later in some form.

It is perhaps useful to point out that because I've also installed gem
in the following location:


bash $ which gem
/usr/local/bin/gem


As a result, anything I install via gem is ignored by WEBrick. For
example, trying to start up a rails app with an sqlite3 database (which
uses the sqlite3 plugin I've installed via gem) provides an error
message:


bash $ gem list --local sqlite3

*** LOCAL GEMS ***

sqlite3-ruby (1.2.1)
SQLite3/Ruby is a module to allow Ruby scripts to interface with a
SQLite3 database.
bash $ ./script/server
=> Booting WEBrick...
=> Rails application started on http://0.0.0.0:3000
=> Ctrl-C to shutdown server; call with --help for options
[2007-09-20 19:44:13] INFO WEBrick 1.3.1
[2007-09-20 19:44:13] INFO ruby 1.8.2 (2004-12-25) [powerpc-darwin8.0]
[2007-09-20 19:44:13] INFO WEBrick::HTTPServer#start: pid=799 port=3000

===+ WEB BROWSER ERROR MESSAGE +===
No such file to load -- sqlite3
/usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in
`gem_original_require'
/usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `require'
===+ TRUNCATED FOR CLARITY +===


Anyhow, because mongrel is installed via a gem, it seems to recognize
the other gems installed on the system, so I'm going to use that for
now. However, it does seem that the only fully functional recourse in
some cases appears to be actually blowing away the Apple install of
ruby.

Thanks again for the help!
 
M

Marc Heiler

However, it does seem that the only fully functional recourse in
some cases appears to be actually blowing away the Apple install of
ruby.

Free yourself from the slowness of Apple! :D

PS: Compiling ruby from source is very easy too. Perl is a little bit
more annoying. (Python compiled fine too, maybe its a paradigma thing
that perl has a slightly weird build-system from source compared to
ruby/python)
 
J

John Joyce

well, what you missed at Hivelogic is this: the $PATH variable can be
and is set in more than one dot file.
bash_login
bash_rc
profile

etc...

There can be a precedence for these, based on which one gets loaded
first or last.
What you need to do is investigate what all you have on your machine.
You need to check more than just your home directory too. You should
check some things higher up.
this is all shell stuff, it could be true in any shell, but the most
common used on OS X is Bash.
I recommend picking up a copy of Unix in a Nutshell. ( you need to
have a reference like this around anyway and this one is good for
multiple *nixes )
It has a nice section on Bash configuration, so you'll always have a
reference of where to look for these things.
sometimes when you install software or run updates, this stuff gets
changed.
Usually what happens is another bit of software prefers to use
something for all *nix systems rather than using what is commonly
used on a particular system. For example, I installed a newer Python
recently, and it gummed things up because it created a dot file that
wasn't there before. This is really a problem with Bash. It allows
multiple files in multiple places to determine your $PATH all
together, so it can take a little work to track it all down. The key
is to get it how you want it/need it all in one file and then comment
out the stuff in the other dot files and leave a comment of why and
what it was for, including the date. This will give you reference in
the future.
Don't be afraid to comment the hell out of those dot files that store
PATH information. You need it for when (not if) your PATH gets
screwed up.
 
A

Aaron Massey

Felix said:
If you do a "cat script/server" from the base directory of your rails
application, what Ruby path does the shebang line point to?

Felix


#!/usr/bin/ruby

This was the problem. Normally it is "#!/usr/bin/env ruby" but I had
pulled a rails project from a friend's svn server and apparently it was
setup differently on his system. I simply never thought to look there.

At least it wasn't forgetting to set my environment variable in bash.
I've been using bash for around 12 years now and I'm familiar with the
various ways of setting environment variables on *nix systems. ;-)

Thanks for all the help folks!

Actually, now that I think about it. Is there a way to reset the
shebangs on all the rails scripts without inadvertently pushing them
back to svn? That's going to be a bit of a pain if we're fighting over
the shebangs with every commit.
 
U

Une Bévue

Aaron Massey said:
I have a similar problem. I installed a manually compiled version of
ruby, rails and gem at /usr/local/bin. They all work fine and I have my
environment variables setup so that I can use them in a Terminal without
problems. However, when I start WEBrick, it is defaulting to the Mac OS
X version of rails. Where can I set the version of ruby that WEBrick
should be using?

may be u've to setup yours :

~/.MacOSX/environment.plist

here is mine :

~%> cat ~/.MacOSX/environment.plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN"
"http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>ANT_HOME</key>
<string>/Users/yt/bin/ant</string>
<key>BATIK_HOME</key>
<string>/Users/yt/bin/batik-1.7</string>
<key>CLASSPATH</key>
<string>.</string>
<key>DIRSTACKSIZE</key>
<string>10</string>
<key>DISPLAY</key>
<string>:0.0</string>
<key>DYLD_FALLBACK_LIBRARY_PATH</key>
<string>/usr/local/lib:/opt/local/lib:/usr/lib</string>
<key>FPATH</key>
<string>/Users/yt/Library/init/zsh/func_dir</string>
<key>GEM_HOME</key>
<string>/opt/local/lib/ruby/gems/1.8</string>
<key>JAVA_HOME</key>

<string>/System/Library/Frameworks/JavaVM.framework/Versions/1.6.0/Home<
/string>
<key>JGEM_HOME</key>
<string>/Users/yt/bin/jruby/lib/ruby/gems/1.8</string>
<key>JRUBYGEMS</key>
<string>/Users/yt/bin/jruby/lib/ruby/site_ruby/1.8</string>
<key>JRUBY_BIN</key>
<string>/Users/yt/bin/jruby/bin</string>
<key>JRUBY_HOME</key>
<string>/Users/yt/bin/jruby</string>
<key>LC_CTYPE</key>
<string>fr_FR.UTF-8</string>
<key>LD_LIBRARY_PATH</key>

<string>/System/Library/Frameworks/JavaVM.framework/Versions/1.6.0/Libra
iries</string>
<key>MACOSX_DEPLOYMENT_TARGET</key>
<string>10.4</string>
<key>PATH</key>

<string>/opt/local/lib/mysql5/bin:/Users/yt/SVN/WebKit/WebKitTools/Scrip
ts:/Users/yt/bin/ant/bin:/opt/local/bin:/opt/local/sbin:/bin:/usr/bin:/s
bin:/usr/sbin:/usr/X11R6/bin:/usr/local/bin:/usr/local/sbin:/Users/yt/bi
n:/Developer/Tools:/System/Library/Frameworks/Python.framework/Versions/
2.3/bin</string>
<key>PS1</key>
<string>%{%}%~%#%{%}&gt; </string>
<key>RUBYGEMS</key>
<string>/opt/local/lib/ruby/site_ruby/1.8</string>
<key>RUBYLIB</key>

<string>/opt/local/lib/ruby/:/opt/local/lib/ruby/site_ruby/1.8</string>
<key>RUBYOPT</key>
<string>rubygems</string>
<key>TERM</key>
<string>xterm-color</string>
<key>TERM_PROGRAM</key>
<string>iTerm.app</string>
<key>ZDOTDIR</key>
<string>/Users/yt/Library/init/zsh</string>
<key>__CF_USER_TEXT_ENCODING</key>
<string>0x1F9:0:0</string>
</dict>
</plist>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,820
Latest member
GilbertoA5

Latest Threads

Top