[PR #6498] fix: improve PATH handling in install script #11934

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

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

State: open
Merged: No


Summary

The current installer has issues with adding multiple PATH entries in shell configs in many scenarios and does not follow best practices. After much consideration this enhancement is the least invasive "first step" to a much more standard and robust installer.

This update standardizes the install script's PATH handling to prefer standard conventions and simple checks to avoid duplicate entries. There are many more improvements that can be made but this change is as minimal and safe as possible to solve the immediate problem.

Changes

  • Check if opencode already exists in user PATH before modifying shell configs
  • Prefer symlinking to ~/.local/bin when available (standard user bin, often already in PATH)
  • Consolidate shell case statements (zsh|bash|ash|sh)
  • Add warnings for alternate opencode installations (symlinks pointing elsewhere, custom binaries)

Future Improvements

The following best practices would further improve the install experience and avoid "binary in use" issues during upgrades:

  • Migrate INSTALL_DIR from ~/.opencode/bin to ~/.local/share/opencode/
  • Install binary to $INSTALL_DIR/versions/$VERSION
  • Symlink ~/.local/bin/opencode to versioned binary
**Original Pull Request:** https://github.com/anomalyco/opencode/pull/6498 **State:** open **Merged:** No --- ## Summary The current installer has issues with adding multiple PATH entries in shell configs in many scenarios and does not follow best practices. After much consideration this enhancement is the least invasive "first step" to a much more standard and robust installer. This update standardizes the install script's PATH handling to prefer standard conventions and simple checks to avoid duplicate entries. There are many more improvements that can be made but this change is as minimal and safe as possible to solve the immediate problem. ## Changes - Check if opencode already exists in user PATH before modifying shell configs - Prefer symlinking to `~/.local/bin` when available (standard user bin, often already in PATH) - Consolidate shell case statements (zsh|bash|ash|sh) - Add warnings for alternate opencode installations (symlinks pointing elsewhere, custom binaries) ## Future Improvements The following best practices would further improve the install experience and avoid "binary in use" issues during upgrades: - Migrate `INSTALL_DIR` from `~/.opencode/bin` to `~/.local/share/opencode/` - Install binary to `$INSTALL_DIR/versions/$VERSION` - Symlink `~/.local/bin/opencode` to versioned binary
yindo added the pull-request label 2026-02-16 18:16:52 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#11934