Skip to content

fix(installation): detect install method from invoked CLI path#26468

Closed
vsiegel wants to merge 3 commits intoanomalyco:devfrom
vsiegel:fix/installation-method-detection
Closed

fix(installation): detect install method from invoked CLI path#26468
vsiegel wants to merge 3 commits intoanomalyco:devfrom
vsiegel:fix/installation-method-detection

Conversation

@vsiegel
Copy link
Copy Markdown

@vsiegel vsiegel commented May 9, 2026

Issue for this PR

Closes #26479

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

This fixes installation-method detection used by auto-upgrade. Previously the code used process.execPath (runtime executable like node/bun) as the primary signal, which can differ from the actual invoked opencode command path. In some local setups that can choose the wrong installer path during upgrade and leave the command unavailable after exiting.

The change switches method heuristics to inspect the invoked CLI path (process.argv[1] fallback chain) and keeps the existing curl path checks and package-manager prioritization behavior.

How did you verify your code works?

  • Reproduced and analyzed the failing behavior path where runtime executable path mismatches command installation path.
  • Validated the diff is scoped to install-method detection only.
  • Attempted local typecheck in packages/opencode; environment is missing tsgo, so full typecheck could not run here.

Screenshots / recordings

N/A (non-UI change)

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

Use the invoked opencode command path for install-method heuristics instead of the runtime executable so auto-upgrade picks the correct package manager and avoids local command disappearance after exit.
@github-actions github-actions Bot added the needs:compliance This means the issue will auto-close after 2 hours. label May 9, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 9, 2026

This PR doesn't fully meet our contributing guidelines and PR template.

What needs to be fixed:

  • Not all checklist items are checked. Please confirm you have tested locally and have not included unrelated changes.

Please edit this PR description to address the above within 2 hours, or it will be automatically closed.

If you believe this was flagged incorrectly, please let a maintainer know.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 9, 2026

Thanks for your contribution!

This PR doesn't have a linked issue. All PRs must reference an existing issue.

Please:

  1. Open an issue describing the bug/feature (if one doesn't exist)
  2. Add Fixes #<number> or Closes #<number> to this PR description

See CONTRIBUTING.md for details.

@vsiegel
Copy link
Copy Markdown
Author

vsiegel commented May 9, 2026

I installed opencode with "npm i -g opencode-ai@latest".
The command opencode repeatedly vanished, so often that it felt really weird not to find a critical issue about it.
Assuming it must be related to the local situation, I literally asked opencode to submit this PR with a fix.
If I get it right, opencode tries to update itself, misjudges how it was installed and proceeds to uninstall itself.

Admittedly, there is educational value in seeing an agent commit suicide.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 9, 2026

This pull request has been automatically closed because it was not updated to meet our contributing guidelines within the 2-hour window.

Feel free to open a new pull request that follows our guidelines.

@github-actions github-actions Bot removed the needs:compliance This means the issue will auto-close after 2 hours. label May 9, 2026
@github-actions github-actions Bot closed this May 9, 2026
@github-actions github-actions Bot added the needs:compliance This means the issue will auto-close after 2 hours. label May 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs:compliance This means the issue will auto-close after 2 hours.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

opencode command disappears after exit because auto-upgrade misdetects install method

1 participant