close
Skip to content

Linux: support installing the Studio CLI#3269

Merged
ivan-ottinger merged 6 commits into
trunkfrom
rsm-1316-linux-cli-install
Apr 29, 2026
Merged

Linux: support installing the Studio CLI#3269
ivan-ottinger merged 6 commits into
trunkfrom
rsm-1316-linux-cli-install

Conversation

@ivan-ottinger
Copy link
Copy Markdown
Contributor

@ivan-ottinger ivan-ottinger commented Apr 28, 2026

Related issues

How AI was used in this PR

Used Claude Code to scope the work, write the new LinuxCliInstallationManager (mirroring the macOS one), patch the path bug in studio-cli.sh, and run lint/typecheck/tests. Each change was reviewed before committing.

Proposed Changes

  • Add LinuxCliInstallationManager (apps/studio/src/modules/cli/lib/linux-installation-manager.ts) that symlinks ~/.local/bin/studio → the bundled studio-cli.sh and appends export PATH="$HOME/.local/bin:$PATH" to .bashrc / .zshrc. Mirrors the macOS manager (no /usr/local/bin legacy cleanup needed — no prior Linux release shipped there).
  • Wire the new manager into getCliInstallationManager() so the Preferences toggle and IPC handlers work on Linux. Drop the now-redundant isPlatformSupported() guard — every Electron-supported platform now has a manager, so the explicit throw in getCliInstallationManager() is the single source of truth.
  • Call autoInstallLinuxCliIfNeeded() from apps/studio/src/index.ts so the CLI auto-installs on first launch (production builds only, matching the existing macOS/Windows behavior).
  • Fix apps/studio/bin/studio-cli.sh: derive CLI_SCRIPT from BIN_DIR directly so it works on both macOS (Resources/) and Linux (resources/). The previous CONTENTS_DIR/Resources/cli/main.mjs path was mac-specific and would have broken on Linux even with a working installer.
  • Add a vitest mock for the new module in apps/studio/src/tests/index.test.ts.
  • Update apps/studio/installers/desktop.ejs to use an absolute path in Exec= (/usr/bin/<%= name %> instead of bare <%= name %>). Without this, clicking the dock icon would invoke the CLI symlink (~/.local/bin/studio) instead of the GUI launcher (/usr/bin/studio), because Ubuntu's ~/.profile puts ~/.local/bin ahead of /usr/bin on PATH for the desktop session. Same pattern VS Code uses (Exec=/usr/share/code/code %F).

Testing Instructions

  1. Build the DEB: npm run make.
  2. Install it: sudo apt install ./out/make/deb/<arch>/studio_*.deb.
  3. Reset state so the next launch counts as "first launch": sudo rm -f ~/.local/bin/studio ~/.studio/app.json. Then launch Studio from your distro's application launcher.
  4. The first launch should create ~/.local/bin/studio (a symlink to /usr/lib/studio/resources/bin/studio-cli.sh). We can check this with ls -la ~/.local/bin/studio.
  5. We can also check if export PATH="$HOME/.local/bin:$PATH" is in ~/.bashrc (or ~/.zshrc if zsh is your shell): grep -n '\.local/bin' ~/.bashrc.
  6. Open a fresh terminal so the new PATH export gets sourced, then run studio --help. The CLI help should print.
  7. Run studio preview list (or any other CLI subcommand) to verify the bundled Node runtime and CLI bundle resolve correctly.
  8. In Preferences, toggle the CLI off and Save. Verify the symlink was removed with ls -l ~/.local/bin/studio — it should report "No such file or directory". (Note: which studio may still resolve to /usr/bin/studio, which is the DEB-installed GUI launcher — that's expected and unrelated to the CLI.)
  9. In Preferences, toggle the CLI back on and Save. In a fresh terminal (or after hash -r in the current one, since bash caches command paths), confirm studio --help works again.
  10. Verify the dock/launcher icon still opens the GUI (not the CLI) while the CLI symlink is present at ~/.local/bin/studio.

Pre-merge Checklist

  • Have you checked for TypeScript, React or other console errors?
  • Manually validated the install / uninstall / auto-install flow on a Linux machine (DEB build).

@ivan-ottinger ivan-ottinger self-assigned this Apr 28, 2026
}
}

function isPlatformSupported(): boolean {
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Since we support all three platforms now, this is not necessary anymore.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Nice! Makes sense.

@ivan-ottinger ivan-ottinger marked this pull request as ready for review April 29, 2026 08:23
@ivan-ottinger ivan-ottinger requested a review from Copilot April 29, 2026 08:35
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds Linux support for installing and auto-installing the bundled Studio CLI, aligning Linux behavior with existing macOS/Windows flows and fixing Linux pathing issues in the CLI launcher script.

Changes:

  • Introduce LinuxCliInstallationManager and wire it into CLI IPC install/uninstall/status flows.
  • Auto-install the CLI on first production launch on Linux (matching other platforms).
  • Fix Linux desktop launcher Exec= resolution and make studio-cli.sh resource-path agnostic (macOS vs Linux).

Reviewed changes

Copilot reviewed 5 out of 6 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
apps/studio/src/modules/cli/lib/linux-installation-manager.ts Adds Linux CLI install/uninstall/auto-install implementation (symlink + shell profile PATH export).
apps/studio/src/modules/cli/lib/ipc-handlers.ts Adds Linux manager to platform switch; removes previous platform guard.
apps/studio/src/index.ts Calls Linux CLI auto-install during app boot in production.
apps/studio/bin/studio-cli.sh Fixes CLI bundle path resolution to work under Linux resources/ and macOS Resources/.
apps/studio/installers/desktop.ejs Uses absolute Exec=/usr/bin/<name> to ensure launcher opens GUI, not CLI symlink.
apps/studio/src/tests/index.test.ts Mocks the new Linux auto-install module for initialization tests.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread apps/studio/src/modules/cli/lib/linux-installation-manager.ts
Comment thread apps/studio/src/modules/cli/lib/linux-installation-manager.ts Outdated
@ivan-ottinger ivan-ottinger requested review from a team and gavande1 April 29, 2026 09:11
@wpmobilebot
Copy link
Copy Markdown
Collaborator

📊 Performance Test Results

Comparing 30b79f2 vs trunk

app-size

Metric trunk 30b79f2 Diff Change
App Size (Mac) 1454.55 MB 1454.51 MB 0.04 MB ⚪ 0.0%

site-editor

Metric trunk 30b79f2 Diff Change
load 1775 ms 1815 ms +40 ms ⚪ 0.0%

site-startup

Metric trunk 30b79f2 Diff Change
siteCreation 8085 ms 8081 ms 4 ms ⚪ 0.0%
siteStartup 4941 ms 4946 ms +5 ms ⚪ 0.0%

Results are median values from multiple test runs.

Legend: 🟢 Improvement (faster) | 🔴 Regression (slower) | ⚪ No change (<50ms diff)

Copy link
Copy Markdown
Contributor

@gavande1 gavande1 left a comment

Choose a reason for hiding this comment

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

Thanks for fixing this. I tested it, and it works as expected. The CLI was installed and removed according to the preferences.

CLI installation
Image
Preview site created using CLI
Image

@ivan-ottinger ivan-ottinger merged commit e2e9235 into trunk Apr 29, 2026
16 checks passed
@ivan-ottinger ivan-ottinger deleted the rsm-1316-linux-cli-install branch April 29, 2026 11:37
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.

4 participants