Skip to content

fix(cua-driver)(#1651): install.ps1 updates current shell's PATH for immediate cua-driver resolution - #1652

Merged
f-trycua merged 1 commit into
mainfrom
fix/install-current-shell-path-update
May 21, 2026
Merged

fix(cua-driver)(#1651): install.ps1 updates current shell's PATH for immediate cua-driver resolution#1652
f-trycua merged 1 commit into
mainfrom
fix/install-current-shell-path-update

Conversation

@f-trycua

@f-trycua f-trycua commented May 21, 2026

Copy link
Copy Markdown
Collaborator

Summary

After `irm install.ps1 | iex`, the user's next `cua-driver --version` fails with "not recognized" because PowerShell's `$env:Path` was cached at process start and doesn't see the User PATH registry update. install.ps1 runs in the caller's shell via `iex`, so it CAN mutate `$env:Path` directly. This PR makes `Add-UserPathEntry` do that too.

Fix

Two-line change in `Add-UserPathEntry`:
```powershell
if (-not (($env:Path -split ';') -contains $dir)) {
$env:Path = "$dir;$env:Path"
}
```

Plus hint-message update: "resolves immediately in THIS shell and in any new shell."

Verification

Before:
```
PS> irm install.ps1 | iex
... cua-driver-rs 0.2.16 installed.
PS> cua-driver --version
cua-driver : The term 'cua-driver' is not recognized ...
```

After (v0.2.17):
```
PS> irm install.ps1 | iex
... cua-driver-rs 0.2.17 installed.
PS> cua-driver --version
cua-driver 0.2.17
```

Closes #1651.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • The installer now updates your current shell session's PATH immediately after installation, allowing you to use cua-driver without restarting your terminal.
    • Updated installer messaging to clarify that cua-driver is available immediately in the current session.

Review Change Stack

… so cua-driver resolves immediately

User-facing bug: after `irm install.ps1 | iex`, `cua-driver --version`
fails with "not recognized" in the SAME shell. The installer wrote the
bin dir to the User PATH registry, but PowerShell's $env:Path was
cached at process start — the registry update doesn't propagate to the
running shell. The post-install message even acknowledged this:

  cua-driver will resolve in any NEW PowerShell window.
  In THIS shell, invoke via the full Binary path printed below.

That's a usability papercut. The user just ran the install one-liner,
sees "0.2.16 installed", and their natural next command fails. They
either re-read the message and copy the full binary path, or open a
new tab. Either way: the install LOOKS broken.

## Fix

install.ps1 runs in the caller's PowerShell via `iex` (per the
`irm install.ps1 | iex` one-liner), so it CAN mutate that shell's
$env:Path directly. Add-UserPathEntry now does two writes:

  1. Persistent (registry, via Environment::SetEnvironmentVariable
     scope=User) — unchanged.
  2. Current process ($env:Path prepend, idempotent) — new.

The current-process write is guarded with a `-contains` check so
re-running the installer doesn't accumulate duplicate entries.

Plus updated the post-install hint and the manual-PATH-instructions
helper to say "resolves immediately in this shell" instead of "in any
NEW PowerShell window".

## Verification

```powershell
PS> irm install.ps1 | iex
...
Added C:\Users\cuademo\AppData\Local\Programs\Cua\cua-driver\bin to your User PATH.
  cua-driver resolves immediately in THIS shell and in any new shell.

PS> cua-driver --version
cua-driver 0.2.17        # ← was: "not recognized" before this fix
```

Closes #1651.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@vercel

vercel Bot commented May 21, 2026

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
docs Ignored Ignored Preview May 21, 2026 8:58pm

Request Review

@f-trycua
f-trycua merged commit c094498 into main May 21, 2026
5 of 7 checks passed
@f-trycua
f-trycua deleted the fix/install-current-shell-path-update branch May 21, 2026 20:58
@coderabbitai

coderabbitai Bot commented May 21, 2026

Copy link
Copy Markdown
Contributor

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 85a2366d-88e3-433e-97f7-2f180f3f383a

📥 Commits

Reviewing files that changed from the base of the PR and between 4797fe0 and 11772b6.

📒 Files selected for processing (1)
  • libs/cua-driver/scripts/install.ps1

📝 Walkthrough

Walkthrough

The installer updates the current PowerShell session's $env:Path immediately after adding the install directory to the User PATH, allowing cua-driver to resolve without reopening the shell. Post-install messaging is adjusted to reflect immediate availability.

Changes

Install Session PATH Availability

Layer / File(s) Summary
In-process PATH update
libs/cua-driver/scripts/install.ps1
Add-UserPathEntry now prepends the install bin directory to the caller's current process $env:Path immediately after updating the persistent User PATH, if not already present.
Post-install messaging
libs/cua-driver/scripts/install.ps1
Manual PATH instructions and success confirmation messages are updated to indicate cua-driver is available immediately in the current shell rather than only in new shells.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Possibly related PRs

  • trycua/cua#1576: Both PRs modify libs/cua-driver/scripts/install.ps1's PATH-update behavior—fix(cua-driver/install.ps1): auto-add bin dir to User PATH #1576 adds/idempotently updates the User PATH (with -NoPathUpdate fallback) and this PR further ensures $env:Path in the current PowerShell session is updated immediately after the User PATH change.

  • trycua/cua#1628: Both PRs modify libs/cua-driver/scripts/install.ps1's post-install PATH/hint messaging (e.g., cua-driver resolution guidance for the current session and related text), though only this PR additionally updates $env:Path in the running shell.

Poem

🐰 A PATH that springs to life right here,
No waiting for a shell new-spun!
The rabbit hops through install with cheer—
cua-driver runs when setup's done.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/install-current-shell-path-update

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

f-trycua added a commit that referenced this pull request May 21, 2026
The previous params conflicted in meaning with install.ps1:
- install.ps1's `-Release "<version>"` selects the release TAG to install
- install-local.ps1's `-Release` switched build CONFIGURATION (debug vs release)

Both were named `-Release` but meant entirely different things. Confusing
for anyone bouncing between the two scripts.

Aligning install-local.ps1's surface with install.ps1:
- Drop `-Release` switch entirely. Always build in release mode (matches
  what install.ps1 hands end users — the GitHub Releases zip is built
  --release). If a dev wants debug builds for faster compile iteration,
  invoke `cargo build -p cua-driver` directly and use the resulting
  target\debug\cua-driver.exe themselves.
- Add `-NoPathUpdate` switch + the corresponding PATH-update step that
  install.ps1 has. Also updates $env:Path in the current shell so
  cua-driver resolves immediately (matches #1651 / PR #1652 behavior).
- Keep `-AutoStart` — same shape as install.ps1.

Final params: `-AutoStart`, `-NoPathUpdate`. Exact subset of install.ps1.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
f-trycua added a commit that referenced this pull request May 22, 2026
…surface + v0.2.14+ paths (#1655)

Dev-script polish so the local-build install loop matches what end users
experience. Two changes:

1. **Path defaults**: switch the visible bin dir and package home defaults
   to v0.2.14+ layout (`Programs\Cua\cua-driver` + `~/.cua-driver`).
   Previously install-local.ps1 was still using the legacy
   `trycua\cua-driver-rs` paths, which meant local-build installs landed
   in a different location than what install.ps1 produces — and the
   `current` junction couldn't flip between them.

2. **Param surface mirrors install.ps1**: drop the `-Release` switch
   (which conflicted in meaning with install.ps1's `-Release "<version>"`
   tag selector — confusing for anyone bouncing between the two scripts)
   and always build release-mode (matches what install.ps1 hands users —
   the GitHub Releases zip is `--release`). Add `-NoPathUpdate` switch +
   corresponding User-PATH update step (also writes $env:Path in the
   current shell so cua-driver resolves immediately, matching PR #1652
   / #1651's behavior). Keep `-AutoStart` as-is.

Final param surface: `-AutoStart`, `-NoPathUpdate` — exact subset of
install.ps1's user-facing params. If a dev wants a debug build for
faster compile iteration, invoke `cargo build -p cua-driver` and use
target\debug\cua-driver.exe directly.

Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
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.

install.ps1: cua-driver not resolvable in the SAME shell after irm | iex — /Users/francesco/cuaath needs in-process update

1 participant