Uninstalling the mac tiger version of ruby


#1

hi all

in trying to uninstall the mac version of ruby how can i do this?


#2

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?


#3

libsfan01 wrote:

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/2006/10/14/a-shell-script-to-install-the-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.


#4

libsfan01 wrote:

in trying to uninstall the mac version of ruby how can i do this?

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.


#5

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


#6

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


#7

libsfan01 wrote:

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.


#8

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!


#9

libsfan01 wrote:

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.


#10

On 9/20/07, Aaron M. removed_email_address@domain.invalid wrote:

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?

Not a direct answer, but this is my usual “solution” whenever installing
Ruby on OS X:

sudo rm /usr/bin/irb /usr/bin/rdoc /usr/bin/ri /usr/bin/ruby
sudo ln -s /usr/local/bin/irb /usr/bin/irb
sudo ln -s /usr/local/bin/rdoc /usr/bin/rdoc
sudo ln -s /usr/local/bin/ri /usr/bin/ri
sudo ln -s /usr/local/bin/ruby /usr/bin/ruby

Well… it works :slight_smile: (although you have to remember to do it again if OS X
updates Ruby!)

Regards,
Peter C.
http://www.rubyinside.com/


#11

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.


#12

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! :smiley:

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)


#13

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:inrequire’
===+ 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!


#14

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.


#15

the problem more clearly:

I can’t determine which is the case because I really don’t know much
visibility with
in the following location:
message:
=> Booting WEBrick…
/usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in
ruby.

Thanks again for the help!

Posted via http://www.ruby-forum.com/.

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


#16

Felix W. wrote:

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. :wink:

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.


#17

.bash_rc
this is all shell stuff, it could be true in any shell, but the most
used on a particular system. For example, I installed a newer Python
that store
PATH information. You need it for when (not if) your PATH gets
screwed up.

One approach could be a simple “grep -i path ~/.*” and then setting the
same
environment variable in each file to the files name. Then start a new
shell
session and check the value of the environment variable - that file got
processed last. Make any changes to the path in that file. On most
systems,
user files should override system wide files by design.

Felix


#18

application, what Ruby path does the shebang line point to?
look there.
back to svn? That’s going to be a bit of a pain if we’re
fighting over
the shebangs with every commit.


Posted via http://www.ruby-forum.com/.

I wish I was more proficient in svn, so I’m not sure there isn’t a much
more
efficient way of doing this - but maybe write a short shell script to
commit
that first checks out the script directory (thus resetting the scripts,
which should be fairly static apart from your shebangs) and then commits
back to the repository?

HTH,

Felix


#19

Luckily you don’t have many places to alter the shebangs.
2 or 3 as I recall, in a normal Rails app.
I know I always have to change them for DreamHost servers.
It’s not much to do unless you’re building something to be re-used in
more than one deployment.
Even then, just put a not the the app docs. It’s one of those things
that is probably best manually checked.
You could write a Rake task though, to switch them to whatever
shebangs you want.
Rake is ideally suited for this since it is well integrated to the
Rails development process.


#20

Aaron M. removed_email_address@domain.invalid wrote:

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"?> ANT_HOME /Users/yt/bin/ant BATIK_HOME /Users/yt/bin/batik-1.7 CLASSPATH . DIRSTACKSIZE 10 DISPLAY :0.0 DYLD_FALLBACK_LIBRARY_PATH /usr/local/lib:/opt/local/lib:/usr/lib FPATH /Users/yt/Library/init/zsh/func_dir GEM_HOME /opt/local/lib/ruby/gems/1.8 JAVA_HOME

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

/System/Library/Frameworks/JavaVM.framework/Versions/1.6.0/Libra
iries
MACOSX_DEPLOYMENT_TARGET
10.4
PATH

/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
PS1
%{%}%~%#%{%}>
RUBYGEMS
/opt/local/lib/ruby/site_ruby/1.8
RUBYLIB

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