# Unzip EAR file?

**URL:** <https://www.ruby-forum.com/t/unzip-ear-file/60970>\
**Category:** Ruby\
**Created:** [May 18, 2006, 10:59pm UTC](https://www.ruby-forum.com/t/unzip-ear-file/60970 "2006-05-18T22:59:36Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![unknown](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/4bbf92/32.png) [@unknown](https://www.ruby-forum.com/u/unknown)\
**Post date:** [May 18, 2006, 10:59pm UTC](https://www.ruby-forum.com/t/unzip-ear-file/60970/1 "2006-05-18T22:59:36Z")

</div>

Hello group. New to ruby and needing the ability to unzip EAR files.  
Isn’t  
an EAR file technically just a zip file? I’ve been able to untar  
tarballs  
and unzip zip files in Ruby but failed for ear files. Any pointers  
appreciated.

Error msg: bad value for range

def unzip(zipfile, dest)  
zf = Zip::ZipFile.open(zipfile)  
zf.each do |entry|  
begin  
file=file\_to\_basename(entry)  
File.makedirs("#{dest}/#{file}") unless File.exists?  
“#{dest}/#{file}”  
zf.extract(entry, “#{dest}/#{entry.name}”)  
rescue Exception =\> e  
log(“Error while unzipping: #{dest}/#{file}: #{e}”, 1)  
end  
end  
end

---

<div class="post-metadata">

**Author:** ![unknown](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/4bbf92/32.png) [@unknown](https://www.ruby-forum.com/u/unknown)\
**Post date:** [May 18, 2006, 11:31pm UTC](https://www.ruby-forum.com/t/unzip-ear-file/60970/2 "2006-05-18T23:31:13Z")

</div>

Cliff C. wrote:

> Hello group. New to ruby and needing the ability to unzip EAR files. Isn’t  
> an EAR file technically just a zip file? I’ve been able to untar tarballs  
> and unzip zip files in Ruby but failed for ear files. Any pointers  
> appreciated.  
> I am just writing a deployment script for a web app, and there I am  
> unzipping WAR files without any problems (EAR should be the same from  
> this POV) with standard \*nix zip.

pete@dello:~$ file metasearch.war  
metasearch.war: Zip archive data, at least v1.0 to extract

I have never used unzip from Ruby for WAR/EAR files though - I am really  
curious now why should it not work?

Peter

---

<div class="post-metadata">

**Author:** ![unknown](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/4bbf92/32.png) [@unknown](https://www.ruby-forum.com/u/unknown)\
**Post date:** [May 19, 2006, 12:27am UTC](https://www.ruby-forum.com/t/unzip-ear-file/60970/3 "2006-05-19T00:27:00Z")

</div>

On Fri, May 19, 2006 at 06:29:05AM +0900, Peter S. wrote:

> pete@dello:~$ file metasearch.war  
> metasearch.war: Zip archive data, at least v1.0 to extract
> 
> I have never used unzip from Ruby for WAR/EAR files though - I am really  
> curious now why should it not work?
> 
> Peter

Yes, it is a strange one…It looks like it starts to unarchive the  
files but  
it chokes while extracting a war file from the ear.

from unzip in ruby:

path: ./tmp/ADT110\_1.1.0.2/ADT/Install/ADT.ear  
Error while unzipping: ADTWeb.war : bad value for range

system unzip shows the ADTWeb.war that fails in the ruby zip lib.

[ccyphers@ccyphers Install]$ unzip ADT.ear  
Archive: ADT.ear  
inflating: ADTWeb.war  
creating: META-INF/  
inflating: META-INF/.modulemaps  
inflating: META-INF/application.xml  
inflating: META-INF/ibm-application-ext.xmi  
inflating: META-INF/MANIFEST.MF
