# Ruby gems install error

**URL:** <https://www.ruby-forum.com/t/ruby-gems-install-error/139714>\
**Category:** Ruby\
**Created:** [June 6, 2008, 8:57am UTC](https://www.ruby-forum.com/t/ruby-gems-install-error/139714 "2008-06-06T08:57:55Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Artie\_Ziff](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/41988e/32.png) [@Artie\_Ziff](https://www.ruby-forum.com/u/Artie_Ziff)\
**Post date:** [June 6, 2008, 8:57am UTC](https://www.ruby-forum.com/t/ruby-gems-install-error/139714/1 "2008-06-06T08:57:55Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Artie\_Ziff](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/41988e/32.png) [@Artie\_Ziff](https://www.ruby-forum.com/u/Artie_Ziff)\
**Post date:** [June 8, 2008, 3:51am UTC](https://www.ruby-forum.com/t/ruby-gems-install-error/139714/2 "2008-06-08T03:51:21Z")

</div>

On Jun 5, 2008, at 23:54 PM, Artie Ziff wrote:

> from setup.rb:123  
> from setup.rb:118:in `chdir’  
> from setup.rb:118

Did you unpack the tarball in /tmp?

---

<div class="post-metadata">

**Author:** ![Artie\_Ziff](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/41988e/32.png) [@Artie\_Ziff](https://www.ruby-forum.com/u/Artie_Ziff)\
**Post date:** [June 8, 2008, 5:32am UTC](https://www.ruby-forum.com/t/ruby-gems-install-error/139714/3 "2008-06-08T05:32:33Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Artie\_Ziff](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/41988e/32.png) [@Artie\_Ziff](https://www.ruby-forum.com/u/Artie_Ziff)\
**Post date:** [June 8, 2008, 7:17am UTC](https://www.ruby-forum.com/t/ruby-gems-install-error/139714/4 "2008-06-08T07:17:17Z")

</div>

On Saturday 07 June 2008 22:30:53 Artie Ziff wrote:

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

---

<div class="post-metadata">

**Author:** ![Artie\_Ziff](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/41988e/32.png) [@Artie\_Ziff](https://www.ruby-forum.com/u/Artie_Ziff)\
**Post date:** [June 8, 2008, 8:45am UTC](https://www.ruby-forum.com/t/ruby-gems-install-error/139714/5 "2008-06-08T08:45:06Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Artie\_Ziff](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/41988e/32.png) [@Artie\_Ziff](https://www.ruby-forum.com/u/Artie_Ziff)\
**Post date:** [June 8, 2008, 10:34am UTC](https://www.ruby-forum.com/t/ruby-gems-install-error/139714/6 "2008-06-08T10:34:58Z")

</div>

On Jun 7, 2008, at 23:41 PM, Artie Ziff wrote:

> > 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 is a good practice.

> > 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).

Yes.

> 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?

---

<div class="post-metadata">

**Author:** ![Artie\_Ziff](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/41988e/32.png) [@Artie\_Ziff](https://www.ruby-forum.com/u/Artie_Ziff)\
**Post date:** [June 8, 2008, 9:15am UTC](https://www.ruby-forum.com/t/ruby-gems-install-error/139714/7 "2008-06-08T09:15:01Z")

</div>

On Sunday 08 June 2008 01:41:31 Artie Ziff wrote:

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

> > 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).

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).
