Skip to content

Remove partial OpenCode install when symlink creation fails - #484

Open
Ravomi wants to merge 2 commits into
google:mainfrom
Ravomi:fix/480-opencode-symlink-cleanup
Open

Ravomi wants to merge 2 commits into
google:mainfrom
Ravomi:fix/480-opencode-symlink-cleanup

Conversation

@Ravomi

@Ravomi Ravomi commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

Contribution Type

  • Bug Fix / Minor Patch (Targeted fix, non-test diff <= 100 lines and < 3 core files in skills/ or agents/; no design doc required)

Closes #480

Summary of Key Changes

  • Update adapters/opencode/install.py: Clean up the newly created installation directory on failure and re-raise the original error. Windows junction fallback is out of scope.
  • Update tests/unit/test_opencode_adapter.py: Verify symlink failure leaves no partial destination and retrying at the same path succeeds.

Human Accountability Affirmation

  • I am a human contributor. I have personally reviewed, understood, and can explain every line of this change in review (using AI tools to write code is welcome, but human understanding of the submitted change is required).

Verification

  • For Bug Fix / Implementation PRs (Stage 2): pytest tests/unit/test_opencode_adapter.py -q executed (17 passed on Linux).

@egm-triage-bot egm-triage-bot left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated first-pass review found zero blocking or major issues. Routing to @google/egm-maintainers for maintainer review.

@egm-triage-bot egm-triage-bot added the triage: passed Automated Stage-1 PR triage found zero blocking or major issues label Nov 18, 2026
@egm-triage-bot
egm-triage-bot requested review from a team and n3wth and removed request for a team November 18, 2026 19:37
@karthik-0306

Copy link
Copy Markdown

Verified locally on Windows 11 (Python 3.11.18) without Developer Mode or admin rights, based on 70406c4.

  • On main, python adapters/opencode/install.py <dir> fails with WinError 1314 and leaves bundle/ and an empty skills/. A retry then fails with FileExistsError (Remove partial OpenCode install when symlink creation fails #480).
  • On this branch the install completes. All 8 entries in skills/ are directory junctions (LinkType: Junction), and each resolves to its SKILL.md.
  • It also completes for a destination containing spaces and a non-ASCII character (EGM candidate ü).
  • tests/unit/test_opencode_adapter.py: failures drop from 5 on main to 2. The remaining 2 (test_symlink_parent_cannot_bypass_path_validation, test_dangling_destination_is_untouched) create symlinks in their own setup, so they're out of scope here.

Two optional suggestions:

  1. If mklink fails, check=True with capture_output=True raises a bare CalledProcessError, and the reason is lost. Including stderr in the raised error would help. Alternatively, the private _winapi.CreateJunction creates the junction without a shell.
  2. docs/opencode.md could mention that Windows falls back to junctions when symlinks aren't allowed.

@n3wth

n3wth commented Nov 21, 2026

Copy link
Copy Markdown
Collaborator

@Ravomi, Could you keep the partial-install cleanup in this patch? The Windows junction fallback has useful evidence and can be evaluated separately against the installer support scope.

@egm-triage-bot egm-triage-bot left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated first-pass review found zero blocking or major issues. Routing to @google/egm-maintainers for maintainer review.

@Ravomi

Ravomi commented Nov 21, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for the feedback! I’ve removed the Windows junction fallback so this PR only cleans up partial installs. The Ubuntu and Windows tests both passed.

This branch has not been deployed

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

Labels

triage: passed Automated Stage-1 PR triage found zero blocking or major issues

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Remove partial OpenCode install when symlink creation fails

4 participants