go-utils icon indicating copy to clipboard operation
go-utils copied to clipboard

Cannot zip files in subdirectories

Open sa-spag opened this issue 6 years ago • 12 comments

Hey there 😃

Calling ziputil.ZipDir("path/to/file", "path/to/zip", false) produces the /usr/bin/zip -rTy path/to/zip file command which ultimately fails with zip I/O error: No such file or directory as file does not exist but path/to/file does. Indeed, this happens: https://github.com/bitrise-io/go-utils/blob/2a09aab8380d7842750328aebd5671bcccea89c8/ziputil/ziputil.go#L24 Before opening a pull request I wanted to know if there was any reason behind this implementation. Thanks!

sa-spag avatar Feb 14 '19 10:02 sa-spag

Hello @sa-spag

is this a custom script, or the Create ZIP step?

fehersanyi-bitrise avatar Feb 14 '19 10:02 fehersanyi-bitrise

I can reproduce the issue with the Create ZIP step.

sa-spag avatar Feb 14 '19 10:02 sa-spag

Could you please send me a build's url where this issue happens, so I can check out the full logs to it?

fehersanyi-bitrise avatar Feb 14 '19 10:02 fehersanyi-bitrise

Here it is. Notice the:

config:
- SourcePath: path/to/file
- Destination: path/to/zip
Issue with compress: command: (/usr/bin/zip "-rTy" "path/to/zip" "file") failed, output: zip I/O error: No such file or directory
zip error: Could not create output file (path/to/zip), error: exit status 15

sa-spag avatar Feb 14 '19 10:02 sa-spag

could it be that the correct path would be Users/vagrant/git/fastlane/test_output/BlaBlaCar.test_result/ ?

hmm that is the same that you set 🤔 I would try it to be sure

fehersanyi-bitrise avatar Feb 15 '19 10:02 fehersanyi-bitrise

As I expected:

Error: failed to parse config:
- SourcePath: /Users/vagrant/git/fastlane/test_output/BlaBlaCar.test_result/: file does not exist

Again I'm pretty sure my initial problem is that filepath.Base is called but I want to make sure it's indeed not the intended behavior.

sa-spag avatar Feb 15 '19 17:02 sa-spag

could you add and run a script step with:

#!/bin/bash
set -e
set -x
/usr/bin/zip "-rTy" "/Users/vagrant/git/fastlane/test_output/BlaBlaCar.test_result.zip" "BlaBlaCar.test_result"

fehersanyi-bitrise avatar Feb 18 '19 15:02 fehersanyi-bitrise

"BlaBlaCar.test_result" does not exist (but fastlane/test_output/BlaBlaCar.test_result does), the previous snippet will fail. FYI I already implemented a workaround using a script step:

- script:
    title: Compress test results bundle
    is_always_run: true
    inputs:
    - content: |-
        #!/usr/bin/env bash
        set -ex
        cd fastlane/test_output
        zip -qrTy BlaBlaCar.test_result.zip BlaBlaCar.test_result

sa-spag avatar Feb 18 '19 15:02 sa-spag

I'm glad you found a solution! and I realised that if you give it the long path, then the second argument needs the same path to it as well like /usr/bin/zip "-rTy" "/Users/vagrant/git/fastlane/test_output/BlaBlaCar.test_result.zip" "/Users/vagrant/git/fastlane/test_output/BlaBlaCar.test_result"

fehersanyi-bitrise avatar Feb 18 '19 19:02 fehersanyi-bitrise

Bump—is this issue still on the radar? The workaround is pretty inconvenient for something that should work out of the box. Thanks!

usmonster avatar May 26 '19 16:05 usmonster

Hello @fehersanyi-bitrise, is this issue still considered?

tdesert avatar Mar 11 '20 17:03 tdesert

Hi @tdesert, Could you please send a build URL where the issue is reproducible? My guess is that the issue happens when the destination directory does not exist, but this should be validated. Thanks

adborbas avatar Sep 08 '20 12:09 adborbas