I need to unpack an .rar archive with Ruby. I could not find a gem though.
I discovered the rar gem which only allows to create an archive. How can I extract a rar file, not just create it?
RAR files are safe in themselves. Like zip files, their purpose is to have other files. But it is worth noting that the files present in the RAR file can be dangerous. In fact, cybercriminals usually spread malware through archived files such as RAR files.
After doing some additional reading on the subject it seems that any gems that were for this are basically abandoned. But, you can brew install unrar
and use that from Ruby system('unrar l your_file.rar')
.
ffi-libarchive provides a gem-based solution. It works for rar files even though they don't specifically mention it (see issue #151). Add this to your application's Gemfile:
gem 'ffi-libarchive'
and then execute:
$ bundle
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With