From 3f73414514d8414cf80bf340e8245793d0d9bed5 Mon Sep 17 00:00:00 2001 From: Som Date: Sat, 22 Aug 2026 06:56:43 +0000 Subject: [PATCH 1/2] fix: implement documented install-dir override chain OPENCODE_INSTALL_DIR > XDG_BIN_DIR > $HOME/bin > $HOME/.opencode/bin, matching README.md's Installation Directory section. The install script previously hardcoded $HOME/.opencode/bin and ignored both env vars entirely. Closes #43772 --- install | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/install b/install index b0716d532082..3656f4fdb515 100755 --- a/install +++ b/install @@ -65,7 +65,15 @@ while [[ $# -gt 0 ]]; do esac done -INSTALL_DIR=$HOME/.opencode/bin +if [ -n "${OPENCODE_INSTALL_DIR:-}" ]; then + INSTALL_DIR=$OPENCODE_INSTALL_DIR +elif [ -n "${XDG_BIN_DIR:-}" ]; then + INSTALL_DIR=$XDG_BIN_DIR +elif mkdir -p "$HOME/bin" 2>/dev/null; then + INSTALL_DIR=$HOME/bin +else + INSTALL_DIR=$HOME/.opencode/bin +fi mkdir -p "$INSTALL_DIR" # If --binary is provided, skip all download/detection logic From b96080aa17c165438fb970a370e1350051bb87df Mon Sep 17 00:00:00 2001 From: Som Date: Sun, 23 Aug 2026 17:14:37 +0000 Subject: [PATCH 2/2] fix: preserve existing install location across upgrades Checking OPENCODE_INSTALL_DIR/XDG_BIN_DIR before the new $HOME/bin tier could silently move a user's install: someone with an existing $HOME/.opencode/bin install and no env vars set would get a fresh binary in $HOME/bin while their PATH still pointed at the old location. Now an existing $HOME/.opencode/bin/opencode keeps installing there unless an env var explicitly says otherwise. Also re-indents the block to 2-space to match the rest of the file. Addresses review feedback on PR #44079. --- install | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/install b/install index 3656f4fdb515..0fbcf16b6147 100755 --- a/install +++ b/install @@ -66,13 +66,17 @@ while [[ $# -gt 0 ]]; do done if [ -n "${OPENCODE_INSTALL_DIR:-}" ]; then - INSTALL_DIR=$OPENCODE_INSTALL_DIR + INSTALL_DIR=$OPENCODE_INSTALL_DIR elif [ -n "${XDG_BIN_DIR:-}" ]; then - INSTALL_DIR=$XDG_BIN_DIR + INSTALL_DIR=$XDG_BIN_DIR +elif [ -x "$HOME/.opencode/bin/opencode" ]; then + # Keep upgrading in place instead of silently moving an existing + # install to the newer $HOME/bin tier below. + INSTALL_DIR=$HOME/.opencode/bin elif mkdir -p "$HOME/bin" 2>/dev/null; then - INSTALL_DIR=$HOME/bin + INSTALL_DIR=$HOME/bin else - INSTALL_DIR=$HOME/.opencode/bin + INSTALL_DIR=$HOME/.opencode/bin fi mkdir -p "$INSTALL_DIR"