fix: update fallback user in remote_user_run function to use current user#60
fix: update fallback user in remote_user_run function to use current user#60darthrevan030 wants to merge 2 commits into
Conversation
FabianSchurig
left a comment
There was a problem hiding this comment.
Hi @stu-bell The PR makes sense and LGTM, could you merge this, please. Thanks!
|
@darthrevan030 maybe you want to bump the version of the feature so tah it does not overwrite/ collide with the existing published one? |
|
@FabianSchurig Done, bumped feature version to 1.0.1 and updated the version comment in util.sh too |
|
Hey @darthrevan030, I appreciate your work on this 🙌 Can you share a minimal reproducible example that causes the failure? For example, the following works fine for me, I'm able to build, shell in and launch claude without error: The first username is Please could you let me know:
Your suggested fix may well be the answer, but I want to understand why you're getting the error and I'm not before merging. Thanks! |
|
Hey @stu-bell , here is the minimal reproducible example and the logs you requested. Environment: MRE {
"name": "Node/TS",
"image": "mcr.microsoft.com/devcontainers/typescript-node:24",
"features": {
"ghcr.io/stu-bell/devcontainer-features/claude-code:0": {}
}
}Build Log Output: Why it works for you but fails for me: On my setup (and likely others using Windows/WSL Dev Container CLI), Falling back to Let me know if you need me to test anything else! Happy to share a full copy of the build logs if you need them! |
Fix: fall back to current user when UID 1000 does not exist
Problem:
When using this feature with standard Microsoft devcontainer base images (e.g. mcr.microsoft.com/devcontainers/typescript-node, python, go, cpp), the build fails with:
su: user vscode does not exist or the user entry does not contain all the required fields.This happens because devcontainer features run during the Docker build phase, but the
vscodeuser (UID 1000) is only created at container startup. Soid -un 1000fails and falls back to the hardcoded string"vscode", which doesn't exist in/etc/passwdat build time.Fix
In
util.sh, change the fallback inremote_user_runfrom:sh_REMOTE_USER="$(id -un 1000 2>/dev/null || echo "vscode")" # vscode fallbackto:
sh_REMOTE_USER="$(id -un 1000 2>/dev/null || id -un)" # fallback to current userid -unreturns whoever is actually executing the script (root during build), which is guaranteed to exist. Claude Code's install script handles installing to the correct home directory regardless.