7z libraries for Ruby
Ruby has no 7z support in the standard library. Two gems work:
- seven-zip (
SevenZipRuby) is a native extension that compiles the bundled p7zip source (7-Zip’s code) when you install the gem. It reads and writes 7z with all 7-Zip methods, passwords and header encryption, and can extract to memory. It’s a fork by Fontist of the originalseven_zip_rubygem (last release 2020); the fork’s last stable release is from 2022, with a pre-release in 2025. - ffi-libarchive is an FFI binding to the C libarchive library. It reads and writes 7z and many other formats with one API, but can’t handle encrypted archives and needs libarchive installed on the system.
Pick seven-zip when you work with 7z specifically, especially encrypted archives; ffi-libarchive when your code handles TAR, ZIP and 7z together.
- ffi-libarchive ffi-libarchive is a Ruby FFI binding to libarchive that reads and writes 7z archives. How to install it, list and extract a 7z file, read entry data.
- seven-zip The seven-zip gem (SevenZipRuby) reads and writes 7z archives in Ruby using bundled 7-Zip (p7zip) code. How to install it, extract, list.