postCreateCommand cannot find executables that should be in PATH
What happened?
In a dev container that uses the pre-commit dev container feature to install pre-commit, I have a "postCreateCommand": "pre-commit install". It fails to run:
16:26:53 info Run command : pre-commit install...
16:26:53 warn bash: line 1: pre-commit: command not found
16:26:53 info lifecycle hooks: failed to run: pre-commit install, error: exit status 127
16:26:53 info devcontainer up: run agent command: Process exited with status 1
16:26:53 error Try using the --debug flag to see a more verbose output
16:26:53 fatal run agent command: Process exited with status 1
What did you expect to happen instead?
pre-commit should be in PATH in the dev container context: it is installed by the feature.
How can we reproduce the bug? (as minimally and precisely as possible)
This repo reproduces the issue with devpod up . --recreate:
https://github.com/eguiraud/devpod-postcreatecommand-issue
The devcontiner.json:
{
"build": {
"dockerfile": "Dockerfile",
"context": ".."
},
"remoteEnv": {
// set variable to the local user
// Needed to upload to the db as the correct user
"OS_USER": "${localEnv:USER}"
},
"features": {
"ghcr.io/prulloac/devcontainer-features/pre-commit:1": {},
},
"remoteUser": "devuser",
// install pre-commit Git hooks automatically after build
"postCreateCommand": "pre-commit install",
}
Local Environment:
- DevPod Version: v0.5.19
- Operating System: linux
- ARCH of the OS: AMD64
DevPod Provider:
- Local/remote provider: docker | ssh
Anything else we need to know?
Works with VSCode.
Related (closed) issue: https://github.com/loft-sh/devpod/issues/1084
Hi @eguiraud, thanks for reporting this issue. We'll look into it 👍
@eguiraud could you please try again and add the --debug flag and paste the entire logs? Also how did you set up the remote user devuser? Also can you post your Dockerfile? When I tried your example I got an error about the user not being found. When I created it using the ghcr.io/devcontainers/features/common-utils feature layer with username: devuser everything worked for me
i.e.
{
"build": {
"dockerfile": "Dockerfile",
"context": ".."
},
"remoteEnv": {
"TEST": "TEST",
"OS_USER": "${localEnv:USER}"
},
"features": {
"ghcr.io/devcontainers/features/common-utils:1": {
"installZsh": true,
"configureZshAsDefaultShell": true,
"installOhMyZsh": true,
"installOhMyZshConfig": true,
"upgradePackages": true,
"username": "devuser"
},
"ghcr.io/prulloac/devcontainer-features/pre-commit:1": {}
},
"remoteUser": "devuser",
"postCreateCommand": "pre-commit install"
}
This issue is stale because it has been open for 60 days with no activity.
This issue was closed because it has been inactive for 30 days since being marked as stale.