Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8588421
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T22:47:55+00:00 2026-06-11T22:47:55+00:00

I am trying to decompress a file with following Ruby code. File.open(file_compressed.gz) do |compressed|

  • 0

I am trying to decompress a file with following Ruby code.

File.open("file_compressed.gz") do |compressed|
  File.open("file_decomp","w") do |decompressed|
    gz = Zlib::GzipReader.new(compressed)
    result = gz.read
    decompressed.write(result)
    gz.close
  end
end

But I am getting following error –

 not in gzip format (Zlib::GzipFile::Error)
 ./features/support/abc/abc_file.rb:44:in `initialize'

When I decompress the same file using gzip command on Mac it produced the correct uncompressed output.
For following command I can see –

 $file file_compressed.gz
 file_compressed.gz: gzip compressed data, from FAT filesystem (MS-DOS, OS/2, NT)

Do I need to put any header data while I create the compressed file with Zlib? Because when I use the inflate method instead of the GzipReader I get following error –

 incorrect header check (Zlib::DataError)
  ./features/support/abc/abc_file.rb:69:in `inflate'
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T22:47:56+00:00Added an answer on June 11, 2026 at 10:47 pm

    If you’re on a platform that doesn’t use LF delimiters, but CR+LF, you may need to open the file in binary mode for reading:

    File.open("file_compressed.gz", "rb") do |compressed|
      # ...
    end
    

    This should also avoid interpreting the input stream as anything but 8-bit binary.

    Be sure to open your output file the same way using "wb" as the flag.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to decompress a file that was compressed using the DEFLATE algorithm and
I am trying to programmatically decompress a .xml.gz file. It seems to be all
I get an exception when trying to decompress a (.gz) file using the GZipStream
I'm trying to convert the following bash code into C++ using boost::iostreams: #!/usr/bin/bash (
I am trying to decompress an AES-256 encrypted zip file on Windows Phones 7
I'm trying to decompress a tar file into a directory, but have no idea
I have a problem trying to decompress (in Java) a string that was compressed
Hey, I'm trying to unzip a file using this class: public class Decompress {
I'm trying to decompress gzipped data with Inflater . According to the docs, If
I have a gzip file and I am trying to read it via Python

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.