-
Notifications
You must be signed in to change notification settings - Fork 39
Using a .devcontainer setup causes issues with volume mounts for .venv within the dev container. #40
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
Comments
I'm sorry I don't entirely follow the question. Did you read the documentation at https://docs.astral.sh/uv/guides/integration/docker/#developing-in-a-container |
Thank you for the quick reply. Yes, I read the documentation. The issue is, that when creating the .venv in the container as described above respectively using |
A sync both ways won't always work, e.g., the virtual environment references the Python interpreter and if it's not in the exact same place the virtual environment will broken.
You can use How are you confirming the virtual environment is not present? How are you testing detection of it; with VS Code? |
@zanieb thanks for the questions. It does not matter which way I use to create the venv in the container (uv sync, uv venv, ...) in the terminal respectively in the devcontainer.json, of course always in the root of the project where the pyproject.toml is. How are you confirming the virtual environment is not present?
How are you testing detection of it; with VS Code?
Trying your suggestion to explicit set the default path using |
@zanieb thank you again for the hint. It is caused by a permission issue. Just needed to add It is still strange that even without the permission the .venv was created. Since I could use it. Still the .venv folder was empty (probably due to permission restriction - Also to mention that permission for the folder should be set with the config (as it was): |
Interesting, I'm glad you figured it out! I'm happy to add something to the uv documentation about the required permissions, but might need a simple example to understand it fully. |
Let me see if I can provide a simple example. I will keep you updated |
@zanieb I just created a simple example to reproduce the error. I am not a 100% sure what causes the error. But it seems that anonymous mounts for the .venv causes permission issues.
Find the related simple example here: https://github.com/tiefenthaler/dev-container-uv-datascience/tree/venv-mount-issue-example |
I tried to define a dev container setup with vscode for development. The purpose is to define a template to use uv to develop python projects (source code layout) within a devcontainer with vs code alongside without using vs code. Therefore I want to define a dev container setup with a Docker.debug, docker-compose.yml and devcontainer.json file.
Issue:
The "new (in the container)" create .venv to reflect the container os does neither exists in the defined (standard) root folder of the project when creating it in the config of the devcontainer.json via the
"postCreateCommand": {"uv-sync--frozen--no-install-project": "uv sync --frozen --no-install-project"}
nor when using the terminal within the running containeruv sync --frozen --no-install-project
. The .venv file is excluded during build by using .dockerignore. The mount should enable volume bind for the project code on the one side and a separate mount of the container .venv should persist the .venv within the container.Find the setup in the git repo:
https://github.com/tiefenthaler/dev-container-uv-datascience/tree/venv-mount-issue
FYI: The repo also contains the use of docker for production, which all works perfekt.
Would be great for any information how to solve this issue.
The text was updated successfully, but these errors were encountered: