# Bzipping a file from ruby

**URL:** <https://www.ruby-forum.com/t/bzipping-a-file-from-ruby/62561>\
**Category:** Ruby\
**Created:** [June 6, 2006, 4:35am UTC](https://www.ruby-forum.com/t/bzipping-a-file-from-ruby/62561 "2006-06-06T04:35:40Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Edgardo\_H](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/c68b51/32.png) [@Edgardo\_H](https://www.ruby-forum.com/u/Edgardo_H)\
**Post date:** [June 6, 2006, 4:35am UTC](https://www.ruby-forum.com/t/bzipping-a-file-from-ruby/62561/1 "2006-06-06T04:35:40Z")

</div>

Hi,

Is there a way to bzip2 a file from Ruby without invoking the unix  
app? I want to create a bzipped tarball without using any external  
programs so my app can run using anything but plain ol’ Ruby. I’m  
already using archive-tar-minitar to create the tarball but now I need  
a way to compress it.

Thanks,  
Ed

---

<div class="post-metadata">

**Author:** ![Edgardo\_H](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/c68b51/32.png) [@Edgardo\_H](https://www.ruby-forum.com/u/Edgardo_H)\
**Post date:** [June 6, 2006, 4:52am UTC](https://www.ruby-forum.com/t/bzipping-a-file-from-ruby/62561/2 "2006-06-06T04:52:06Z")

</div>

On Tue, 2006-06-06 at 11:33 +0900, Edgardo H. wrote:

> Hi,
> 
> Is there a way to bzip2 a file from Ruby without invoking the unix  
> app? I want to create a bzipped tarball without using any external  
> programs so my app can run using anything but plain ol’ Ruby. I’m  
> already using archive-tar-minitar to create the tarball but now I need  
> a way to compress it.

I don’t know of any pure ruby implementations of the bzip2 algorithm. I  
suspect that if there’s any libraries out there, they’d bind libbz2…  
at which point it’s also not pure ruby.

Aria

---

<div class="post-metadata">

**Author:** ![Edgardo\_H](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/c68b51/32.png) [@Edgardo\_H](https://www.ruby-forum.com/u/Edgardo_H)\
**Post date:** [June 6, 2006, 9:09am UTC](https://www.ruby-forum.com/t/bzipping-a-file-from-ruby/62561/3 "2006-06-06T09:09:48Z")

</div>

On 6/6/06, Aredridel [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> suspect that if there’s any libraries out there, they’d bind libbz2…  
> at which point it’s also not pure ruby.
> 
> Aria

Yup. I was looking for such a thing myself, and only found bz2[1]. In  
fact, that library seems to be the only way of utilizing BZip2 from  
Ruby currently; at least there are no other listed in the  
Library/Compression category of RAA [2].

Right now, I’m using the gzip algorithm instead, which you don’t even  
need a gem for (part of core). It would be nice to see pure-ruby  
implementations of the more advanced algorithms out there (bzip2,  
7-zip).

–  
-Alder

[1] [http://raa.ruby-lang.org/project/bz2/](http://raa.ruby-lang.org/project/bz2/)  
[2]  
[http://raa.ruby-lang.org/cat.rhtml?category\_major=Library;category\_minor=Compression](http://raa.ruby-lang.org/cat.rhtml?category_major=Library;category_minor=Compression)
