diff --git a/registry/coder/modules/devcontainers-cli/README.md b/registry/coder/modules/devcontainers-cli/README.md index ed2a4cb17..9622cceb0 100644 --- a/registry/coder/modules/devcontainers-cli/README.md +++ b/registry/coder/modules/devcontainers-cli/README.md @@ -15,7 +15,7 @@ The devcontainers-cli module provides an easy way to install [`@devcontainers/cl ```tf module "devcontainers-cli" { source = "registry.coder.com/coder/devcontainers-cli/coder" - version = "1.0.31" + version = "1.0.32" agent_id = coder_agent.example.id } ``` diff --git a/registry/coder/modules/devcontainers-cli/main.test.ts b/registry/coder/modules/devcontainers-cli/main.test.ts index 6cfe4d04e..5a4d34e8e 100644 --- a/registry/coder/modules/devcontainers-cli/main.test.ts +++ b/registry/coder/modules/devcontainers-cli/main.test.ts @@ -45,6 +45,8 @@ const executeScriptInContainerWithPackageManager = async ( console.log(path); + await execContainer(id, [shell, "-c", "mkdir -p /tmp/coder-script-data"]); + const resp = await execContainer( id, [shell, "-c", instance.script], @@ -52,6 +54,8 @@ const executeScriptInContainerWithPackageManager = async ( "--env", "CODER_SCRIPT_BIN_DIR=/tmp/coder-script-data/bin", "--env", + "CODER_SCRIPT_DATA_DIR=/tmp/coder-script-data", + "--env", `PATH=${path}:/tmp/coder-script-data/bin`, ], ); diff --git a/registry/coder/modules/devcontainers-cli/run.sh b/registry/coder/modules/devcontainers-cli/run.sh old mode 100644 new mode 100755 index f7bf852c6..7be78616d --- a/registry/coder/modules/devcontainers-cli/run.sh +++ b/registry/coder/modules/devcontainers-cli/run.sh @@ -1,5 +1,11 @@ #!/usr/bin/env sh +# We want to cd into `$CODER_SCRIPT_DATA_DIR` as the current directory +# might contain a `package.json` with `packageManager` set to something +# other than the detected package manager. When this happens, it can +# cause the installation to fail. +cd "$CODER_SCRIPT_DATA_DIR" + # If @devcontainers/cli is already installed, we can skip if command -v devcontainer >/dev/null 2>&1; then echo "🥳 @devcontainers/cli is already installed into $(which devcontainer)!" @@ -34,7 +40,7 @@ install() { # so that the devcontainer command is available if [ -z "$PNPM_HOME" ]; then PNPM_HOME="$CODER_SCRIPT_BIN_DIR" - export M_HOME + export PNPM_HOME fi pnpm add -g @devcontainers/cli elif [ "$PACKAGE_MANAGER" = "yarn" ]; then