From 1f6d27ab919bab42a4ad1c3ef3b4b9000b17b093 Mon Sep 17 00:00:00 2001 From: virskl Date: Mon, 16 Nov 2026 09:40:21 +0100 Subject: [PATCH 1/2] The dev container's Python tools in .venv-devcontainer The workspace is the host's folder, and a .venv that uv made on the host names the host's paths in its scripts. uv takes it as current, and in the container the tools failed to start: "Failed to spawn: clang-tidy", as in AtmegaTimer, whose .venv came from the host. UV_PROJECT_ENVIRONMENT gives the container an environment of its own, relative, so that each worktree keeps its own too. --- template/.devcontainer/Dockerfile | 7 ++++--- template/.devcontainer/README.md.jinja | 8 +++++++- .../.devcontainer/shared/devcontainer-feature.json.jinja | 9 +++++++-- template/.gitignore | 4 +++- template/Makefile | 4 ++-- template/tools/arduino_lint.sh | 8 ++++---- 6 files changed, 27 insertions(+), 13 deletions(-) diff --git a/template/.devcontainer/Dockerfile b/template/.devcontainer/Dockerfile index 6508a85..ca4359d 100644 --- a/template/.devcontainer/Dockerfile +++ b/template/.devcontainer/Dockerfile @@ -86,9 +86,10 @@ RUN ARCH="$(dpkg --print-architecture)" && \ rm /tmp/gh.deb # uv makes the environment of the Python tools from pyproject.toml and uv.lock, in the -# workspace's .venv, on the first `uv run` or with `uv sync --frozen` when the container is -# created: clang-format, clang-tidy, cpplint, gcovr, shellcheck, actionlint, ruff and copier, -# at the versions CI checks with. This ARG is the one place uv's version is written: +# workspace's .venv-devcontainer (UV_PROJECT_ENVIRONMENT in shared/devcontainer-feature.json), +# on the first `uv run` or with `uv sync --frozen` when the container is created: clang-format, +# clang-tidy, cpplint, gcovr, shellcheck, actionlint, ruff and copier, at the versions CI checks +# with. This ARG is the one place uv's version is written: # .github/actions/uv-sync reads it for CI. Pinned with its published checksum, as the tools # above. ARG UV_VERSION=0.12.0 diff --git a/template/.devcontainer/README.md.jinja b/template/.devcontainer/README.md.jinja index fdef510..0b1dced 100644 --- a/template/.devcontainer/README.md.jinja +++ b/template/.devcontainer/README.md.jinja @@ -23,7 +23,7 @@ another container is lost with that container. {%- endif %} | `g++`, `gdb` (from the base image) | the tests on the host, and what `tools/project.sh` prepares | | `cmake`, `ninja`, GoogleTest | the tests on the host: `cmake --workflow --preset default` | -| `uv` | the Python tools that `uv.lock` pins, in `.venv`: clang-format, clang-tidy, cpplint, gcovr, shellcheck, actionlint, ruff, copier | +| `uv` | the Python tools that `uv.lock` pins, in `.venv-devcontainer`: clang-format, clang-tidy, cpplint, gcovr, shellcheck, actionlint, ruff, copier | | `clang` | the tests a second time, by another compiler: `make clang` | | `clangd` | IntelliSense, see below | | LLVM's headers, in `/opt/llvm-23/include` | the checks of our own, `house-*`, a module that `tools/lib/tidy_module.sh` builds and `tools/tidy.sh` loads | @@ -67,6 +67,12 @@ clangd does not load the module of the checks of our own, `house-*`: those findi `make tidy` alone. The module's own sources in `tools/lib/tidy_module/` are read against LLVM's headers, without the checks of `.clang-tidy`, which are the library's rules and not LLVM's. +uv makes the Python tools' environment in `.venv-devcontainer`, which `UV_PROJECT_ENVIRONMENT` in +`shared/devcontainer-feature.json` names, not in `.venv`: the workspace is the host's folder, and a +`.venv` that uv made on the host names the host's paths in its scripts. uv takes such an +environment as current, and the tools fail to start (`Failed to spawn: clang-tidy`). A `.venv` in +the workspace is the host's, which the container leaves alone. + clangd comes from PyPI at 22.1.1, the newest there, one behind the clang-tidy 23 of CI, which stays the measure. The package wraps the binary in a Python script whose interpreter would lie in root's home; `/usr/local/bin/clangd` links to the binary itself. diff --git a/template/.devcontainer/shared/devcontainer-feature.json.jinja b/template/.devcontainer/shared/devcontainer-feature.json.jinja index 7145ae2..a29dbfe 100644 --- a/template/.devcontainer/shared/devcontainer-feature.json.jinja +++ b/template/.devcontainer/shared/devcontainer-feature.json.jinja @@ -38,11 +38,16 @@ } } }, - // uv's cache is a volume of its own, another file system than the workspace's .venv, so it - // copies rather than failing to link and saying so on every sync. + // uv's cache is a volume of its own, another file system than the project's environment, so + // it copies rather than failing to link and saying so on every sync. "containerEnv": { "GH_HOST": "github.com", "UV_LINK_MODE": "copy", + // The environment of the Python tools in .venv-devcontainer, not in .venv: the workspace + // is the host's folder, and a .venv that uv made on the host names the host's paths in + // its scripts, which the container does not have; uv takes it as current and the tools + // fail to start. Relative, so that each worktree has its own. + "UV_PROJECT_ENVIRONMENT": ".venv-devcontainer", // Claude Code keeps .claude.json beside ~/.claude rather than in it; this puts both // into the volume below, so that a rebuild keeps the login and the settings. "CLAUDE_CONFIG_DIR": "/home/vscode/.claude", diff --git a/template/.gitignore b/template/.gitignore index c31d22c..ed6ea90 100644 --- a/template/.gitignore +++ b/template/.gitignore @@ -1,6 +1,8 @@ build/ -# The Python tools' environment, which uv makes from uv.lock. +# The Python tools' environment, which uv makes from uv.lock: on the host, and in the dev container, +# where UV_PROJECT_ENVIRONMENT names its own. .venv/ +.venv-devcontainer/ # What PlatformIO keeps beside a platformio.ini, its libraries among it; the builds go to build/. .pio/ # A dev container variant of the site, such as one on an internal base image, see diff --git a/template/Makefile b/template/Makefile index 3b16928..43dd2a1 100644 --- a/template/Makefile +++ b/template/Makefile @@ -120,8 +120,8 @@ docs: ## The reference from the Doxygen blocks, failing on a gap tools/docs.sh # What git has, tracked or new, copied into build/arduino-lint/: the Library Manager sees -# the repository, not the working tree with its build/ and .venv, whose links arduino-lint would -# report. +# the repository, not the working tree with its build/ and uv's environments, whose links +# arduino-lint would report. arduino-lint: ## The rules of the Arduino Library Manager tools/arduino_lint.sh diff --git a/template/tools/arduino_lint.sh b/template/tools/arduino_lint.sh index ee476c4..5a305e1 100755 --- a/template/tools/arduino_lint.sh +++ b/template/tools/arduino_lint.sh @@ -5,10 +5,10 @@ # # Checks the library against the rules of the Arduino Library Manager, as arduino-lint does in # CI. Not the working tree: the Library Manager sees the repository, and the working tree has -# build/ and .venv beside it, whose links arduino-lint reports as a library's. So what git has, -# tracked or new and not ignored, is copied into a folder of the library's name in build/, and -# that is checked. CI runs it as a developer does, through `make arduino-lint`, with arduino-lint -# installed by the action arduino-lint-setup at the dev container's version. +# build/ and uv's environments beside it, whose links arduino-lint reports as a library's. So +# what git has, tracked or new and not ignored, is copied into a folder of the library's name in +# build/, and that is checked. CI runs it as a developer does, through `make arduino-lint`, with +# arduino-lint installed by the action arduino-lint-setup at the dev container's version. set -euo pipefail From 5b25036364ba212bc96e9ff7df795ad174a49333 Mon Sep 17 00:00:00 2001 From: virskl Date: Mon, 16 Nov 2026 09:40:21 +0100 Subject: [PATCH 2/2] CHANGELOG: the dev container's Python tools in .venv-devcontainer --- CHANGELOG.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index aa67223..e3cd923 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,18 @@ What changed in each version of the template, and what a project has to do when `copier update` brings it. +## Unreleased + +- **The dev container keeps the Python tools in `.venv-devcontainer`:** the workspace is the + host's folder, and a `.venv` that uv made on the host names the host's paths in its scripts. + uv took it as current, and in the container clang-tidy, cpplint, copier and the others failed + to start, `make tidy` with `Failed to spawn: clang-tidy`; found in AtmegaTimer, whose `.venv` + came from the host. `UV_PROJECT_ENVIRONMENT` gives the container an environment of its own, + relative, so that each worktree has its own as before. `.gitignore` ignores it. + +On the update: rebuild the dev container, whose `postCreateCommand` makes `.venv-devcontainer`. A +`.venv` the container made before can go; one of the host stays the host's. + ## v0.11.2 A class may befriend its own CRTP base (C-12), so that `house-no-friend` passes a `friend Base;`