You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have searched the issue tracker and believe that this is not a duplicate.
Make sure you run commands with -v flag before pasting the output.
Steps to reproduce
I am mounting a docker volume in my devcontainer at <project path>/.venv to try and cache the virtual environments between rebuilds, and then running pdm venv create in my project. I also have venv.in_project set to true in pdm.toml.
Actual behavior
[VirtualenvCreateError]: The location /<project path>/.venv is not empty, add --force to overwrite it.
Adding --force gives:
Cleaning existing target directory /<project path>/.venv
[OSError]: [Errno 16] Device or resource busy: '/<project path>/.venv'
Add '-v' to see the detailed traceback
Expected behavior
The .venv volume is in fact empty, however pdm is looking for existence rather than empty and since the volume mount cannot be deleted, it fails.
Can _ensure_clean instead check that the directory is empty and be done with it?
dennispg
changed the title
VirtualenvCreateError: checking for .venv existence rather emptiness
VirtualenvCreateError: checking for .venv existence rather than emptiness
Sep 20, 2023
3a4> import os73a75,76> if location.is_dir() and not any(location.iterdir()):> return81c84,90< shutil.rmtree(location)---> self.project.core.ui.echo("Dennis code here")> with os.scandir(location) as entries:> for entry in entries:> if entry.is_dir() and not entry.is_symlink():> shutil.rmtree(entry.path)> else:> os.remove(entry.path)
Make sure you run commands with
-v
flag before pasting the output.Steps to reproduce
I am mounting a docker volume in my devcontainer at
<project path>/.venv
to try and cache the virtual environments between rebuilds, and then runningpdm venv create
in my project. I also havevenv.in_project
set totrue
inpdm.toml
.Actual behavior
[VirtualenvCreateError]: The location /<project path>/.venv is not empty, add --force to overwrite it.
Adding
--force
gives:Expected behavior
The
.venv
volume is in fact empty, however pdm is looking for existence rather than empty and since the volume mount cannot be deleted, it fails.Can
_ensure_clean
instead check that the directory is empty and be done with it?https://github.com/pdm-project/pdm/blob/main/src/pdm/cli/commands/venv/backends.py#L81
Adding this seems to resolve it for me:
I can make a pull request to that effect if its deemed appropriate?
Environment Information
The text was updated successfully, but these errors were encountered: