ruby gems install error

A

Artie Ziff

Hello,

I am hoping to get some ideas here. Being new to ruby, I am not familiar
enough with all the pieces to know how to diagnose my installation
issue. I am attempting to install rubygems 1.1.1 is on a RHEL4 host.

The following line (#51) was deleted:
require 'rdoc/rdoc'

# ruby -v
ruby 1.8.5 (2006-08-25) [x86_64-linux]

# cd rubygems-1.1.1
# ruby setup.rb --no-ri --no-doc

This is final 30 lines of output from setup.rb:

install -c -m 0644 rubygems/commands/query_command.rb
/usr/lib/ruby/site_ruby/1.8/rubygems/commands/query_command.rb
install -c -m 0644 rubygems/commands/dependency_command.rb
/usr/lib/ruby/site_ruby/1.8/rubygems/commands/dependency_command.rb
install -c -m 0644 rubygems/commands/mirror_command.rb
/usr/lib/ruby/site_ruby/1.8/rubygems/commands/mirror_command.rb
install -c -m 0644 rubygems/commands/unpack_command.rb
/usr/lib/ruby/site_ruby/1.8/rubygems/commands/unpack_command.rb
install -c -m 0644 rubygems/commands/sources_command.rb
/usr/lib/ruby/site_ruby/1.8/rubygems/commands/sources_command.rb
install -c -m 0644 rubygems/commands/pristine_command.rb
/usr/lib/ruby/site_ruby/1.8/rubygems/commands/pristine_command.rb
install -c -m 0644 rubygems/commands/install_command.rb
/usr/lib/ruby/site_ruby/1.8/rubygems/commands/install_command.rb
install -c -m 0644 rubygems/commands/check_command.rb
/usr/lib/ruby/site_ruby/1.8/rubygems/commands/check_command.rb
install -c -m 0644 rubygems/commands/help_command.rb
/usr/lib/ruby/site_ruby/1.8/rubygems/commands/help_command.rb
install -c -m 0644 rubygems/commands/search_command.rb
/usr/lib/ruby/site_ruby/1.8/rubygems/commands/search_command.rb
mkdir -p /usr/lib/ruby/site_ruby/1.8/rubygems/package
install -c -m 0644 rubygems/package/tar_input.rb
/usr/lib/ruby/site_ruby/1.8/rubygems/package/tar_input.rb
install -c -m 0644 rubygems/package/tar_reader.rb
/usr/lib/ruby/site_ruby/1.8/rubygems/package/tar_reader.rb
install -c -m 0644 rubygems/package/f_sync_dir.rb
/usr/lib/ruby/site_ruby/1.8/rubygems/package/f_sync_dir.rb
install -c -m 0644 rubygems/package/tar_writer.rb
/usr/lib/ruby/site_ruby/1.8/rubygems/package/tar_writer.rb
install -c -m 0644 rubygems/package/tar_header.rb
/usr/lib/ruby/site_ruby/1.8/rubygems/package/tar_header.rb
install -c -m 0644 rubygems/package/tar_output.rb
/usr/lib/ruby/site_ruby/1.8/rubygems/package/tar_output.rb
mkdir -p /usr/lib/ruby/site_ruby/1.8/rubygems/package/tar_reader
install -c -m 0644 rubygems/package/tar_reader/entry.rb
/usr/lib/ruby/site_ruby/1.8/rubygems/package/tar_reader/entry.rb
cp gem /tmp_dk/rubygems-1.1.1/bin/gem
rm /tmp_dk/rubygems-1.1.1/bin/gem
/usr/lib/ruby/1.8/fileutils.rb:1378:in `fu_each_src_dest': same file:
gem and /tmp_dk/rubygems-1.1.1/bin/gem (ArgumentError)
from /usr/lib/ruby/1.8/fileutils.rb:1395:in `fu_each_src_dest0'
from /usr/lib/ruby/1.8/fileutils.rb:1377:in `fu_each_src_dest'
from /usr/lib/ruby/1.8/fileutils.rb:382:in `cp'
from /usr/lib/ruby/1.8/fileutils.rb:1510:in `cp'
from setup.rb:134
from setup.rb:123:in `each'
from setup.rb:123
from setup.rb:118:in `chdir'
from setup.rb:118


##

Any ideas?

Thx!
az

PS: For reasons out of my control, I cannot simply change change the OS,
so moving to a different OS/release is not an option, unfortunately.
Thank you for your understanding.
 
E

Eric Hodel

cp gem /tmp_dk/rubygems-1.1.1/bin/gem
rm /tmp_dk/rubygems-1.1.1/bin/gem
/usr/lib/ruby/1.8/fileutils.rb:1378:in `fu_each_src_dest': same file:
gem and /tmp_dk/rubygems-1.1.1/bin/gem (ArgumentError)
from /usr/lib/ruby/1.8/fileutils.rb:1395:in `fu_each_src_dest0'
from /usr/lib/ruby/1.8/fileutils.rb:1377:in `fu_each_src_dest'
from /usr/lib/ruby/1.8/fileutils.rb:382:in `cp'
from /usr/lib/ruby/1.8/fileutils.rb:1510:in `cp'
from setup.rb:134
from setup.rb:123:in `each'
from setup.rb:123
from setup.rb:118:in `chdir'
from setup.rb:118

Did you unpack the tarball in /tmp?
 
A

Artie Ziff

Hello,

Thank you for your interest.
Did you unpack the tarball in /tmp?
No. Unpacked in temporary directory that was not "/tmp".
It was very fun to diagnose.
The problem was the following:

The directory "/tmp" was symlink'ed to non-existent directory.

Perhaps the installer should check to see if /tmp actually exists
rather than presuming that it exists, which leads to this failure.

Cheers,
az
 
D

David Masover

Perhaps the installer should check to see if /tmp actually exists
rather than presuming that it exists, which leads to this failure.

That's a reasonable assumption, though. It's kind of like saying "Perhaps the
program should check if the home directory actually exists..."

It might be nice to have a user-friendly option about this, but really, if tmp
doesn't exist, you're going to have a lot more problems than that one
installer.
 
A

Artie Ziff

Hello,
That's a reasonable assumption, though. It's kind of like saying "Perhaps the
program should check if the home directory actually exists..."

Is it not good programming practice to check if resource exists before
using?
It might be nice to have a user-friendly option about this,

IMHO, it would be user-friendly if software emits error when required
resource not available (and make program barf).
but really, if tmp
doesn't exist, you're going to have a lot more problems than that one
installer.
(Score:5, Insightful) :)

And very much my experience.

This is my first week using Ruby, so please tolerate a newbie question:

Is it general convention/assumption by all Ruby programmers: a Ruby
program always has valid writable Dir.tmpdir defined, without verification?

Cheers,
az
 
D

David Masover

Is it not good programming practice to check if resource exists before
using?

Depends. I tend to develop Ruby a bit more optimistically -- I try to use a
resource, assuming that if it doesn't exist, some sort of "NoSuchResource"
exception will be thrown. If it turns out that this is something that will
happen often, and the user might know something about it, I'll catch the
exception and provide a more helpful error message.

I think that's the whole point of exceptions -- most application code should
not be about error handling. We shouldn't have to do this:

if ok_to_do_something?
do_something
return true
else
return nil
end
# Repeat, say, five times in a single function.
# And, of course, in the caller...
if some_function_that_does_something.nil?
error "Can't do something."
exit 1
end
# That's unrealistic. Figure it's more like five levels deep.
IMHO, it would be user-friendly if software emits error when required
resource not available (and make program barf).

Generally, yes, and that's what I meant. It takes a bit more effort to say
something like "Record not found" than to say "You tried to call method :foo
on NilClass", but if it's an error that's likely to happen, it's worth that
effort, and your users will thank you.

But not having a tempdir is just a whole new level of broken-ness. I'm having
trouble coming up with a properly absurd analogy, because of how absurd that
situation is in the first place.
Is it general convention/assumption by all Ruby programmers: a Ruby
program always has valid writable Dir.tmpdir defined, without verification?

I can't speak for others, but I certainly would, mostly because I write Ruby
apps that are meant to run on more or less complete Unices. I know of no
modern Unix that lacks a tempdir. Actually, I know of no modern Unix that
lacks a directory called /tmp, with mode 1777. And I know of no modern Win32
implementation that lacks a tempdir of some kind -- I don't know the details
of where that is (maybe a %TEMP% environment variable?), but that's also
something that should be Ruby's responsibility to work out, not my app's.

My comment about "more problems than that one installer" wasn't about Ruby, it
was about the rest of your Unix (Linux?) system. You probably couldn't even
bring up a GUI without it -- I see a socket called /tmp/.X11-unix/X0, and
while I don't know for certain, I strongly suspect that this is needed to
communicate with my X server (as TCP is disabled).

If you're moving beyond Unices (and Windows), you're probably going to have to
make more extensive changes than tempdirs -- and you might not end up using
Ruby at all (though not, I hope, because of a lack of tempdirs).
 
E

Eric Hodel

Is it not good programming practice to check if resource exists before
using?

It is a good practice.
IMHO, it would be user-friendly if software emits error when required
resource not available (and make program barf).
Yes.

(Score:5, Insightful) :)

And very much my experience.

This is my first week using Ruby, so please tolerate a newbie
question:

Is it general convention/assumption by all Ruby programmers: a Ruby
program always has valid writable Dir.tmpdir defined, without
verification?

RubyGems is using Dir.tmpdir because it is supposed to do the
verification, it checks:

if dir and File.directory?(dir) and File.writable?(dir)

Maybe there is a bug.

I have a symlinked /tmp (OS X), but it goes to a valid place:

$ ruby -v
ruby 1.8.6 (2007-09-24 patchlevel 111) [universal-darwin9.0]
$ ls -al /tmp
lrwxr-xr-x@ 1 root admin 11 Nov 15 2007 /tmp@ -> private/tmp
$ ruby -e 'p File.directory?("/tmp")'
true
$ ruby -e 'p File.symlink?("/tmp")'
true

But if I create a symlink pointing to a nonexistent place:

$ ln -s /foo baz
$ ls -al baz
lrwxr-xr-x 1 drbrain staff 4 Jun 8 01:08 baz@ -> /foo
$ ls -al /foo
ls: /foo: No such file or directory
$ ruby -e 'p File.directory?("baz")'
false
$ ruby -e 'p File.symlink?("baz")'
true

So maybe some other bug exists?

If you find the bug, can you inform ruby-core?
 

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

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,065
Latest member
OrderGreenAcreCBD

Latest Threads

Top