Skip to content

Instantly share code, notes, and snippets.

@3dd13
Created August 31, 2011 08:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save 3dd13/1183048 to your computer and use it in GitHub Desktop.
Save 3dd13/1183048 to your computer and use it in GitHub Desktop.
the reason of ruby_core_source.rb:57 'initilize': not in gzip format (Zlib::GzipFile::Error)
#
# the problem was
# this file was TAR compressed but not TAR.GZ
#
uri_path = "http://ftp.ruby-lang.org/pub/ruby/1.9/" + ruby_dir + ".tar.gz"
Tempfile.open("ruby-src") { |temp|
temp.binmode
uri = URI.parse(uri_path)
uri.download(temp)
tgz = Zlib::GzipReader.new(File.open(temp, "rb"))
FileUtils.mkdir_p(dest_dir)
Dir.mktmpdir { |dir|
inc_dir = dir + "/" + ruby_dir + "/*.inc"
hdr_dir = dir + "/" + ruby_dir + "/*.h"
Archive::Tar::Minitar.unpack(tgz, dir)
FileUtils.cp(Dir.glob([ inc_dir, hdr_dir ]), dest_dir)
}
}
# just a temp workaround when the ruby source format is TAR, but not TAR.GZ
#
# tgz = Zlib::GzipReader.new(File.open(temp, "rb"))
tgz = File.open(temp, "rb")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment