mechboxes / mech

Easy command line virtual machines for VMWare
https://mechboxes.github.io/mech/
MIT License
311 stars 49 forks source link

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

Open ghost opened 3 years ago

ghost commented 3 years ago

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
arizvisa commented 3 years ago

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.

ghost commented 3 years ago

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

ghost commented 3 years ago

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 commented 3 years ago

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

ColdHeat commented 3 years ago

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