Skip to content

Fix devcontainer CLI PATH resolution for nvm environments - #6

Merged
marchingphoenix merged 1 commit into
mainfrom
claude/fix-devcontainer-node-HqUxc
Feb 13, 2026
Merged

Fix devcontainer CLI PATH resolution for nvm environments#6
marchingphoenix merged 1 commit into
mainfrom
claude/fix-devcontainer-node-HqUxc

Conversation

@marchingphoenix

Copy link
Copy Markdown
Owner

Summary

This PR fixes an issue where the devcontainer CLI fails to execute in environments where Node.js is managed by nvm. The problem occurs when VS Code is launched from the OS application launcher rather than a terminal, causing the nvm bin directory to not be on the PATH inherited by child processes.

Changes

  • PATH augmentation in executeCommand: When the devcontainer CLI path is an absolute path, its parent directory is now prepended to the PATH environment variable passed to child processes. This ensures that the devcontainer CLI (a #!/usr/bin/env node script) can find the correct Node.js binary in the same directory.
  • Test coverage: Added comprehensive tests to verify:
    • PATH is correctly augmented when devcontainerCliPath is an absolute path
    • PATH remains unchanged when devcontainerCliPath is a bare command name

Implementation Details

  • The fix extracts the binary directory from absolute paths using path.dirname() and prepends it to the existing PATH using path.delimiter
  • Only absolute paths trigger PATH modification; relative or bare commands are left unchanged
  • The environment object is passed to the exec() call to ensure the modified PATH is used by child processes

https://claude.ai/code/session_012wQn8VuzGxVXtDYbwmekUk

When the devcontainer CLI path is absolute (e.g. installed via nvm), its
#!/usr/bin/env node shebang requires node to be on PATH. VS Code child
processes often don't inherit nvm's PATH entries when launched from the
OS application launcher. Prepend the CLI binary's parent directory to
PATH in execCommand so sibling binaries like node are discoverable.

https://claude.ai/code/session_012wQn8VuzGxVXtDYbwmekUk
@marchingphoenix
marchingphoenix merged commit a2680ad into main Feb 13, 2026
4 checks passed
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