From 8c130bcb5a1c7822448ee18964cd51583ca3c4b2 Mon Sep 17 00:00:00 2001 From: Meghea Iulian Date: Fri, 27 Mar 2026 19:55:07 +0200 Subject: [PATCH] fix(opencode): pass VERSION to bash instead of curl in install pipe (#815) ## Summary - Fix version pinning bug in the OpenCode install script (`registry/coder-labs/modules/opencode/scripts/install.sh`, line 42) **Bug:** The install command was: ```bash VERSION=$ARG_OPENCODE_VERSION curl -fsSL https://opencode.ai/install | bash ``` `VERSION` was set as an environment variable prefix to `curl` (the left side of the pipe), so the `bash` process on the right side of the pipe never received it. In a shell pipeline, each command runs in its own subprocess, so env var prefixes only apply to the immediately following command. This caused the installer script to always install the latest version instead of the pinned version specified by the user. **Fix:** Move `VERSION` to prefix `bash` instead of `curl`: ```bash curl -fsSL https://opencode.ai/install | VERSION=$ARG_OPENCODE_VERSION bash ``` Now the `VERSION` variable is correctly available to the install script executed by `bash`. ## Test plan - [x] Set `opencode_version` to a specific version (e.g., `0.1.0`) and verify that version is installed instead of latest - [x] Set `opencode_version` to `latest` and verify the latest version is still installed (this code path is unchanged) - [x] Verify `opencode --version` output matches the requested version after install --------- Co-authored-by: 35C4n0r <70096901+35C4n0r@users.noreply.github.com> --- registry/coder-labs/modules/opencode/README.md | 6 +++--- registry/coder-labs/modules/opencode/scripts/install.sh | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/registry/coder-labs/modules/opencode/README.md b/registry/coder-labs/modules/opencode/README.md index 711ad522..2eb6baf7 100644 --- a/registry/coder-labs/modules/opencode/README.md +++ b/registry/coder-labs/modules/opencode/README.md @@ -13,7 +13,7 @@ Run [OpenCode](https://opencode.ai) AI coding assistant in your workspace for in ```tf module "opencode" { source = "registry.coder.com/coder-labs/opencode/coder" - version = "0.1.1" + version = "0.1.2" agent_id = coder_agent.main.id workdir = "/home/coder/project" } @@ -34,7 +34,7 @@ resource "coder_ai_task" "task" { module "opencode" { source = "registry.coder.com/coder-labs/opencode/coder" - version = "0.1.1" + version = "0.1.2" agent_id = coder_agent.main.id workdir = "/home/coder/project" @@ -89,7 +89,7 @@ Run OpenCode as a command-line tool without web interface or task reporting: ```tf module "opencode" { source = "registry.coder.com/coder-labs/opencode/coder" - version = "0.1.1" + version = "0.1.2" agent_id = coder_agent.main.id workdir = "/home/coder" report_tasks = false diff --git a/registry/coder-labs/modules/opencode/scripts/install.sh b/registry/coder-labs/modules/opencode/scripts/install.sh index 6d553108..473e5ac4 100755 --- a/registry/coder-labs/modules/opencode/scripts/install.sh +++ b/registry/coder-labs/modules/opencode/scripts/install.sh @@ -39,7 +39,7 @@ install_opencode() { if [ "$ARG_OPENCODE_VERSION" = "latest" ]; then curl -fsSL https://opencode.ai/install | bash else - VERSION=$ARG_OPENCODE_VERSION curl -fsSL https://opencode.ai/install | bash + curl -fsSL https://opencode.ai/install | VERSION="${ARG_OPENCODE_VERSION}" bash fi export PATH=/home/coder/.opencode/bin:$PATH printf "Opencode location: %s\n" "$(which opencode)"