Skip to content

Devcontainer fixes#117

Merged
zendern merged 6 commits intomainfrom
devcontainer-fixes
Feb 3, 2026
Merged

Devcontainer fixes#117
zendern merged 6 commits intomainfrom
devcontainer-fixes

Conversation

@zendern
Copy link
Contributor

@zendern zendern commented Feb 3, 2026

Why is this change necessary?

Devcontainer and technically the codespaces have been failing during creation.

Codespaces just fails, shows error and moves on. Devcontainers have more issues and in some cases will not build at all and generally fail with one of 2 errors below.

git-lfs details

When git-lfs tries to install its hook (added in v.1.2.5 of the feature) since pre-commit is already there. This is the "soft failure" where it reports but does not cause it to stop anything in codespaces. But in devcontainers it does fail and stops any future setup from this point on.

Note

I did try to reorder where pre-commit install was called but that didn't seem to help. This seemed like a reasonable solution since we are not using git-lfs today and if we do at some point we can dig in then.

2026-01-27 20:58:02.251Z: Stop: Run: /bin/sh -c sh .devcontainer/initialize-command.sh
2026-01-27 20:58:02.254Z: 
2026-01-27 20:58:02.388Z: $ docker compose -f /var/lib/docker/codespacemount/workspace/sensor-dashboard/.devcontainer/docker-compose.yml -f /var/lib/docker/codespacemount/.persistedshare/docker-compose.codespaces.yml --profile * config
2026-01-27 20:58:02.550Z: Stop: Run: docker compose -f /var/lib/docker/codespacemount/workspace/sensor-dashboard/.devcontainer/docker-compose.yml -f /var/lib/docker/codespacemount/.persistedshare/docker-compose.codespaces.yml --profile * config
2026-01-27 20:58:02.763Z: Running the postCreateCommand from Feature 'ghcr.io/devcontainers/features/git-lfs:1'...

2026-01-27 20:58:02.766Z: /usr/local/share/pull-git-lfs-artifacts.sh
2026-01-27 20:58:02.872Z: Fetching git lfs artifacts...
2026-01-27 20:58:09.401Z: Hook already exists: post-checkout
2026-01-27 20:58:09.402Z: 
 #!/usr/bin/env bash
 # File generated by pre-commit: https://pre-commit.com
 # ID: 138fd403232d2ddd5efb44317e38bf03
 
 # start templated
 INSTALL_PYTHON=/home/codespace/.local/share/uv/tools/pre-commit/bin/python
 ARGS=(hook-impl --config=.pre-commit-config.yaml --hook-type=post-checkout)
 # end templated
 
 HERE="$(cd "$(dirname "$0")" && pwd)"
 ARGS+=(--hook-dir "$HERE" -- "$@")
 
 if [ -x "$INSTALL_PYTHON" ]; then
 exec "$INSTALL_PYTHON" -mpre_commit "${ARGS[@]}"
 elif command -v pre-commit > /dev/null; then
 exec pre-commit "${ARGS[@]}"
 else
 echo '`pre-commit` not found.  Did you forget to activate your virtualenv?' 1>&2
 exit 1
 fi

To resolve this, either:
  1: run `git lfs update --manual` for instructions on how to merge hooks.
  2: run `git lfs update --force` to overwrite your hook.
2026-01-27 20:58:09.417Z: postCreateCommand from Feature 'ghcr.io/devcontainers/features/git-lfs:1' failed with exit code 2. Skipping any further user-provided commands.

volume mount issues

Below you can see that these fail when spinning up a brand new devcontainer. Pretty sure this only impacts local devcontainers since codespaces likely are not using the volume mounts in the same way. This is a hard failure for local devcontainers.

[2026-02-02T23:03:31.494Z] + python .devcontainer/manual-setup-deps.py --optionally-check-lock
[2026-02-02T23:03:31.867Z]  EACCES  EACCES: permission denied, mkdir '/workspaces/sensor-monitor/.pnpm-store/v10'

pnpm: EACCES: permission denied, mkdir '/workspaces/sensor-monitor/.pnpm-store/v10'
    at async Object.mkdir (node:internal/fs/promises:861:10)
    at async createNewStoreController (/usr/local/share/nvm/versions/node/v24.11.1/lib/node_modules/pnpm/dist/pnpm.cjs:110272:7)
    at async installDeps (/usr/local/share/nvm/versions/node/v24.11.1/lib/node_modules/pnpm/dist/pnpm.cjs:161803:21)
    at async /usr/local/share/nvm/versions/node/v24.11.1/lib/node_modules/pnpm/dist/pnpm.cjs:195292:23
    at async main (/usr/local/share/nvm/versions/node/v24.11.1/lib/node_modules/pnpm/dist/pnpm.cjs:195250:34)
    at async runPnpm (/usr/local/share/nvm/versions/node/v24.11.1/lib/node_modules/pnpm/dist/pnpm.cjs:195517:5)
    at async /usr/local/share/nvm/versions/node/v24.11.1/lib/node_modules/pnpm/dist/pnpm.cjs:195509:7
[2026-02-02T23:03:31.889Z] Traceback (most recent call last):
[2026-02-02T23:03:31.892Z]   File "/workspaces/sensor-monitor/.devcontainer/manual-setup-deps.py", line 164, in <module>
    main()
    ~~~~^^
  File "/workspaces/sensor-monitor/.devcontainer/manual-setup-deps.py", line 145, in main
    _ = subprocess.run(
        pnpm_command,
        check=True,
    )
  File "/usr/local/python/3.13.9/lib/python3.13/subprocess.py", line 577, in run
    raise CalledProcessError(retcode, process.args,
                             output=stdout, stderr=stderr)
subprocess.CalledProcessError: Command '['pnpm', 'install', '--dir', '/workspaces/sensor-monitor/frontend', '--frozen-lockfile']' returned non-zero exit status 243.
[2026-02-02T23:03:31.910Z] Stop (61717 ms): Run in container:
[2026-02-02T23:03:31.910Z] onCreateCommand from devcontainer.json failed with exit code 1. Skipping any further user-provided commands.
[2026-02-02T23:03:31.913Z] Error: Command failed: /bin/sh -c sh .devcontainer/on-create-command.sh
[2026-02-02T23:03:31.913Z]     at E (/home/devcontainers/.vscode-remote-containers/dist/dev-containers-cli-0.437.0/dist/spec-node/devContainersSpecCLI.js:235:157)
[2026-02-02T23:03:31.913Z]     at async Promise.allSettled (index 0)
[2026-02-02T23:03:31.913Z]     at async b9 (/home/devcontainers/.vscode-remote-containers/dist/dev-containers-cli-0.437.0/dist/spec-node/devContainersSpecCLI.js:237:119)
[2026-02-02T23:03:31.913Z]     at async ND (/home/devcontainers/.vscode-remote-containers/dist/dev-containers-cli-0.437.0/dist/spec-node/devContainersSpecCLI.js:226:4668)
[2026-02-02T23:03:31.913Z]     at async RD (/home/devcontainers/.vscode-remote-containers/dist/dev-containers-cli-0.437.0/dist/spec-node/devContainersSpecCLI.js:226:4013)
[2026-02-02T23:03:31.913Z]     at async MD (/home/devcontainers/.vscode-remote-containers/dist/dev-containers-cli-0.437.0/dist/spec-node/devContainersSpecCLI.js:226:3020)
[2026-02-02T23:03:31.914Z]     at async G7 (/home/devcontainers/.vscode-remote-containers/dist/dev-containers-cli-0.437.0/dist/spec-node/devContainersSpecCLI.js:668:2746)
[2026-02-02T23:03:31.914Z]     at async b7 (/home/devcontainers/.vscode-remote-containers/dist/dev-containers-cli-0.437.0/dist/spec-node/devContainersSpecCLI.js:667:8546)
[2026-02-02T23:03:31.914Z]     at async /home/devcontainers/.vscode-remote-containers/dist/dev-containers-cli-0.437.0/dist/spec-node/devContainersSpecCLI.js:484:1188
[2026-02-02T23:03:31.919Z] Stop (62996 ms): Run in Host: /home/devcontainers/.vscode-remote-containers/bin/c9d77990917f3102ada88be140d28b038d1dd7c7/node /home/devcontainers/.vscode-remote-containers/dist/dev-containers-cli-0.437.0/dist/spec-node/devContainersSpecCLI.js run-user-commands --container-session-data-folder /tmp/devcontainers-cc18fb53-7a3c-4771-95e9-d025cc3b66ed1770072981455 --workspace-folder /home/devcontainers/dev/projects/sensor-monitor --id-label devcontainer.local_folder=\\wsl.localhost\Ubuntu-24.04\home\devcontainers\dev\projects\sensor-monitor --id-label devcontainer.config_file=/home/devcontainers/dev/projects/sensor-monitor/.devcontainer/devcontainer.json --container-id 9ac3cfa32556bd4ad87f58afd3baf7908bfe2fa8a32ffd9cbf8d976d98239ce7 --log-level debug --log-format json --config /home/devcontainers/dev/projects/sensor-monitor/.devcontainer/devcontainer.json --default-user-env-probe loginInteractiveShell --skip-non-blocking-commands true --prebuild false --stop-for-personalization true --remote-env REMOTE_CONTAINERS_IPC=/tmp/vscode-remote-containers-ipc-764ce6b9-f7cf-4ef9-b500-26dcf68a3fd5.sock --remote-env SSH_AUTH_SOCK=/tmp/vscode-ssh-auth-764ce6b9-f7cf-4ef9-b500-26dcf68a3fd5.sock --remote-env DISPLAY=:0 --remote-env REMOTE_CONTAINERS_DISPLAY_SOCK=/tmp/.X11-unix/X0 --remote-env REMOTE_CONTAINERS=true --mount-workspace-git-root --terminal-columns 278 --terminal-rows 31 --dotfiles-repository https://github.com/zendern/dotfiles --dotfiles-install-command install.sh --dotfiles-target-path ~/dotfiles
[2026-02-02T23:03:31.919Z] Exit code 1

How does this change address the issue?

For all docker mounts we are now pre-creating the dirs and updating the perms. And for git-lfs feature we have just disabled the install step for the git hook.

What side effects does this change have?

Working devcontainer build

How is this change tested?

Locally using sensor-monitor

Summary by CodeRabbit

Release Notes

  • Chores
    • Improved development container workspace configuration with enhanced directory structure and permissions management.
    • Added Git LFS support to the development environment for managing large files.
    • Introduced pnpm store and frontend node_modules caching configuration for optimized development setup.

@zendern zendern requested a review from ejfine February 3, 2026 01:46
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 3, 2026

📝 Walkthrough

Walkthrough

These changes update the development container configuration to support a full-stack monorepo setup with separate backend (Python venv) and frontend (Node.js/pnpm) workspace directories, and adds Git LFS support for the container environment.

Changes

Cohort / File(s) Summary
Backend & Frontend Environment Setup
template/.devcontainer/Dockerfile
Modified VENV_PATH to reference backend/.venv instead of root .venv. Added PNPM_STORE and FRONTEND_NODE_MODULES environment variables to support Node.js package management. Extended directory creation and permission handling to cover new frontend and pnpm paths.
Git LFS Feature
template/.devcontainer/devcontainer.json.jinja
Added git-lfs devcontainer feature (v1.2.5) with autoPull disabled.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 inconclusive)
Check name Status Explanation Resolution
Title check ❓ Inconclusive The title 'Devcontainer fixes' is vague and generic, lacking specificity about which devcontainer issues are being addressed. Consider a more descriptive title that specifies the main fix, such as 'Fix devcontainer build failures from git-lfs hooks and volume permissions' or similar.
✅ Passed checks (2 passed)
Check name Status Explanation
Description check ✅ Passed The PR description comprehensively addresses all required template sections with detailed explanations of the problems, solutions, testing approach, and side effects.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@ejfine
Copy link
Contributor

ejfine commented Feb 3, 2026

probably want to merge #115 and then update this branch before you start using this in instantiated templates...I'm not sure exactly what will happen otherwise

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are you running your devcontainers inside WSL? maybe that explains some of the differences in behaviors we've observed. my files are on my regular windows hard drive. I know it's better to have them in the WSL "hard drive", but I haven't had a chance to figure that out yet

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes using WSL "hard drive"

"service": "devcontainer",
"workspaceFolder": "/workspaces/${localWorkspaceFolderBasename}",
"features": {{% endraw %}{% if is_child_of_copier_base_template is not defined %}{% raw %}
"ghcr.io/devcontainers/features/git-lfs:1.2.5": {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this be a change in the base template?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if you wanna just add a note to yourself, and not make the change now, that's fine. I just don't want to forget

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

probably worthwhile to put at that level too. Since figuring it out i haven't gone back and tried to use other non "python/nuxt project" based things as a devcontainer. So i wouldn't be surprised if its broken there.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

merged and updated this branch. :beg: for another approval please

Comment on lines +19 to +21
ENV VENV_PATH=/workspaces/${REPO_NAME}/backend/.venv
ENV PNPM_STORE=/workspaces/${REPO_NAME}/.pnpm-store
ENV FRONTEND_NODE_MODULES=/workspaces/${REPO_NAME}/frontend/node_modules
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we have several copier templates that have venv/node_modules that are not in the repo root. at some point (not saying now) we should probably move this into copier-base template and make a copier task in the sub-template that just adjusts the paths. the task could be defined in the copier.yaml.jinja-base in the base template, and just read from the envs.json that defines the paths for the different python/node environments in the template

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ejfine
ejfine previously approved these changes Feb 3, 2026
zendern added a commit to LabAutomationAndScreening/copier-base-template that referenced this pull request Feb 3, 2026
## Link to Issue or Message thread
See
LabAutomationAndScreening/copier-nuxt-python-intranet-app#117


 ## Why is this change necessary?
Propogating the devcontainers fix for failures to init git-lfs hook when
we already have pre-commit in place. This impacts both devcontainers and
codespaces.


 ## How does this change address the issue?
Explicitly adds the git-lfs feature (which is a transitive already) and
sets the "autoPull" property to false. This makes it so the hook wont be
installed. If we ever end up needing git-lfs we can figure out how to
make this and pre-commit play nicely together.

> [!NOTE]
> As stated in the other PR i did try to fiddle the pre-commit install
order and it did not help it kept failing out.


 ## What side effects does this change have?
Not git hook attempted to be setup for git-lfs so the container then
fully initializes since there are no failures.


 ## How is this change tested?
Locally spinning up devcontainer as well as using using it previously
with the fix in the python/nuxt template.



<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

* **Chores**
* Updated development container configuration to include Git LFS with
auto-pull disabled to prevent pre-commit hook interference during
development.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
@zendern zendern merged commit e007143 into main Feb 3, 2026
11 checks passed
@ejfine ejfine deleted the devcontainer-fixes branch February 20, 2026 17:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants