-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Closed
Description
Summary
The current OpenCode install script always installs the binary to $HOME/.opencode/bin, which does not respect common standards or user preferences for binary locations. Many modern Linux distributions and user environments prefer XDG-compliant directories or custom bin paths.
Request:
Enhance the installation script to support the following priority order for the installation path:
- Use
$OPENCODE_INSTALL_DIRif set - Else use
$XDG_BIN_DIRif set - Else use
$HOME/binif it exists (or can be created) - Else fallback to
$HOME/.opencode/bin
Motivation
- Standards compliance: The XDG Base Directory Specification is widely used and makes home directories more organized.
- User flexibility: Many users want to customize where their binaries go, either with
$HOME/binor with XDG variables. - Better PATH defaults: Modern distros and shells often include
$XDG_BIN_DIRor$HOME/bininPATHby default.
Current Behavior
The script sets:
INSTALL_DIR=$HOME/.opencode/binThis does not check for environment variables or user preferences.
Proposed Behavior
Update the install script to:
- Use
$OPENCODE_INSTALL_DIRif it is set - Else use
$XDG_BIN_DIRif it is set - Else use
$HOME/binif it exists or can be created - Else fallback to
$HOME/.opencode/bin
Example Implementation
if [ -n "${OPENCODE_INSTALL_DIR:-}" ]; then
INSTALL_DIR="$OPENCODE_INSTALL_DIR"
elif [ -n "${XDG_BIN_DIR:-}" ]; then
INSTALL_DIR="$XDG_BIN_DIR"
elif [ -d "$HOME/bin" ] || mkdir -p "$HOME/bin"; then
INSTALL_DIR="$HOME/bin"
else
INSTALL_DIR="$HOME/.opencode/bin"
fi- The script should also ensure that
INSTALL_DIRis added toPATHin the same way as currently, with relevant shell logic. - If the chosen
INSTALL_DIRis not present inPATH, the script should suggest or attempt to add it, as before.
Benefits
- More predictable and standards-compliant installations
- Minimal surprises for users who prefer or require custom bin locations
- Future-proofs the script for changing Linux desktop conventions
References
Additional Details
- Please document the new variables (
OPENCODE_INSTALL_DIR,XDG_BIN_DIR) in the README for clarity. - Consider echoing the chosen install location to the user at the end of the script.
- For bonus points, warn the user if the chosen path is not present in
PATH.
Thank You
This change would greatly improve install experience and compliance with modern Linux standards.
ejarmand
Metadata
Metadata
Assignees
Labels
No labels