unzip error 22: invalid argument

Upgraded to MacOS Catalina and now I cannot unzip any zipped file. I had no problems before. Also, moving the file or redownloading is not fixing it. Multiple files of different sizes failed. MacBook user here.

MacBook

Posted on Oct 13, 2019 10:08 PM

Reply
Question marked as Top-ranking reply

Posted on Dec 1, 2019 12:56 AM

The bug is in the Archive Utility provided with MacOS Catalina.


I have used "The Unarchiver" app downloaded from the App Store. Worked like a charm!

It asks you during unarchiving to choose the encoding for the characters causing the Archive Utility to crash.

77 replies

Oct 15, 2019 8:47 AM in response to galking

It’s either a corrupt zip archive, or your installed zip is old, or whatever is pretending to be zip is buggy.

Use zip -v and unzip -v and see if it’s older than InfoZip zip 3.0 and unzip 6.0.

If older, upgrade using homebrew or otherwise.

And if it’s not InfoZip zip and unzip you’re finding, homebrew yourself copies of InfoZip zip and unzip, and check again.

Nov 23, 2019 5:43 AM in response to heiko1960

heiko1960 wrote:

what´s going on here? I have the same problem.
I cannot unzip any zipped file.


Did you read the whole thread through, or do you want folks here to go back through the whole thread with you too, asking and answering the same questions for a third time?


If this is the third report of the same issue—and not something new and different—then some Windows zip tools are producing a questionable or bad zip archive file. This zip archive containing invalid character encoding for the filenames. Encountering one of these zip files is causing the (rewritten?) Mac unzip tool to crash. Pending a fix for this unzip from the zip provider and/or from Apple—log feedback, reference this thread—launch Terminal.app and use ditto from the command line. Links to the ditto command are included in a previous reply of mine here.


If this is a different or unrelated unzip crash, then we’ll need more details. Tools used, versions, platforms, commands used, that sort of thing. Starting a new thread is probably a good idea, too. Maybe also referencing this thread and that the zip filename encoding as what the problem isn’t, if ditto and such doesn’t work with your particular zip archive file.

Nov 7, 2019 10:50 AM in response to MrHoffman

Looks like this might be a known limit of zip, which is what these archives are being created as, and 7-Zip is allowing something into the zip archive file names that it (arguably) probably should not. There might be a workaround, but for the creator of the zip archives. See the following URL, and see the -mcu stuff below.


https://sourceforge.net/p/p7zip/discussion/383044/thread/18fe4771/


Caslau.zip unpacks with the command line, as well:


$ zipinfo Caslau.zip     
Archive:  Caslau.zip
Zip file size: 2255415099 bytes, number of entries: 348
drwxa--     2.0 fat        0 b- stor 19-May-06 01:11 Czech Cem_Caslau/
-rw-a--     2.0 fat  6633597 b- defX 17-Sep-17 11:39 Czech Cem_Caslau/20170917_113951.jpg
-rw-a--     2.0 fat  6431121 b- defX 17-Sep-17 12:20 Czech Cem_Caslau/20170917_121957.jpg
...
-rw-a--     2.0 fat  6184800 b- defX 17-Sep-17 12:02 Czech Cem_Caslau/Friedländer Josef, Gustav_20170917_120216.jpg
-rw-a--     2.0 fat  7738339 b- defX 17-Sep-17 12:02 Czech Cem_Caslau/Friedländer Josef, Gustav_20170917_120220.jpg
-rw-a--     2.0 fat  8756593 b- defX 17-Sep-17 12:02 Czech Cem_Caslau/Friedländer Josef, Gustav_20170917_120227.jpg
...
-rw-a--     2.0 fat  6808250 b- defX 17-Sep-17 12:16 Czech Cem_Caslau/_u_20170917_121653.jpg
348 files, 2263625977 bytes uncompressed, 2255356879 bytes compressed:  0.4%
$ unzip Caslau.zip  "Czech Cem_Caslau/Friedländer Josef, Gustav_20170917_120220.jpg"
Archive:  Caslau.zip
  inflating: Czech Cem_Caslau/Friedländer Josef, Gustav_20170917_120220.jpg  
$ file "Czech Cem_Caslau/Friedländer Josef, Gustav_20170917_120220.jpg"
Czech Cem_Caslau/Friedländer Josef, Gustav_20170917_120220.jpg: JPEG image data, Exif standard: [TIFF image data, little-endian, direntries=16], baseline, precision 8, 3096x4128, frames 3
$ 



I'm getting an encoding error in some contexts, though:


open  "Czech Cem_Caslau/Friedl%E4nder Josef, Gustav_20170917_120220.jpg"


Looking at the not-working.zip in a directory listing, I'm seeing the same %E4 encoding in the unpacked filename.


That's almost certainly a z


In summary, it's possible to unpack the zip archives using the command line, which gets you where you want, if not entirely the way you want. I'm going to have to dig into the contents of the zip archives and the zip design docs in some detail and maybe into the 7z tool to see more about what's going on here, but that's something that won't effect your ability to read these archives.


Yes, I know, the restored filenames will be wrong. A script to fix that is certainly feasible.


7-Zip 7za (16.02) on macOS sees the same issue with unpacking the file names, so no help there.


With the Windows 7z/7za tool creating this zip archive, maybe switching from the default -mcu=off to -mcu=on might help? This selects UTF-8 filenames. This -mcu=on is discussed in the URL above. There's no Windows box handy to test that here, though.

Jan 19, 2020 2:18 PM in response to Mackytack

Use one of the downloaded apps. That’ll probably be more comfortable for you.


The macOS command line is accessed using Terminal.app. That app is located in /Applications/Utilities Launch that.


Assuming your zip file foo.zip is in your home directory, assuming the file name contains no “special” characters such as spaces or quotes, and assuming you want to unpack it to the bar subdirectory under your home directory...


mkdir ~/bar
ditto -x -k  ~/foo.zip  ~/bar

Oct 23, 2019 9:13 AM in response to Chemostat

I just spoke to support. I was told this is happening because Catalina no longer reads 32 bit and if the file was compressed on a Microsoft computer a Mac running Catalina will not be able to read it. I was not given any fix for this, I guess they just assume the 32 bit will be phased out. I was told to try 7zip as a workaround, about to try that.

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

unzip error 22: invalid argument

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.