Getting Started w Ruby on MacOSX -- ri/RDoc error

Hello,

I’ve done some poking around and haven’t yet found a satisfactory
answer to this problem and it’s starting to be troublesome.

My development machine run MacOSX and I’ve installed Ruby 1.9.1 via
the MacPorts options. This puts everything into /opt/local and tags
executables with the version number (e.g. ruby becomes ruby1.9, ri
becomes ri1.9, etc.)

When I run ri to browse a class documentation, I get the following
error:

galactica:~ remillard$ ri GC
/opt/local/lib/ruby1.9/1.9.1/rdoc/ri/driver.rb:384:in initialize': Permission denied - /Users/remillard/.ri1.9/cache/.doc_dirs (Errno::EACCES) from /opt/local/lib/ruby1.9/1.9.1/rdoc/ri/driver.rb:384:inopen’
from /opt/local/lib/ruby1.9/1.9.1/rdoc/ri/driver.rb:384:in
create_class_cache' from /opt/local/lib/ruby1.9/1.9.1/rdoc/ri/driver.rb:371:inclass_cache’
from /opt/local/lib/ruby1.9/1.9.1/rdoc/ri/driver.rb:591:in block in run' from /opt/local/lib/ruby1.9/1.9.1/rdoc/ri/driver.rb:590:ineach’
from /opt/local/lib/ruby1.9/1.9.1/rdoc/ri/driver.rb:590:in run' from /opt/local/lib/ruby1.9/1.9.1/rdoc/ri/driver.rb:300:inrun’
from /opt/local/bin/ri:5:in `’

Now, my best guess is that there’s something funny about the paths
where MacPorts installed things, but I’ll be damned if I can figure
out what’s going on. When looking at my path I see:

galactica:~ remillard$ echo $PATH
/opt/local/bin:/opt/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/
local/bin:/usr/X11/bin:/Users/remillard/bin

And it looks to me like the MacPorts path should be searched first.
The only thing I did was to go into /opt/local/bin and symlink the
simple names to the versioned names for convenience. However I still
get the same error if I run “ri1.9 GC” so I don’t think the symlinks
are causing any trouble.

Has anyone run into this with MacPorts, Ruby 1.9 and MacOSX?

Thanks for any information and help the community can suggest.

Best regards,
Mark Norton

I did finally figure it out so I will document the answer here in case
it helps someone else.

Somewhere along the line with installing ruby, rails, and other gems,
the local ri cache was created and owned by root. I’m not entirely
sure why, but that explained the lack of permissions. If you get
errors similar to what I described above, check your local directory
“ls -al” and look to see if root owns .ri1.9/. Blow that away and
then rerun ri. It’ll rebuild the cache and hopefully be owned by your
own self.

Hope this helps.

All the best,
Mark Norton

On Dec 31, 2009, at 16:05 , M. Norton wrote:

When I run ri to browse a class documentation, I get the following
error:

galactica:~ remillard$ ri GC
/opt/local/lib/ruby1.9/1.9.1/rdoc/ri/driver.rb:384:in `initialize’:
Permission denied - /Users/remillard/.ri1.9/cache/.doc_dirs
(Errno::EACCES)

Did you install the docs?

M. Norton wrote:

I did finally figure it out so I will document the answer here in case
it helps someone else.

Somewhere along the line with installing ruby, rails, and other gems,
the local ri cache was created and owned by root. I’m not entirely
sure why, but that explained the lack of permissions. If you get
errors similar to what I described above, check your local directory
“ls -al” and look to see if root owns .ri1.9/. Blow that away and
then rerun ri. It’ll rebuild the cache and hopefully be owned by your
own self.

Hope this helps.

All the best,
Mark Norton

Hi,

Just wanted to let you know you helped someone. Ran into the exact same
problem on Mint linux today, and your post came up with a little
googling.

A simple “sudo chown -R aaron:aaron /home/aaron/.ri1.9.1/” saved the
day!

Aaron