sindresorhus / gulp-zip

ZIP compress files
MIT License
270 stars 47 forks source link

Problem with OSX's unzip #38

Closed adam-lynch closed 9 years ago

adam-lynch commented 9 years ago

I'm using this module to create a ZIP containing a massive node-webkit .app. If I unzip with OSX's unzip on the command-line (no flags or errors returned) then the app will not open. The error I found in the Console utility is:

Attempting to SIGCONT to pid #37280 failed, with errno=#3 , or the process failed to actually start.

This is weird because I would assume it has nothing to do with this module (but rather the unzipping or a problem with my node-webkit app) but...

After zipping with gulp-zip, extracting with unzip and then running chmod -R 777 my.app, it's fine. Could be related to https://github.com/rogerwang/node-webkit/issues/1303#issuecomment-28915750.


gulp-zip@2.0.2 OSX 10.9.1 Node v0.10.24

dduponchel commented 9 years ago

The underlying library, JSZip, creates zip files without any metadata (like the UNIX rights). After extraction, you will likely get files with 644 permissions.

adam-lynch commented 9 years ago

@dduponchel hmm yeah, so I guess this is unexpected behaviour. Someone correct me if I'm wrong.

By the way, when I'm extracting using Finder, Finder must be somehow making up for the lack of metadata, right? Like, it must be finding and marking executables within (or even the entire contents) as 777 or something. Not really making a point here, just wondering.

dduponchel commented 9 years ago

The field "made by" is set to "DOS" : the archive manager knows that there won't be any useful metadata so it usually creates files with the default rights (I tested with unzip on linux). I never played with Finder, it may have a different behavior (like checking if the file is a .app). I created a feature request on JSZip side, see Stuk/jszip#194.

adam-lynch commented 9 years ago

Thanks @dduponchel :smile:

adam-lynch commented 9 years ago

I don't understand why this is closed. It's not fixed or anything.

sindresorhus commented 9 years ago

I think I closed the wrong issue. Sorry.

adam-lynch commented 9 years ago

No prob :)

On Tue, 13 Jan 2015 18:00 Sindre Sorhus notifications@github.com wrote:

I think I closed the wrong issue. Sorry.

— Reply to this email directly or view it on GitHub https://github.com/sindresorhus/gulp-zip/issues/38#issuecomment-69788740 .

kevva commented 9 years ago

@adam-lynch, could you try my fork https://github.com/kevva/gulp-zip/tree/yazl?

brian-mann commented 9 years ago

@adam-lynch I'm getting the exact same problem, and I can tell you're using this on node-webkit :wink:

Swapping out to the yazl fork does indeed seem to fix the issue.

adam-lynch commented 9 years ago

@kevva sorry, didn't see your reply 'til now. I might be able to later.

brian-mann commented 9 years ago

@adam-lynch @kevva Actually nevermind, this fork is blowing up when I try to zip up my app.

buffer.js:176
        this.length = +subject > 0 ? Math.ceil(subject) : 0;
                                          ^
RangeError: Maximum call stack size exceeded
adam-lynch commented 9 years ago

Looks like it's sorted in jszip; https://github.com/Stuk/jszip/pull/200

brian-mann commented 9 years ago

Nope. Still cannot get zipping to work even on that commit.

It zips just fine, and unzips just fine (from the terminal) but after unzipping and trying to open my app it gives me:

LSOpenURLsWithRole() failed with error -10810 for the file

dduponchel commented 9 years ago

@brian-mann after unzipping, what permissions do you have on the file ? JSZip will need two things in your case : unixPermissions:{executable:true} when adding the file and platform:"UNIX" when generating the zip file.

brian-mann commented 9 years ago

I spent about 6 hours today working with every zip library for node. The only one that has worked was using https://github.com/thejoshwolfe/yazl

No permission issues, zipping issues, or unzipping issues. Using it directly what the only way I could get anything to work.

dduponchel commented 9 years ago

I can't test it (I don't have OSX) but a search on your error indicates that a chmod a+x of the file before zipping it could solve the issue (so an issue with the file mode inside the zip), hence my question :) JSZip generates now a 755 file inside the zip when asked to : from what I understand it should be enough. Yazl re-uses the exising file mode : what do you have for the app file ? Using JSZip, could you confirm that, when extracted, the app file mode is 755 ? And check if your test still fail.

dduponchel commented 9 years ago

I just checked with a trainee with a mac at work, the inside of its apps have a umask of 002 : the files are 664, the folders are 775 (some even in 777). I'll do like yazl and reuse directly the mode.

dduponchel commented 9 years ago

I pushed updated code for JSZip and gulp-zip on git branches :

This version should generate 775 folders and keep the original file mode. Could you check if that fix your issue ?

adam-lynch commented 9 years ago

Confirmed that it's fixed as of 3.0.1 :smile: