devpod icon indicating copy to clipboard operation
devpod copied to clipboard

postCreateCommand cannot find executables that should be in PATH

Open eguiraud opened this issue 1 year ago • 1 comments

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

eguiraud avatar Aug 27 '24 22:08 eguiraud

Hi @eguiraud, thanks for reporting this issue. We'll look into it 👍

pascalbreuninger avatar Aug 31 '24 10:08 pascalbreuninger

@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"
}

bkneis avatar Oct 11 '24 07:10 bkneis

This issue is stale because it has been open for 60 days with no activity.

github-actions[bot] avatar Dec 17 '24 02:12 github-actions[bot]

This issue was closed because it has been inactive for 30 days since being marked as stale.

github-actions[bot] avatar Jan 17 '25 01:01 github-actions[bot]