viasite-ansible / ansible-role-zsh

Setup antigen with oh-my-zsh, powerlevel10k theme, fzf, autosuggestions, syntax-highlighting
https://habrahabr.ru/post/323496/
MIT License
347 stars 85 forks source link

unarchive: Failed to find handler #18

Open NickVolynkin opened 7 years ago

NickVolynkin commented 7 years ago

Role fails on the "Download fzf" step, which uses the unarchive module.

TASK [viasite-ansible.zsh : Download fzf] ** fatal: [localhost]: FAILED! => {"changed": false, "failed": true, "msg": "Failed to find handler for \"/private/var/folders/c6/qyn82s7d2d7dkhzqsl3p5yg80000gn/T/ansible_PEb4Qn/fzf-0.16.8-linux_amd64.tgz\". Make sure the required command to extract the file is installed. Command \"/usr/bin/tar\" detected as tar type bsd. GNU tar required. Command \"/usr/bin/unzip\" could not handle archive."}

I have both tar and unzip installed:

$ which tar
/usr/bin/tar
$ ls -hal /usr/bin/tar 
lrwxr-xr-x 1 root wheel 6 Jul 16  2015 /usr/bin/tar -> bsdtar
$  which unzip
/usr/bin/unzip
$ ls -hal /usr/bin/unzip
-rwxr-xr-x 2 root wheel 158K May  1  2015 /usr/bin/unzip

OSX, zsh already installed, default playbook, run with ansible-playbook -i 'localhost,' -c local playbook.yml.

I also doubt that https://github.com/junegunn/fzf-bin/releases/download/0.16.8/fzf-0.16.8-linux_amd64.tgz is the correct option for OSX, so I've opened #17. Running the playbook with --extra-vars "zsh_fzf_os={{ ansible_os_family }}" results in using the darwin release, but doesn't fix the problem.

Any ideas on how to debug this further?

NickVolynkin commented 7 years ago

Heh, I've overlooked the problem. I've got bsdtar, while GNU tar is required. So, brew install gnu-tar solved the problem.

NickVolynkin commented 7 years ago

Still not sure if this should be handled in the role.

popstas commented 7 years ago

I think that role should be provisioned on clean macOS only with brew installed, but I don't tested it on clean macOS... So you can add brew install gnu-tar and/or brew install fzf to role.

gaizeror commented 6 years ago

It is not working because the unarchive module uses /usr/bin/tar and installing gnu-tar does not replace the symlink of tar from bsdtar to gnu-tar

popstas commented 6 years ago

@gaizeror, just replace symlink yourself.

gaizeror commented 6 years ago

@popstas I am new to macOS, but I get permissions denied (also with sudo)

popstas commented 6 years ago

@gaizeror, try to become root with sudo -i

gaizeror commented 6 years ago

I tried, so wierd root cant change symlink

cupen commented 6 years ago

I meet the same problem in my CentOS7, but I have both the /bin/gtar and /bin/unzip. The odd thing was it works in my Debian9, This is both funny and annoying …… Then I find this.

$ tar xvf /home/cupen/.ansible/tmp/ansible-tmp-1523707936.0375483-68992850281293/source
tar (child): cannot run bzip2: No such file or directory
tar (child): trying lbzip2
tar (child): lbzip2: Cannot exec: No such file or directory
tar (child): Error is not recoverable: exiting now
tar: Child returned status 2
tar: Error is not recoverable: exiting now

HOLY SHIT ! OK, run yum install bzip2, then it works.

gaizeror commented 6 years ago

I installed manually fzf with brew install fzf

AjaxOdessa commented 6 years ago

@gaizeror Inability to edit /usr/bin on macOS is the result of SIP. Once it is disabled (requires restart & Recovery partition), you can make changes you need.

kenorb commented 1 year ago

Got similar error on Ubuntu 22.04:

"msg": "Failed to find handler for \"/tmp/site.tar.gz\". Make sure the required command to extract the file is installed. Command \"/usr/bin/unzip\" could not handle archive. Command \"/usr/bin/tar\" could not handle archive."
      - name: Extract site
        ansible.builtin.unarchive:
          src: /tmp/site.tar.gz
          dest: /var/www/html
          owner: root
          group: root
          mode: '0755'
          remote_src: yes
          extra_opts: "--no-same-owner --no-same-permissions -xz"
$ ansible --version
ansible 2.10.8
  config file = None
  configured module search path = ['/var/lib/jenkins/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python3/dist-packages/ansible
  executable location = /usr/bin/ansible
  python version = 3.10.6 (main, May 29 2023, 11:10:38) [GCC 11.3.0]

$ tar --version
tar (GNU tar) 1.34

$ unzip --version
caution:  both -n and -o specified; ignoring -o
UnZip 6.00 of 20 April 2009, by Debian. Original by Info-ZIP.
popstas commented 1 year ago

@kenorb , is it relative to project ansible-role-zsh?

kenorb commented 1 year ago

Is it relative to project ansible-role-zsh?

It is vanilla Ansible, sorry. But the issue could be related.

cueedee commented 11 months ago

To aid any future dwellers who like me landed here when looking for an answer to:

Command /usr/bin/tar could not handle archive: Unable to list files in the archive: /usr/bin/tar: You may not specify more than one -Acdtrux, --delete or --test-label option

In my case the cause turned out to be a mere typo in the extra_opts resulting in a command line option that tar didn't grok.

Similarly, I suspect that the -xz that @kenorb included in their extra_opts could have been the cause for failure if the xz utility needed for this option wasn't installed.