Skip to content
Advertisement

How to overcome – pip install ansible on windows failing with filename or extension too long on windows

how to fix the pip install failures on windows with below error. Getting this error while trying to install ansible.

I suspect it is with issue with selected pip package for install. but the same is working fine with Linux based systems. Will there be any difference with OS for pip install

JavaScript

Advertisement

Answer

Well, it seems to be a known bug:

https://github.com/ansible/ansible/issues/31419

In Ansible 2.4.0, the module copy use symbolic links in the tests suite: https://github.com/ansible/ansible/tree/devel/test/integration/targets/copy/files/subdir/subdir1

JavaScript

Windows 10, cannot create this directories tree because the path is too long. In fact the resolved path is:

JavaScript

bug report ends with:

We do not support installing ansible directly on a windows machine. You will need a linux like operating system to install ansible on

Workaround

A possible workaround is to download the wheel on pypi, it doesn’t depend on Linux or whatever, probably pure python:

JavaScript

(the pip install ansible command downloads the “source” .tgz archive, performs tests, … and the path issue is within the tests, so let’s use a ready-to-use pre-built bundle)

Once downloaded, use pip install path/to/the/wheel/file.whl

Tested and installed successfully on my Windows 10 machine:

JavaScript

ok, installed, but let’s try to import it:

JavaScript

works! yay!

Advertisement