Skip to content

fix(plugin): re-link script plugins on update so the real version is detected - #35

Merged
git-hulk merged 1 commit into
git-hulk:masterfrom
gq-guo:fix/script-update-relink
Nov 27, 2026
Merged

git-hulk merged 1 commit into
git-hulk:masterfrom
gq-guo:fix/script-update-relink

Conversation

@gq-guo

@gq-guo gq-guo commented Nov 27, 2026

Copy link
Copy Markdown
Contributor

Problem

For a script plugin, clime plugin update <name> can print Plugin <name> is up to date even though the install script has just installed a newer binary. The recorded version never changes, so clime plugin list keeps showing the old one.

ScriptInstaller.Update reruns the install script, which writes to binary_path. It then detects the version through ~/.clime/plugins/clime-<name> (plugin.Find). Only Install creates that symlink. Once the link stops pointing at binary_path, update installs to one file and reads the version from another. One way this happens: a plugin with its own self-upgrade command, started through the clime link, renames its new binary over os.Executable(). That is the link path on macOS, so the link becomes a standalone stale copy. If that copy's version equals the recorded version, update reports "up to date" from then on.

Fix

  • ScriptInstaller.Update re-points clime-<name> at the installed binary after the script runs. It looks for binary_path first, then the name on PATH, and shares this resolution and linking code with Install. If the binary can't be located, the existing link is kept as before.
  • clime init records binary_path in the local manifest. It was always written as "", so update had nothing to re-link to when the binary name differs from the plugin name.

Repro (before this change)

  1. ~/.clime/plugins/clime-tool points to an old binary that prints v1.0.0, and the recorded version is 1.0.0.
  2. The install script writes a binary that prints v2.0.0 to binary_path.
  3. clime plugin update tool prints ✓ Plugin tool is up to date, and the record stays at 1.0.0.

Tests

  • New TestScriptInstallerUpdateRelinksDriftedSymlink covers this case. It fails on master and passes with this change.
  • go test ./... passes. Locally, internal/skill's TestCloneAtVersion only passes with GIT_CONFIG_GLOBAL=/dev/null, because tag.gpgSign=true in a global git config makes its git tag call ask for a message. That is unrelated to this change.

Not in this PR: clime plugin list still shows the recorded version rather than running -v live, so an upgrade done outside clime shows up only after the next clime plugin update.

🤖 Generated with Claude Code

…detected

`plugin update` for a script plugin reran the install script but read the
version through the existing ~/.clime/plugins/clime-<name> link, which only
Install creates. If that link had drifted away from binary_path (for example
a plugin's own self-upgrade renamed a new binary over the link, leaving a
standalone stale copy), update kept reading the stale copy, reported
"Plugin <name> is up to date" and never refreshed the recorded version.

- ScriptInstaller.Update now re-points the link at binary_path (or the
  binary found on PATH) after the script runs, sharing the resolution and
  linking code with Install. If the binary can't be located, the existing
  link is kept as before.
- `clime init` now records binary_path in the local manifest, so update can
  re-link plugins whose binary name differs from the plugin name.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@git-hulk
git-hulk merged commit 199ad51 into git-hulk:master Nov 27, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants