-
Notifications
You must be signed in to change notification settings - Fork 2.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-installed Poetry encountering EnvironmentError "Permission denied" on Windows when upgrading cffi #2896
Comments
@PAStheLoD not sure that is a poetry problem tbh. Looks like You should be able to reproduce the issue when running the command from this error manually.
Also your experience on poetry from master might be better for this scenario. There are some improvements on how we install packages. |
Sorry for the incomplete/unclear report. What I haven't explicitly stated is that poetry is installed into the same virtualenv that it manipulates. So I guess it is using that particular file. pip itself vendors most/all (?) of its dependencies (if I understand the pip repo correctly). Thanks for the quick reply! If I'll have some time I'll try to reproduce this with just pip, and will check out master too. |
Exact same issue with poetry, cffi and windows, I try to create a minimum reproduction |
@PAStheLoD @jeremad as I mentioned before this is to do with As for the failures, this might no longer be an issue with the latest pre-release since the installation logic and venv creation (#2666) has changed. Please try with the pre-release. |
The install part itself successfully happens, it's the removal of the temp pip-uninstall-[nonce] thing. Presumably pip moves the potentially still in-use package to a temp folder. Then tries to delete it on exit, and fails, because it's used (by poetry or whatever invoked pip from the same venv). At least this is my (admittedly incomplete) understanding. I tried to find some relevant discussion about this post-run cleanup mechanism, but only found this pypa/pip#7567 , and it seems this Windows-only thing is still not implemented (and likely it wouldn't be able to handle this case anyway). So probably the main problem is that poetry should not both manage and run from the same venv. Thanks again! |
Since imported modules are in memory, deleting their files should not matter unless it is deleting an
Poetry in theory should be running outside the venv anyway, unless it was explicitly installed into the venv. |
Oh, I thought .pyd files were similar to .dll files in this regard. (So that they get memory mapped into the process space, but even after reading about it I'm not sure. If they are created with Cython then they are not bytecode but machine code.) Yes, in my case it was explicitly installed into the same venv. |
@Korijn what happens when you do the following? (My windows is a bit rusty!) python3.6 -m venv .venv
.venv\Scripts\python.exe -m pip install -U pip |
Seems to be fine... huh... |
@Korijn confirming that is python 3.6? This is bizarre. I'll try reproducing it in a windows VM. |
I have a similar issue. Newest version of poetry and Windows 10 Home (version 20H2), a fresh environment and Python 3.8.6. Using PowerShell in the new Windows Terminal app. When running
If anyone wants to reproduce this:
|
@Toxe Looks like a pip issue somehow, so maybe out of poetry's control. Looks like at the moment the error occurs, poetry had launched this command in a subprocess: Have you tried deleting that file? Are you sure the issue is reproducible in a fresh environment? |
Yes, 100% sure. Actually the above log was from a fresh environment. |
Maybe the Does |
This is the
|
@Toxe OK, nothing all too meaningful there. Does not give any more clues. Seems to me like the only sure thing, is that there is a file that can not be deleted when pip is trying to uninstall something as part of an upgrade. And to me it is not sure that the issue lies on poetry's side. |
I agree, at this point I suspect some weird Windows access permissions issue. |
FYI: I've encountered this problem many times over various conda/python/pip/poetry -versions and it's still a thing! Is there a known issue somewhere? Latest setup with this error:
Solution:
|
I'm going to close this one as finding a reproducer has been inconclusive, and more importantly, most of the people commenting are likely experiencing #1031. I'm dubious that this will ever be reproducible, as the only user who has provided details is installing Poetry into the same environment, which is obviously fraught as an overlapping dependency tree will cause Poetry to pull the rug out from under itself. |
I'm experiencing exactly the same problem on Updating dependencies
Resolving dependencies... (30.4s)
Writing lock file
Package operations: 26 installs, 2 updates, 0 removals
• Updating charset-normalizer (3.0.1 -> 2.0.12): Failed
CalledProcessError
Command 'C:\XXX_VENV\Scripts\python.exe -m pip install --disable-pip-version-check --isolated --no-input --prefix C:\XXX_VENV --upgrade --no-deps %LOCALAPPDATA%\pypoetry\Cache\artifacts\56\d7\9b\d9f1495af5a4b39024defc8404085361a30368aaa800fecb9fc228c5e0\charset_normalizer-2.0.12-py3-none-any.whl' returned non-zero exit status 1.
at C:\python38\lib\subprocess.py:516 in run
512│ # We don't call process.wait() as .__exit__ does that for us.
513│ raise
514│ retcode = process.poll()
515│ if check and retcode:
→ 516│ raise CalledProcessError(retcode, process.args,
517│ output=stdout, stderr=stderr)
518│ return CompletedProcess(process.args, retcode, stdout, stderr)
519│
520│
The following error occurred when trying to handle this error:
EnvCommandError
Command C:\XXX_VENV\Scripts\python.exe -m pip install --disable-pip-version-check --isolated --no-input --prefix C:\XXX_VENV --upgrade --no-deps %LOCALAPPDATA%\pypoetry\Cache\artifacts\56\d7\9b\d9f1495af5a4b39024defc8404085361a30368aaa800fecb9fc228c5e0\charset_normalizer-2.0.12-py3-none-any.whl errored with the following return code 1, and output:
Looking in indexes: http://pypi.ad.solactive.com/packages/stable
Processing %LOCALAPPDATA%\pypoetry\cache\artifacts\56\d7\9b\d9f1495af5a4b39024defc8404085361a30368aaa800fecb9fc228c5e0\charset_normalizer-2.0.12-py3-none-any.whl
Installing collected packages: charset-normalizer
Attempting uninstall: charset-normalizer
Found existing installation: charset-normalizer 3.0.1
Uninstalling charset-normalizer-3.0.1:
Successfully uninstalled charset-normalizer-3.0.1
ERROR: Could not install packages due to an OSError: [WinError 5] Access is denied: 'C:\\XXX_VENV\\Lib\\site-packages\\~harset_normalizer\\md.cp38-win_amd64.pyd'
Check the permissions.
at ~\\...\\lib\site-packages\poetry\utils\env.py:1540 in _run
1536│ output = subprocess.check_output(
1537│ command, stderr=subprocess.STDOUT, env=env, **kwargs
1538│ )
1539│ except CalledProcessError as e:
→ 1540│ raise EnvCommandError(e, input=input_)
1541│
1542│ return decode(output)
1543│
1544│ def execute(self, bin: str, *args: str, **kwargs: Any) -> int:
The following error occurred when trying to handle this error:
PoetryException
Failed to install %LOCALAPPDATA%/pypoetry/Cache/artifacts/56/d7/9b/d9f1495af5a4b39024defc8404085361a30368aaa800fecb9fc228c5e0/charset_normalizer-2.0.12-py3-none-any.whl
at ~\\...\\lib\site-packages\poetry\utils\pip.py:58 in pip_install
54│
55│ try:
56│ return environment.run_pip(*args)
57│ except EnvCommandError as e:
→ 58│ raise PoetryException(f"Failed to install {path.as_posix()}") from e
59│
• Installing pycparser (2.21)
Please let me know if you need more information to re-open the ticket. |
Hi @SergeyHein, I am facing the same issue on my build server. |
@mohghaderi - I have the exact same problem. We "fixed" it by repeatedly trying the install call. Most of the time this works as you'll fail on different packages. There is also a related SO question: https://stackoverflow.com/questions/64151403/poetry-update-has-access-denied |
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
I am on the latest Poetry version.
I have searched the issues of this repo and believe that this is not a duplicate.
If an exception occurs when executing a command, I executed it again in debug mode (
-vvv
option).OS version and name: Windows 10
Poetry version: 1.0.10
Issue
I've just encountered this problem while running poetry update, which upgraded the cffi package. Using pip 20.2.3 on python 3.9b5 on Windows 10, while using poetry 1.0.10.
Of course it's not the best practice to install poetry via pip. Maybe providing a command line argument to ignore these errors might be worth it?
The text was updated successfully, but these errors were encountered: