研究室のgentooにrubygemに入れるのに、はまったのでメモ。*1
rubygemsは0.9.2。rubyは1.8.6。

emerge でも 自分で tar をおとしてきても、途中でとまる。
具体的に言うとインストール中にCPU使用率が100%になって、進まない。

ということで、ググると、Ruby hangs when trying to install RubyGems - Ruby on Rails - Ruby-Forumに似たような現象のひとが。

I had the same problem both with emerging rubygems or directly running
setup.rb from rubygems-0.9.2.tgz
I fixed it by patching rubygems-0.9.2/lib/rubygems/packages.rb:

450,453c450,453< if @io.respond_to? :seek< # avoid reading...< @io.seek(size - entry.bytes_read, IO::SEEK_CUR) < else

    • -

> #if @io.respond_to? :seek
> # # avoid reading...
> # @io.seek(size - entry.bytes_read, IO::SEEK_CUR)
> #else
460c460< end

    • -

> #end

With that patch you force the TarReader to actually read the file
rather than just seeking into it.
The bug was that by seeking, the bytes_read attribute of entry was
never updated.


ということらしく、そうすると、インストールできた。

で、ためしに

# gem install mechanize


とかやると、

/usr/install がない、とかっておこられるので、

suになって

# ln -s /usr/bin/install /bin/install

をやってあげて、無事に動くように。

*1:別に入れなくても支障はないんだけど