diff --git a/install b/install index b0716d532082..0fbcf16b6147 100755 --- a/install +++ b/install @@ -65,7 +65,19 @@ 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 [ -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 +else + INSTALL_DIR=$HOME/.opencode/bin +fi mkdir -p "$INSTALL_DIR" # If --binary is provided, skip all download/detection logic