TAR libraries for Ruby
- minitar is the usual choice: a pure-Ruby gem that packs and unpacks directories in one call and gives entry-by-entry reading and writing. Combine it with
Zlib::GzipReader/Zlib::GzipWriterfrom the standard library for.tar.gz. It reads and writes ustar headers and GNU long names; it skips pax headers, so names longer than 100 bytes in pax archives (Python, Go, bsdtar) come out truncated. - RubyGems itself contains
Gem::Package::TarReaderandGem::Package::TarWriter(used for.gemfiles, which are tar archives). They are available in every Ruby without a gem install, but they are internal to RubyGems and documented only as part of it; prefer minitar in application code.
For .tar.xz or .tar.zst, decompress with a binding such as ruby-xz or zstd-ruby and pass the resulting IO to minitar.
- minitar minitar is a pure-Ruby library to read and write TAR and .tar.gz archives. How to pack and unpack folders, list entries and add files from memory, with code.