Skip to content

NoMethodError: undefined method `pos' for #<Bzip2::Reader:0xaa2bf5c> #11

Description

@dadooda

Hi

I'm trying to use bzip2-ruby to stream-in .tar.bz2 files via Gem::Package::TarReader.

BRIEF: It doesn't work yet due to this:

NoMethodError: undefined method `pos' for #<Bzip2::Reader:0xaa2bf5c>

Details follow.

require "bzip2-ruby"
require "rubygems/package"

#fn = "/path/to/file.tar"
fn = "/path/to/file.tar.bz2"
#fn = "/path/to/file.tar.gz"

stream = if fn.match /\.bz2\z/
  Bzip2::Reader.open(fn)
elsif fn.match /\.gz\z/
  Zlib::GzipReader.open(fn)
elsif fn.match /\.tar\z/
  File.open(fn)
else
  raise "Error: Don't know how to handle '#{fn}', aborting"
end

untar = Gem::Package::TarReader.new(stream)
untar.each do |entry|
  ...
end

Plain tar and .tar.gz work. .tar.bz2 doesn't, here's the exception info:

NoMethodError: undefined method `pos' for #<Bzip2::Reader:0xaad6394>
        from /home/rbdev/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/site_ruby/1.9.1/rubygems/package/tar_reader.rb:42:in `initialize'
        from /home/rbdev/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/site_ruby/1.9.1/rubygems/package/tar_reader.rb:23:in `new'
        from /home/rbdev/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/site_ruby/1.9.1/rubygems/package/tar_reader.rb:23:in `new'

Thank you.

Alex

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions