Cocoapods: Unzip fail when zip contains chinese char on macOS 10.13

Created on 6 May 2018  Â·  21Comments  Â·  Source: CocoaPods/CocoaPods

I have a SDK, and there is a folder named FaceDistortion_20171205雪天的雪人 in the zip. When I exec pod install, I got a error:

[!] /usr/bin/unzip /var/folders/wc/3xbpwz1s7kbc3970y2kq8mvh0000gn/T/d20180506-48171-76pbah/file.zip -d /var/folders/wc/3xbpwz1s7kbc3970y2kq8mvh0000gn/T/d20180506-48171-76pbah

Archive:  /var/folders/wc/3xbpwz1s7kbc3970y2kq8mvh0000gn/T/d20180506-48171-76pbah/file.zip
bcb02cc7602513e6c0adca622302aec2112217a7
   creating: /var/folders/wc/3xbpwz1s7kbc3970y2kq8mvh0000gn/T/d20180506-48171-76pbah/IESVideoEditor-bcb02cc760-bcb02cc7602513e6c0adca622302aec2112217a7/
  inflating: /var/folders/wc/3xbpwz1s7kbc3970y2kq8mvh0000gn/T/d20180506-48171-76pbah/IESVideoEditor-bcb02cc760-bcb02cc7602513e6c0adca622302aec2112217a7/.clang-format
  inflating: /var/folders/wc/3xbpwz1s7kbc3970y2kq8mvh0000gn/T/d20180506-48171-76pbah/XXXXXX-bcb02cc760-bcb02cc7602513e6c0adca622302aec2112217a7/README.md
checkdir error:  cannot create /var/folders/wc/3xbpwz1s7kbc3970y2kq8mvh0000gn/T/d20180506-48171-76pbah/Bundles/FaceDistortion_20171205����������
                 Illegal byte sequence
                 unable to process Bundles/FaceDistortion_20171205����������/.
checkdir error:  cannot create /var/folders/wc/3xbpwz1s7kbc3970y2kq8mvh0000gn/T/d20180506-48171-76pbah/Bundles/FaceDistortion_20171205����������
                 Illegal byte sequence
                 unable to process Bundles/FaceDistortion_20171205����������/content.json.

I download the zip from Safari and can unzip it by system gui tool.

The CocoaPods is v1.5.0 and macOS is v10.13.

awaiting input workaround available

Most helpful comment

Maybe replace unzip with ditto:

ditto -V -x -k --sequesterRsrc --rsrc FILENAME.ZIP DESTINATIONDIRECTORY

All 21 comments

Looks like potentially an encoding issue

I try change the encoding:

export LC_CTYPE=C

But the CocoaPods require 'utf-8'. :(

Maybe replace unzip with ditto:

ditto -V -x -k --sequesterRsrc --rsrc FILENAME.ZIP DESTINATIONDIRECTORY

It works OK on macOS 10.13.3 (my machine), but fails on 10.13.4 (my colleague's machine) 😞 It seems that the system upgrade changed the default encoding behavior of the unzip utility.

How to fix it now?

Has anyone fix?

I replace unzip with ditto.

How to replace unzip ? Or other fix ?

I resolve the problem by changing the 'source' because the chinese char is not important.

  1. Find the 'xxx' 's location.
    In terminal execute find .cocoapods/repos/master/Specs -iname xxx
  2. Change to the location and entry the version's directory.
  3. Open the 'xxx.podspec.json' file and look up the key named 'source'.
  4. Manually download the source and unzip the 'xxx.zip' by GUI unzip tools.
  5. Modify the chinese char to ascii char then zip all files to 'xxx.zip'.
  6. Move the new 'xxx.zip' to your server's path and keep the server open. (eg. Mac's apache server path)
  7. Modify the 'source' in 'xxx.podspec.json' file to your new server's path.
  8. Now you can execute pod install --no-repo-update or pod update --no-repo-update

It works for me. Good luck!

I hook the unzip function to ditto, it works.

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates.

require 'cocoapods-downloader/http'

module Pod
    module Downloader

        # macos 10.13.4 use APFS, it's unzip have a encoding bug to Chinese Path.
        # We use `ditto` instead of `unzip`
        # see https://github.com/CocoaPods/CocoaPods/issues/7711
        class RemoteFile < Base
            executable :ditto
            def unzip!(*args)
                flag = args.index("-d")
                unpack_from = args[flag - 1]
                unpack_to = args[flag + 1]
                ditto! '-x', '-k', '--sequesterRsrc', '-rsrc', unpack_from, unpack_to
            end
        end
    end
end

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates.

This _seems_ like something we can fix.

I am not sure that this issue still active in macOS 10.14. Because I keep the hook method in my project, and the all pods remove the Chinese path.

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates.

This issue will be auto-closed because there hasn't been any activity for a few months. Feel free to open a new one if you still experience this problem :+1:

I replace unzip with ditto.

works for me thanks

I have the macOS Catalina 10.15.2 and I still have this issue. The ditto workaround works great but there is still an issue with the unzip command.

ditto worked great for me :)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Curtis-Halbrook picture Curtis-Halbrook  Â·  3Comments

hmistry picture hmistry  Â·  3Comments

pronebird picture pronebird  Â·  3Comments

pallaviMN picture pallaviMN  Â·  3Comments

sonu5 picture sonu5  Â·  3Comments