From: Luka Stolyarov on 8 Jun 2010 01:14 Hello. I've trying to figure out rubyzip. Here's the code I had: require 'rubygems' require 'zip/zip' zf = Zip::ZipFile.open('616910.zip') However, when I run it, it throws an error /Users/lukastolyarov/.gem/ruby/1.8/gems/rubyzip-0.9.4/lib/zip/zip.rb:1163:in `dup': can't dup NilClass (TypeError) from /Users/lukastolyarov/.gem/ruby/1.8/gems/rubyzip-0.9.4/lib/zip/zip.rb:1163:in `dup' from /Users/lukastolyarov/.gem/ruby/1.8/gems/rubyzip-0.9.4/lib/zip/zip.rb:1163:in `map' from /Users/lukastolyarov/.gem/ruby/1.8/gems/rubyzip-0.9.4/lib/zip/zip.rb:1163:in `dup' from /Users/lukastolyarov/.gem/ruby/1.8/gems/rubyzip-0.9.4/lib/zip/zip.rb:1399:in `initialize' from /Users/lukastolyarov/.gem/ruby/1.8/gems/rubyzip-0.9.4/lib/zip/zip.rb:1410:in `new' from /Users/lukastolyarov/.gem/ruby/1.8/gems/rubyzip-0.9.4/lib/zip/zip.rb:1410:in `open' from zip.rb:5 I'm pretty sure the zip file is there and is not empty. What might be causing it? I googled the problem, but couldn't find a definitive answer. Thank you, Luka -- Posted via http://www.ruby-forum.com/.
From: Brian Candler on 8 Jun 2010 04:11 Luka Stolyarov wrote: > require 'rubygems' > require 'zip/zip' > > zf = Zip::ZipFile.open('616910.zip') > > However, when I run it, it throws an error > > /Users/lukastolyarov/.gem/ruby/1.8/gems/rubyzip-0.9.4/lib/zip/zip.rb:1163:in > `dup': can't dup NilClass (TypeError) Works fine for me with rubyzip-0.9.1 + "ruby 1.8.6 (2007-09-24 patchlevel 111) [i486-linux]", and I just upgraded to rubyzip-0.9.4 with the same results. What platform are you on? The offending code is here: # deep clone def dup newZipEntrySet = ZipEntrySet.new(@entrySet.values.map { |e| e.dup }) end which suggests to me that the zipfile is corrupt or an unsupported format, since @entrySet must contain a {value=>nil} pair. Try modifying this code (line 657): def ZipEntry.read_c_dir_entry(io) #:nodoc:all entry = new(io.path) entry.read_c_dir_entry(io) return entry rescue ZipError return nil end For example, comment out the rescue ZipError // return nil pair. It seems that this error handling is bad. Either an exception should be raised here, or the bad entry should be skipped (not saved as a nil value in @entrySet which causes the dup error you saw) Regards, Brian. -- Posted via http://www.ruby-forum.com/.
From: Luka Stolyarov on 8 Jun 2010 12:41 I'll give it a try, thank you! -- Posted via http://www.ruby-forum.com/.
From: Brian Candler on 8 Jun 2010 13:30 Luka Stolyarov wrote: > I'll give it a try, thank you! Just to be clear: I'd expect the program to crash still, but this time at an earlier point which will give a much more useful error about what went wrong when parsing the zip directory entry. -- Posted via http://www.ruby-forum.com/.
|
Pages: 1 Prev: Passenger Crashes, It needs an old version of rack Next: Difference between puts and print? |