Fix CLI symlink not updated after Studio app update - #3713
Conversation
|
It seems it works:
I thought I may be fixing an edge case that could happen only during development and testing local build, but it seems it can happen for the user, too:
|
bcotrim
left a comment
There was a problem hiding this comment.
Works as described.
I found one behavior change that may regress users who explicitly uninstalled the CLI before cliUserUninstalled existed.
With this state:
cliAutoInstalled: true- no
cliUserUninstalledkey ~/.local/bin/studioabsent
After launching this branch, Studio recreated ~/.local/bin/studio.
Was that intentional? This state is ambiguous, but it also matches the old “user uninstalled via Settings” state. The stale-bundle case should still have an existing symlink pointing to an old app path, so I wonder if absent symlink + legacy config should keep the CLI uninstalled.
…void IPC handler path
…end to avoid IPC handler path" This reverts commit e2a0c2a.
|
@bcotrim thanks for testing it. I added handling for that case. |
📊 Performance Test ResultsComparing 9224436 vs trunk app-size
site-editor
site-startup
Results are median values from multiple test runs. Legend: 🟢 Improvement (faster) | 🔴 Regression (slower) | ⚪ No change (<50ms diff) |
|
I tested the main flow again, and it works fine: |
|
It took me a second to wrap my head around this, but if I understand it correctly, it's really meant to fix an issue where if you run a local dev build and install it, it might set up a weird symlink at This is kind of an edge case, but I don't have any strong objections to switching the paradigm to running an install on every launch unless we know the user explicitly uninstalled the CLI. However, I think we should consider removing It looks like there's some data migration logic in there (and maybe that's the only real reason we kept that prop). If that's the case, I'd ask that we write an explicit data migration in |
|
@fredrikekelund it could also happen for standard user:
|
|
Right. I'd appreciate it if you could revisit the |
Good catch. We don't need to write it anymore, but we should support it to ensure we don't have to reinstall the CLI for users who uninstalled it in the past. I opened #3781 |
…led (#3781) ## Related issues - Follow-up to #3713 ## How AI was used in this PR Developed with Claude Code assistance. ## Proposed Changes Now that `cliUserUninstalled` exists as an explicit signal, `cliAutoInstalled` no longer serves an ongoing purpose. Its original role — preventing re-installation after first launch — is fully handled by `cliUserUninstalled` (absent = not uninstalled). The only remaining use is a one-time migration: on first launch of the new version, `cliAutoInstalled: true` + absent symlink/directory is treated as a deliberate uninstall and sets `cliUserUninstalled: true`. After that migration runs once per user, `cliAutoInstalled` is never meaningfully consulted again. This PR stops writing `cliAutoInstalled` on new installs and marks it `@deprecated` in the storage type. The migration block still reads it, so existing users who uninstalled before #3713 shipped are correctly preserved. The flag and migration block can be removed entirely in a follow-up release. On Windows, this also fixes `updateWindowsCliVersionedPathIfNeeded()` to run on every launch where the CLI is installed (not only when `cliAutoInstalled` was set), keeping the proxy `.bat` path up to date after app updates. ## Testing Instructions - Launch Studio with `cliAutoInstalled: true` + symlink absent in `app.json` → `cliUserUninstalled` should be set to `true`, CLI not reinstalled - Launch Studio with `cliAutoInstalled: true` + symlink present but stale → symlink re-pointed to current app - Fresh install (no flags set) → CLI installs as normal, `cliAutoInstalled` is NOT written ## Pre-merge Checklist - [ ] Have you checked for TypeScript, React or other console errors? --------- Co-authored-by: Fredrik Rombach Ekelund <fredrik.rombach.ekelund@automattic.com>
Related issues
How AI was used in this PR
This PR was developed with Claude Code assistance.
Proposed Changes
After Studio is updated, the
studioCLI command could continue running the binary from a previous app bundle. The root cause was thatautoInstallIfNeededused a singlecliAutoInstalledflag to mean both "we've done first-time install" and "user deliberately uninstalled — don't reinstall". Once set, it preventedinstallCli()from ever running again, so a stale symlink would never get fixed.This PR introduces a separate
cliUserUninstalledflag that is explicitly set when the user uninstalls the CLI via Settings, and cleared when they reinstall it.autoInstallIfNeedednow skips only whencliUserUninstalledis true, and otherwise callsinstallCli()on every launch. SinceinstallCli()already no-ops when the symlink is correct, this is safe and cheap — it only re-points the symlink when it's actually stale.Testing Instructions
studiocommand is gone and re-launching Studio does not reinstall itstudiocommand works and re-launching Studio keeps it pointing to the correct appPre-merge Checklist