From: Scott Bronson Date: 2010-08-27T17:18:05+09:00 Subject: Re: Rubyzip - `dup': can't dup NilClass (TypeError) The 1.57 zipfile on this page fails for me: http://www.vim.org/scripts/script.php?script_id=2441 The Unix unzip command unzips it just fine. Here's the direct link to the failing zip: http://www.vim.org/scripts/download_script.php?src_id=11978 To test it in irb: require 'open-uri' require 'zip/zipfilesystem' open('http://www.vim.org/scripts/download_script.php?src_id=11978', 'rb') { |f| Zip::ZipFile.open(f) } this dies with: TypeError: can't dup NilClass from rubyzip-0.9.4/lib/zip/zip.rb:1163:in `dup' from rubyzip-0.9.4/lib/zip/zip.rb:1163:in `block in dup' from rubyzip-0.9.4/lib/zip/zip.rb:1163:in `map' ...etc the zipfiles before 1.57 are fine. For instance: require 'open-uri' require 'zip/zipfilesystem' open('http://www.vim.org/scripts/download_script.php?src_id=11524', 'rb') { |f| Zip::ZipFile.open(f) } works just fine. The nil entry is actually being added by read_central_directory_entries around line 1250 (I added the raise): @entrySet = ZipEntrySet.new @size.times { @entrySet << ZipEntry.read_c_dir_entry(io) || raise("nil entry!") } For some reason, read_c_dir_entry is returning nil. I haven't tried to figure out why since I'm not familiar with the internals of a zipfile. -- Posted via http://www.ruby-forum.com/.