-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
pip install fails to remove its temporary directory on Windows when it contains a deep folder hierarchy. #2892
Comments
Here is my working example: |
Does the patch below can addresses this issue? |
Gabi Davar [email protected] writes:
Hi, thanks for the patch. I will try this out during the week (when I have Btw, there's a typo in the comment in your patch, -- Stefano |
@mindw , unfortunately the patch is not sufficient. |
Thanks for testing this - I'll try and revise the patch. -gabi On Mon, Jun 15, 2015 at 12:40 PM, Stefano Mazzucco <[email protected]
|
@mindw If you have access to a Windows machine you can try out my example https://github.com/stefano-m/pip_issue_2892 (you will need node.js too). |
First of allEven though I have a workaround, I am happy to test possible fixes for WorkaroundI have a workaround that can help me solve the issue: I run Now my
By letting I have pushed the workaround in a branch of my working example: https://github.com/stefano-m/pip_issue_2892/tree/workaround |
I was thinking of adding a try/catch around the part the generates the problem and log a warning about the fact that the temporary directory could not be deleted. However I am not sure whether this may affect other errors not related to long paths, so I'd appreciate some advice. |
For what it is worth, I'm also seeing this error on a Docker container based on debian:latest pip: 7.1.2
Craziest part is it doesn't error if you just do A try-catch might be great. |
@kevhill, I agree with you that the try/catch would be a good deal. I would log the fact that pip couldn't remove the temporary directory and leave that to the user. What I am worried about is potential side effects. I am not familiar enough with pip's codebase, that's why I have not created a PR. Guidance from pip's core devs would be great. |
Closing this as a duplicate of #3055. |
Hi,
First off, I am using the following:
I will try and publicly upload and link a simple example for you to peruse later today.
TL;DR
Doing
pip install
on Windows for a package that creates a deep hierarchy of directories (e.g. by usingnpm install
internally) fails to remove its temporary build directorypip-*-build
because of the path length limitations imposed by Windows. This leaves the package "half installed".A workaround I have found is to wrap
pip.utils.rmtree
in atry: except
block that ignores the specificWindowsError
related to the path length limitations. This can work as a one-off because it requires to modifypip
's own code and I don't feel is completely satisfactory. Also, it does not actually remove thepip-*-build
directory that will be left dangling.Long long description
I have a Python package for a web app that uses
npm
to download its JavaScript requirements. To do so, I have created a custominstall
class that runsnpm install
withsubprocess
before running the actual installationrun
method and have overridden theinstall
class in mysetup
function using thecmdclass
keyword argument.pip install
works fine on GNU/Linux, but when I try it on Windows 7, it fails to remove the temporary directory it created and lefts the package half installed. After some Internet searching, I think this is due to the Maximum Path Length Limitation imposed on Windows and the way npm stores its dependencies in a nested way.The error reported is
The failure is in the
rmtree_errorhandler
function inpip\utils\__init__.py
, where it does anos.stat(path)
. I tried to prepend the path with the\\\\?\\
string as suggested in this stackoverflow question by adding something like the following:If I do that in
pip.utils.rmtree
, I getpip install
:pip uninstall
(if trying to remove an half-installed package):If I do that in
pip.utils.rmtree_errorhandler
, I getpip.utils.rmtree_errorhandler
, but only for the path variable inos.stat
, I get and error on the followingos.chmod
:pip.utils.rmtree_errorhandler
, but only for the path variable in bothos.stat
andos.chmod
, I get and error on the followingfunc
:Also, if I wrap the code of
pip.utils.rmtree_errorhandler
around atry: except:
that will return only ifWindowsError.winerror == 3
I get:Finally, I could get around the error by using the
try: except:
inpip.utils.rmtree
:but of course, that does not actually remove the temporary directory
pip-*-build
.The text was updated successfully, but these errors were encountered: