Poetry: Fixing permission error when upgrading dulwich
All notes in this series:
- (1) Poetry: Fixing dubious ownership error
- (2) Poetry: build.py example
- (3) Poetry: Automatically generate package version from git commit
- (4) Poetry: Fix warning about sources
- (5) Poetry: Running Black and isort with pre-commit hooks
- (6) Poetry: Fixing permission error when upgrading dulwich
- (7) NiceGUI with Click, Poetry, auto-reload and classes
- (8) Poetry: Offline installation of packages
- (9) Run Poetry command as systemd service
- (10) GitLab CI and poetry-dynamic-versioning
- (11) Poetry: install alpha builds
When attempting to upgrade from Poetry v1.5.1 to v1.6.1 by running poetry self update
I got the following error:
$ poetry self update
Updating Poetry version ...
Using version ^1.6.1 for poetry
Updating dependencies
...
Package operations: 77 installs, 14 updates, 0 removals
...
• Updating dulwich (0.21.5 -> 0.21.6): Failed
...
PermissionError: [WinError 5] Access is denied: 'C:\\Users\\<user>\\AppData\\Roaming\\pypoetry\\venv\\Lib\\site-packages\\~ulwich\\_diff_tree.cp310-win_amd64.pyd'
It appeared to be stuck trying to upgrade dulwich. Subsequent attempts to fix this by doing poetry self update
then hit this error:
ModuleNotFoundError: No module named 'dulwich'
Presumably the dulwich installation got broken somehow? My initial attempts to fix this by re-installing Poetry still led to the same error, because the virtual environment persists between re-installs.
The fix §
I fixed this error with the following manual steps:
- Delete this directory, which was causing the
PermissionError
1:C:\Users\<user>\AppData\Roaming\pypoetry\venv\Lib\site-packages\~ulwich
. - Find the virtual env
activate
script at:C:\Users\<user>\AppData\Roaming\pypoetry\venv\Scripts
. - Run
./activate
to enter the Poetry virtual env. - Run
pip install dulwich==0.21.6
to install dulwich v0.21.6 in the Poetry virtual env.
Then I was able to run poetry self update
successfully.
I did not need admin rights to delete this, so I’m not sure why Poetry was consistently getting
PermissionError
. ↩︎