[Rubygems-developers] Problems with RemoteInstaller

Florian Frank flori at nixe.ping.de
Sat Nov 12 13:04:18 EST 2005


Hello,

I hade some problems using the Rubygems RemoteInstaller. It requires a 
'rubygems/open-uri.rb', that contains a copy of the 'open-uri.rb' file, 
that comes with Ruby. I think this was done to be compatible with older 
versions of Ruby.

I used the RemoteInstaller in an app, that used the standard 
'open-uri.rb', and I had some strange errors, because of this:

SystemStackError (stack level too deep):
    /usr/local/stow/ruby/lib/ruby/18/open-urirb:82:in 
`open_uri_original_open'
    /usr/local/stow/ruby/lib/ruby/18/open-urirb:87:in 
`open_uri_original_open'
    /usr/local/stow/ruby/lib/ruby/18/open-urirb:87:in 
`open_uri_original_open'
    /usr/local/stow/ruby/lib/ruby/18/open-urirb:87:in 
`open_uri_original_open'
...

Both libraries alias Kernel#open to this method and seem to confuse each 
other. I made the following patch, that solved the problem for me:

--- remote_installer.rb.bak     2005-11-12 18:17:16.330519355 +0100
+++ remote_installer.rb 2005-11-12 18:17:41.877160601 +0100
@@ -114,7 +114,11 @@
     # Read the data from the (source based) URI, but if it is a
     # file:// URI, read from the filesystem instead.
     def open_uri_or_path(uri, &block)
-      require 'rubygems/open-uri'
+      begin
+        require 'open-uri'
+      rescue LoadError
+        require 'rubygems/open-uri'
+      end
       if is_file_uri(uri)
         open(get_file_uri_path(uri), &block)
       else


Could you appy it to Rubygems, please?

-- 
Florian Frank



More information about the Rubygems-developers mailing list