"permission deinied" when installing Rails on OS/X

When I do a

  gem install -r rails --include-dependencies

it works fine on Linux, but when I do it from a OS/X bash shell, I get
the error message

  Permission denied - /usr/local/lib/ruby/gems/1.8/cache/
activesupport-1.4.4.gem

The error is reproducible. What could be the problem?

Ronald

dear sir

you have to use sudo when installing gems.

put the word “sudo” before the word “gem” and it will ask for your password and should then work fine.

You probably should use sudo.
sudo gem install rails --include-dependencies

I see!

But there is one strange thing: When I enter the password of my Mac OS
administrator account,
it is rejected by sudo! First I thought I used the wrong password, but
no: I can reproducibly switch
to my Mac Administrator account using this password, but when I supply
it to 'sudo', it is not
accepted.

It looks to me like a "mismatch of account names": When I list /etc/
passwd from my bash shell,
I get (of course) the user "root" as administrator. From the Mac
viewpoint, I have no user named
"root", but I have an user with name "Administrator" having
administrator privileges (and of this,
I know the password of course). However I can not remember having ever
created a separate
password for the root user in the "Unix compatibility box".

Any idea how I could resolve this?

Ronald

I was able to narrow the problem further:

First, I found that I can not do a switch user to root (because of
rejecting the password, as explained in my
previous posting), but I can do, for example, a

  su admin

and this account corresponds to my Mac OS/X administrator account. So
I tried first

  gem install -r rails --include-dependencies

from the admin account - but now I get the error message

  Could not find rails (> 0) in any repository

This puzzles me, because on Linux, the same works fine. Note that I
usually get this error message only
when I forget the '-r' option in the gem install command.

A side remark regarding the suggestion of using "sudo" for the
install: I found that even though I can do
a "su admin", when I do a

  sudo -u admin ....

the same password which was happily accepted by "su", is now rejected.