Skip to content

[FEATURE]: Smart auto-upgrade based on installation method #23435

Closed as not planned

Description

@playeriv65

Describe the enhancement you want to request

Problem

When OpenCode is installed via local npm install (e.g., npm install opencode-ai without -g flag, common on shared servers where users lack sudo access), the auto-upgrade mechanism fails:

  1. TUI shows upgrade prompt: "A new version is available"
  2. User clicks "Update" button
  3. Upgrade fails with permission error (tries to write to /usr/local/lib)
  4. No fallback or guidance for local install scenarios

Current Behavior

The opencode upgrade command assumes global installation:

  • Attempts npm install -g → requires sudo
  • Or attempts curl download to /usr/local/bin → requires sudo
  • Fails silently without detecting local install context

Proposed Enhancement

Smart upgrade detection: Automatically detect the installation method and use the appropriate upgrade strategy:

Install Method Upgrade Strategy
npm install opencode-ai (local in node_modules) npm install opencode-ai@latest in install directory
npm install -g opencode-ai npm install -g opencode-ai@latest
curl script (/usr/local/bin) curl script reinstall
Homebrew brew upgrade opencode

Implementation Suggestions

  1. Detect install location by checking:

    • process.execPath or __dirname of the running binary
    • If path contains node_modules/opencode-ai, it's a local npm install
  2. For local npm installs, run:

    cd <install-dir>/node_modules/opencode-ai/../..
    npm install opencode-ai@latest
  3. Show informative error if upgrade still fails, with manual workaround instructions

Benefits

  • Users on shared servers (no sudo) can use auto-upgrade
  • Reduces confusion about "upgrade failed" errors
  • Better UX for non-global installation scenarios
  • Consistent behavior across all installation methods

Workaround (Current)

Users must manually run:

cd /path/to/node_modules/opencode-ai/../..
npm install opencode-ai@latest

Activity

  1. added
    coreAnything pertaining to core functionality of the application (opencode server stuff)
    on Apr 19, 2026
  2. removed
    coreAnything pertaining to core functionality of the application (opencode server stuff)
    on May 3, 2026
  3. github-actions commented on Jul 3, 2026

    @github-actions
    Contributor

    To stay organized issues are automatically closed after 60 days of no activity. If the issue is still relevant please open a new one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions