Question

I am trying to read a gzipped file using Zlib:GzipReader. This works as expected using ruby 1.9.3 but I am getting a method_missing error for each_line when using Rubinius.

Is there any way to read a gzipped file using Rubinius?

require 'zlib'

Zlib::GzipReader.open("lines.txt.gz").each_line { |line|
  puts "#{line}"
}

Kernel(Zlib::GzipReader)#each_line (method_missing) at kernel/delta/kernel.rb:81
Was it helpful?

Solution

I believe this is a bug in Rubinius, you should consider opening an issue for it with the project. However, this workaround should get you going:

require 'zlib'
require 'stringio'

file = File.read("lines.txt.gz")
lines = Zlib::GzipReader.new(StringIO.new(file)).read
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top