mech icon indicating copy to clipboard operation
mech copied to clipboard

Cannot find a valid box with a VMX file in tar archive

Open ghost opened this issue 4 years ago • 5 comments

using vmware-workstation 16 debian 10(buster) kernel 4.19 mech 0.7.6

whatever box i am trying to use, i am getting same error:

tar: Pattern matching characters used in file names
tar: Use --wildcards to enable pattern matching, or --no-wildcards to suppress this warning
tar: *.vmx: Not found in archive
tar: Exiting with failure status due to previous errors
Cannot find a valid box with a VMX file in it

ghost avatar Mar 29 '21 22:03 ghost

when adding, or init'ing? gnu tar is only used in two places at https://github.com/mechboxes/mech/blob/v0.7.6/mech/utils.py#L422, so it'd have to be that the --wildcards parameter isn't being passed to it correctly.

arizvisa avatar Mar 30 '21 01:03 arizvisa

when initing - i tried manually downloading the file and using it, nothing helps

ghost avatar Apr 06 '21 11:04 ghost

there is an issue with debian gnu tar : if you place --wildcards after -tf option, it can not find anything gives error :

tar -tf --wildcards  vmware_desktop.box  "*.vmx"
tar: --wildcards: Cannot open: No such file or directory
tar: Error is not recoverable: exiting now

bit if you reverse it :

tar --wildcards -tf  vmware_desktop.box  "*.vmx"
       centos-7-1-1.x86_64.vmx

ghost avatar Apr 06 '21 13:04 ghost

I was able to hack it by editing this function:

def tar_cmd(*args, **kwargs):
    try:
        proc = subprocess.Popen(['tar', '--help'], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
    except OSError:
        return None
    if proc.returncode:
        return None
    stdoutdata, stderrdata = map(b2s, proc.communicate())
    tar = ['tar', '--wildcards']
    if kwargs.get('wildcards') and re.search(r'\b--wildcards\b', stdoutdata):
        tar.append('--wildcards')
    if kwargs.get('fast_read') and sys.platform.startswith('darwin'):
        tar.append('--fast-read')
    tar.extend(args)
    return tar

i just added --wildcard into tar list and seems to work but it is not by a long shot the direct answer

ghost avatar Apr 06 '21 15:04 ghost

If you figure out an appropriate solution here a PR would be welcome!

ColdHeat avatar Apr 21 '21 13:04 ColdHeat