Install script ignores OPENCODE_INSTALL_DIR environment variable #4657

Open
opened 2026-02-16 17:44:56 -05:00 by yindo · 3 comments
Owner

Originally created by @grgong on GitHub (Jan 10, 2026).

Originally assigned to: @thdxr on GitHub.

Description

The install script hardcodes installation to $HOME/.opencode/bin, ignoring documented environment variables like $OPENCODE_INSTALL_DIR and $XDG_BIN_DIR.

Expected priority: OPENCODE_INSTALL_DIRXDG_BIN_DIR$HOME/bin$HOME/.opencode/bin

Plugins

No response

OpenCode version

No response

Steps to reproduce

OPENCODE_INSTALL_DIR=$HOME/.local/bin curl -fsSL https://opencode.ai/install | bash

Screenshot and/or share link

No response

Operating System

Ubuntu22.04

Terminal

No response

Originally created by @grgong on GitHub (Jan 10, 2026). Originally assigned to: @thdxr on GitHub. ### Description The install script hardcodes installation to `$HOME/.opencode/bin`, ignoring documented environment variables like `$OPENCODE_INSTALL_DIR` and `$XDG_BIN_DIR`. Expected priority: `OPENCODE_INSTALL_DIR` → `XDG_BIN_DIR` → `$HOME/bin` → `$HOME/.opencode/bin` ### Plugins _No response_ ### OpenCode version _No response_ ### Steps to reproduce `OPENCODE_INSTALL_DIR=$HOME/.local/bin curl -fsSL https://opencode.ai/install | bash` ### Screenshot and/or share link _No response_ ### Operating System Ubuntu22.04 ### Terminal _No response_
yindo added the bug label 2026-02-16 17:44:56 -05:00
Author
Owner

@github-actions[bot] commented on GitHub (Jan 10, 2026):

This issue might be a duplicate of existing issues. Please check:

  • #3097: Wrong installation path - User reported that XDG_BIN_DIR environment variable is being ignored, same as this issue
  • #1124: Feature Request: Respect OPENCODE_INSTALL_DIR, XDG_BIN_DIR, $HOME/bin, and Fallback for Installation Path - This is the original feature request that documented the expected behavior
  • #3127: Cannot upgrade "seems to be managed by a package manager" - Related issue caused by the installation script not respecting custom install directories

Feel free to ignore if none of these address your specific case.

@github-actions[bot] commented on GitHub (Jan 10, 2026): This issue might be a duplicate of existing issues. Please check: - #3097: Wrong installation path - User reported that XDG_BIN_DIR environment variable is being ignored, same as this issue - #1124: Feature Request: Respect OPENCODE_INSTALL_DIR, XDG_BIN_DIR, $HOME/bin, and Fallback for Installation Path - This is the original feature request that documented the expected behavior - #3127: Cannot upgrade "seems to be managed by a package manager" - Related issue caused by the installation script not respecting custom install directories Feel free to ignore if none of these address your specific case.
Author
Owner

@neohe-imer commented on GitHub (Jan 10, 2026):

Put this where INSTALL_DIR=$HOME/.opencode/bin currently is

`# Choose install dir (priority: OPENCODE_INSTALL_DIR → XDG_BIN_DIR → $HOME/bin → $HOME/.opencode/bin)
choose_install_dir() {

1) explicit override

if -n "${OPENCODE_INSTALL_DIR:-}" ; then
echo "$OPENCODE_INSTALL_DIR"
return
fi

2) XDG override

if -n "${XDG_BIN_DIR:-}" ; then
echo "$XDG_BIN_DIR"
return
fi

3) standard ~/bin if it exists OR can be created

if -n "${HOME:-}" ; then
if -d "$HOME/bin" || mkdir -p "$HOME/bin" 2>/dev/null; then
echo "$HOME/bin"
return
fi
fi

4) fallback

echo "$HOME/.opencode/bin"
}

INSTALL_DIR="$(choose_install_dir)"
mkdir -p "$INSTALL_DIR"
`

If you are using Ubuntu test it with this

chmod +x install.sh

OPENCODE_INSTALL_DIR="$HOME/.local/bin" ./install.sh
command -v opencode
ls -l "$HOME/.local/bin/opencode"

@neohe-imer commented on GitHub (Jan 10, 2026): Put this where INSTALL_DIR=$HOME/.opencode/bin currently is `# Choose install dir (priority: OPENCODE_INSTALL_DIR → XDG_BIN_DIR → $HOME/bin → $HOME/.opencode/bin) choose_install_dir() { # 1) explicit override if [[ -n "${OPENCODE_INSTALL_DIR:-}" ]]; then echo "$OPENCODE_INSTALL_DIR" return fi # 2) XDG override if [[ -n "${XDG_BIN_DIR:-}" ]]; then echo "$XDG_BIN_DIR" return fi # 3) standard ~/bin if it exists OR can be created if [[ -n "${HOME:-}" ]]; then if [[ -d "$HOME/bin" ]] || mkdir -p "$HOME/bin" 2>/dev/null; then echo "$HOME/bin" return fi fi # 4) fallback echo "$HOME/.opencode/bin" } INSTALL_DIR="$(choose_install_dir)" mkdir -p "$INSTALL_DIR" ` If you are using Ubuntu test it with this chmod +x install.sh OPENCODE_INSTALL_DIR="$HOME/.local/bin" ./install.sh command -v opencode ls -l "$HOME/.local/bin/opencode"
Author
Owner

@eamonburns commented on GitHub (Jan 12, 2026):

A fix that worked for me while this is still broken:

  • Download install script:
    curl -fsSL https://opencode.ai/install > ~/install-opencode.sh
    
  • Open ~/install-opencode.sh and change the following line:
    # remove this line
    INSTALL_DIR="$HOME/.opencode/bin"
    # replace with
    INSTALL_DIR="$HOME/.opencode/bin" # Change this to change the install path
    
  • Run the install script:
    bash ~/install-opencode.sh
    
@eamonburns commented on GitHub (Jan 12, 2026): A fix that worked for me while this is still broken: - Download install script: ```sh curl -fsSL https://opencode.ai/install > ~/install-opencode.sh ``` - Open `~/install-opencode.sh` and change the following line: ```sh # remove this line INSTALL_DIR="$HOME/.opencode/bin" # replace with INSTALL_DIR="$HOME/.opencode/bin" # Change this to change the install path ``` - Run the install script: ```sh bash ~/install-opencode.sh ```
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#4657