Skip to content

Add Windows support for CLI updates via npm#12877

Draft
AlexS935 wants to merge 1 commit intogitbutlerapp:masterfrom
AlexS935:claude/fix-npm-install-error-kHAVp
Draft

Add Windows support for CLI updates via npm#12877
AlexS935 wants to merge 1 commit intogitbutlerapp:masterfrom
AlexS935:claude/fix-npm-install-error-kHAVp

Conversation

@AlexS935
Copy link

🧢 Changes

  • Removed #[cfg(unix)] guards from the install command to enable it on all platforms
  • Refactored install() function to dispatch to platform-specific implementations:
    • install_unix(): Handles Linux/macOS installations (existing logic)
    • install_windows(): New Windows-specific handler with npm detection
  • Added detect_npm_package() to identify npm-based installations on Windows by checking for node_modules in the executable path or the npm_package_name environment variable
  • Added install_via_npm() to perform npm updates on Windows by spawning a detached batch script that waits for the current process to exit before running npm install -g, avoiding EBUSY file lock errors
  • Added invalidate_update_cache() helper function to reduce code duplication
  • Updated command documentation to reflect Windows npm support and clarify that the command updates the CLI (not the desktop app)

☕️ Reasoning

Previously, the install command was only available on Unix platforms. This change extends update support to Windows users with npm-based installations.

On Windows, npm cannot rename package directories while the current process (running from that directory) holds file locks. The solution spawns a detached updater script that waits for the CLI process to exit before proceeding with the npm update, eliminating the EBUSY error.

For non-npm Windows installations, the command provides helpful download instructions pointing users to the official downloads page.

The refactoring improves maintainability by separating platform-specific logic into dedicated functions and extracting the cache invalidation logic into a reusable helper.

https://claude.ai/code/session_01TBAMrb7RTK9884TPorXCTP

…ling

The `but update install` command was previously unix-only (#[cfg(unix)]),
leaving Windows users with no self-update mechanism. When the CLI is
installed via npm on Windows, npm's rename operation fails with EBUSY
because the running process locks the package directory.

This adds Windows support that:
- Detects npm installations by checking if the exe is under node_modules
- Spawns a detached batch script that waits for the CLI to exit before
  running `npm install -g <package>`, avoiding the EBUSY file lock
- For non-npm Windows installations, provides download instructions
- Extracts cache invalidation into a shared helper

https://claude.ai/code/session_01TBAMrb7RTK9884TPorXCTP
@vercel
Copy link

vercel bot commented Mar 17, 2026

@claude is attempting to deploy a commit to the GitButler Team on Vercel.

A member of the Team first needs to authorize it.

Copy link
Contributor

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c17c7d6960

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +271 to +274
let version_suffix = match target.as_deref() {
Some(version) => format!("@{version}"),
None => "@latest".to_string(),
};
Copy link
Contributor

Choose a reason for hiding this comment

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

P2 Badge Preserve channel when no npm target is provided

When but update install is run on Windows npm installs without an explicit target, this branch always uses @latest instead of deriving the channel from the current build (unlike the Unix path, which auto-detects release vs nightly). In the nightly channel this causes users to be switched to stable on their next update, which contradicts the command’s documented default behavior and can silently change the installed track.

Useful? React with 👍 / 👎.

@Byron Byron marked this pull request as draft March 17, 2026 10:00
@Byron
Copy link
Collaborator

Byron commented Mar 17, 2026

Thanks a lot for giving it a shot!

Let's use this PR as forum for discussion how Windows updates should be supported, and what alternatives to NPM were considered.

In any case, this PR isn't mergable yet and may need time, so I am putting it back into draft.

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.

3 participants