[PR #11358] fix: respect install directory priority as documented in README #13755

Open
opened 2026-02-16 18:18:35 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/anomalyco/opencode/pull/11358

State: open
Merged: No


Summary

Resubmission of #6993 (accidentally deleted fork).

Fixes the install script to respect the installation directory priority order as documented in the README.

Problem

The install script was hardcoding INSTALL_DIR=$HOME/.opencode/bin on line 68-69, completely ignoring the environment variables documented in the README:

  1. $OPENCODE_INSTALL_DIR - Custom installation directory
  2. $XDG_BIN_DIR - XDG Base Directory Specification compliant path
  3. $HOME/bin - Standard user binary directory (if exists or can be created)
  4. $HOME/.opencode/bin - Default fallback

Solution

This PR implements the documented priority order with proper validation:

  • Checks $OPENCODE_INSTALL_DIR first (highest priority)
  • Falls back to $XDG_BIN_DIR if not set
  • Falls back to $HOME/bin if it exists or can be created
  • Falls back to $HOME/.opencode/bin as final default

Additional Improvements

  • Directory creation validation: Ensures the installation directory can be created, with clear error messages if it fails
  • Write permission check: Verifies the directory is writable before proceeding with installation
  • Better error messages: Informs users to use OPENCODE_INSTALL_DIR if default paths fail

Testing

  • Verified bash syntax is valid (bash -n install)
  • Tested priority logic with unit tests
  • Tested with --help flag to ensure no regressions
  • All tests pass ✓

Impact

Users can now properly customize their installation directory as documented, and will receive clear error messages if there are permission issues.

Fixes #7675

**Original Pull Request:** https://github.com/anomalyco/opencode/pull/11358 **State:** open **Merged:** No --- ## Summary Resubmission of #6993 (accidentally deleted fork). Fixes the install script to respect the installation directory priority order as documented in the README. ## Problem The install script was hardcoding `INSTALL_DIR=$HOME/.opencode/bin` on line 68-69, completely ignoring the environment variables documented in the README: 1. `$OPENCODE_INSTALL_DIR` - Custom installation directory 2. `$XDG_BIN_DIR` - XDG Base Directory Specification compliant path 3. `$HOME/bin` - Standard user binary directory (if exists or can be created) 4. `$HOME/.opencode/bin` - Default fallback ## Solution This PR implements the documented priority order with proper validation: - Checks `$OPENCODE_INSTALL_DIR` first (highest priority) - Falls back to `$XDG_BIN_DIR` if not set - Falls back to `$HOME/bin` if it exists or can be created - Falls back to `$HOME/.opencode/bin` as final default ## Additional Improvements - **Directory creation validation**: Ensures the installation directory can be created, with clear error messages if it fails - **Write permission check**: Verifies the directory is writable before proceeding with installation - **Better error messages**: Informs users to use `OPENCODE_INSTALL_DIR` if default paths fail ## Testing - Verified bash syntax is valid (`bash -n install`) - Tested priority logic with unit tests - Tested with `--help` flag to ensure no regressions - All tests pass ✓ ## Impact Users can now properly customize their installation directory as documented, and will receive clear error messages if there are permission issues. Fixes #7675
yindo added the pull-request label 2026-02-16 18:18:35 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#13755