Skip to content

Add cross-platform installer scripts#5

Merged
cleak merged 7 commits into
masterfrom
codex/add-installers
Apr 7, 2026
Merged

Add cross-platform installer scripts#5
cleak merged 7 commits into
masterfrom
codex/add-installers

Conversation

@cleak
Copy link
Copy Markdown
Owner

@cleak cleak commented Apr 7, 2026

Summary

  • add repo-root Windows and Linux installer scripts that install tempyr from crates/tempyr-cli
  • update PATH idempotently for the install root on both platforms
  • safely handle locked updates by only terminating running tempyr processes whose executable path exactly matches the installed binary before retrying the install

Validation

  • parsed install.ps1 successfully with PowerShell's parser
  • smoke-tested install.ps1 with a fresh install root
  • smoke-tested reinstall while a live tempyr.exe --mcp process was holding the installed binary, confirming the installer kills only the exact installed binary path and retries successfully

Notes

  • the Linux installer path was reviewed and syntax-checked in this session, but not fully runtime-smoked in a native Linux environment here

Summary by CodeRabbit

  • Documentation

    • Added a comprehensive installation guide with platform-specific steps, update instructions, and customizable install locations.
  • New Features

    • Added interactive installers for Linux and Windows to install/update the CLI, optionally update the user PATH, and support custom install roots.
    • Installers detect locked executables, stop only exact-matching running binaries, retry installation, and perform idempotent PATH updates (with opt-out).

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 7, 2026

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Added installation documentation and two platform-specific installers (install.sh, install.ps1) that perform cargo-based installs of the tempyr CLI, handle locked binaries by stopping matching processes and retrying once, and optionally update the user PATH.

Changes

Cohort / File(s) Summary
Documentation
docs/install.md
New installation guide describing source install target (crates/tempyr-cli), default install roots (XDG/data on Linux, %LocalAppData% on Windows), flags (--install-root / -InstallRoot, --no-path-update / -NoPathUpdate), update behavior, and lock-handling semantics.
Linux installer
install.sh
New Bash installer: validates cargo and source path, runs cargo install --path crates/tempyr-cli --root <...> --locked --force --bin tempyr, captures output, detects "device busy" lock patterns, enumerates /proc to find matching executables, terminates matching processes (SIGTERM → SIGKILL retries), retries install once, and upserts a marked PATH block into ~/.profile and shell rc files unless --no-path-update.
Windows installer
install.ps1
New PowerShell installer: strict mode, validates cargo, runs cargo install --path .\crates\tempyr-cli --root $InstallRoot --locked --force --bin tempyr, captures output, detects file-lock/access-denied patterns, canonicalizes running processes' executable paths, stops matching tempyr.exe processes (when needed) and retries once, and updates the user PATH (registry + current process + broadcast) unless -NoPathUpdate.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Installer
    participant Cargo
    participant FS
    participant ProcMgr
    participant PathMgr

    User->>Installer: invoke installer (flags: install-root / no-path-update)
    Installer->>Installer: validate cargo and source crate path
    Installer->>Cargo: cargo install --path crates/tempyr-cli --root ... --locked --force --bin tempyr
    alt install succeeds
        Cargo->>FS: write binary to <install_root>/bin/tempyr(.exe)
        Cargo-->>Installer: exit 0
        Installer->>PathMgr: optionally add bin to user PATH (rc files or registry)
        PathMgr-->>Installer: PATH updated / already present
        Installer-->>User: success
    else install fails with lock/access error
        Cargo-->>Installer: non-zero + output indicates lock/access denied
        Installer->>ProcMgr: enumerate running processes and canonicalize exec paths
        ProcMgr-->>Installer: matching PID(s) for target executable
        Installer->>ProcMgr: terminate matching process(es) (SIGTERM / taskkill, escalate to SIGKILL)
        ProcMgr-->>Installer: processes stopped
        Installer->>Cargo: retry cargo install once
        Cargo->>FS: write binary to install root/bin
        Cargo-->>Installer: exit 0
        Installer->>PathMgr: optionally add bin to user PATH
        Installer-->>User: success after retry
    end
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Poem

🐇 I hopped through docs and scripts today,
bash and PowerShell paved the way,
if tempyr's stuck, I'll sniff the trace,
stop the run, then give one chase,
PATH set snug — now off I play.

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The pull request title 'Add cross-platform installer scripts' accurately summarizes the main change: adding installer scripts for both Windows and Linux platforms.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/add-installers

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

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@docs/install.md`:
- Around line 13-19: Add documentation describing the opt-out flags for PATH
mutation: mention the installer flags --no-path-update (for install.sh) and
-NoPathUpdate (for install.ps1) and show a short example for each (e.g., bash
install.sh --no-path-update and PowerShell .\install.ps1 -NoPathUpdate). Update
the sections that explain how the installers idempotently update PATH (the Unix
and Windows install paragraphs) to include a one-line note and the example
commands so users in managed environments can discover the non-mutating install
mode; reference the install scripts by name (install.sh, install.ps1) and the
flags (--no-path-update, -NoPathUpdate).

In `@install.ps1`:
- Around line 85-100: The current shutdown routine stops processes with
Stop-Process and returns $true without confirming termination; re-query the
process set by calling Get-TargetProcessIds -BinaryPath $BinaryPath after the
Stop-Process/Wait-Process loop and only return $true if that re-check returns an
empty array, otherwise return $false so the caller's retry logic won't proceed
while a matching tempyr.exe is still running; update the block containing
$processIds, Stop-Process, the foreach Wait-Process loop, and the final return
to perform this final verification using Get-TargetProcessIds.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 17086604-cfe4-4815-bea2-ca8a2fc7e2bd

📥 Commits

Reviewing files that changed from the base of the PR and between f82ba30 and f670a29.

📒 Files selected for processing (3)
  • docs/install.md
  • install.ps1
  • install.sh

Comment thread docs/install.md
Comment thread install.ps1 Outdated
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@install.ps1`:
- Line 58: The variable $matches is shadowing PowerShell's automatic $matches;
rename the local variable created with New-Object
System.Collections.Generic.List[int] (e.g., to $matchList or $customMatches) and
update all references where it's used (the subsequent usages around the current
references on lines 72 and 76) to the new name to avoid clobbering the automatic
regex results; ensure the variable name is consistent where it's initialized and
where items are added/iterated.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 4e9e8092-80e1-4cf8-97b1-27383ddc8dc9

📥 Commits

Reviewing files that changed from the base of the PR and between f670a29 and 66fcefa.

📒 Files selected for processing (2)
  • docs/install.md
  • install.ps1

Comment thread install.ps1 Outdated
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@install.ps1`:
- Around line 240-243: The thrown error currently discards cargo's captured
output; update the throw sites to include the combined stderr/stdout payload
(the $output variable and/or $installResult.Output) so the error message
contains both the exit code and the captured output; locate the places building
and returning the PSCustomObject (ExitCode and Output) and the subsequent throw
statements (including the similar case around lines 276-277) and concatenate or
interpolate $installResult.Output into the thrown exception message to surface
cargo logs in CI failures.
- Around line 161-195: The current PATH dedupe only checks the user PATH and
treats any malformed segment as fatal; change the logic around
Normalize-PathEntry and the comparison so you build the comparison set from both
persisted scopes ([Environment]::GetEnvironmentVariable("Path","User") and
("Machine")), iterate entries and attempt Normalize-PathEntry inside a safe
check (skip entries that return null/empty or throw), and compare
normalizedEntry to $normalizedTarget using OrdinalIgnoreCase to avoid duplicates
even if the match exists in machine scope; only set the user env and prepend
$env:Path when no matching normalized entry was found, and keep
Broadcast-EnvironmentChange as-is. Ensure references: Normalize-PathEntry,
$userPath, $env:Path, [Environment]::GetEnvironmentVariable("Path","Machine"),
$updatedPath, Broadcast-EnvironmentChange.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: b94d0c9e-8f56-4d30-ae5c-946eb936e7aa

📥 Commits

Reviewing files that changed from the base of the PR and between 66fcefa and b230769.

📒 Files selected for processing (1)
  • install.ps1

Comment thread install.ps1 Outdated
Comment thread install.ps1
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@install.ps1`:
- Around line 329-333: The message after Ensure-UserPathContains() uses
$addedToPath and currently says "user PATH" even when the directory was found
only in machine scope; update the Write-Host messaging that references $binDir
and $addedToPath to use a neutral phrase like "already present in PATH" (or
similar) so it accurately covers both user- and machine-scope matches—locate the
block that checks $NoPathUpdate and $addedToPath and change the "Added $binDir
to the user PATH." / "$binDir is already present in the user PATH." strings
accordingly.
- Around line 254-268: Start-Process is building a single command line so
unquoted path values like $CratePath and $InstallRootPath will break when they
contain spaces; fix by ensuring those path arguments include literal escaped
double quotes in the ArgumentList (e.g. wrap the $CratePath and $InstallRootPath
strings with escaped quotes) when constructing the -ArgumentList for
Start-Process (the block that builds the "install", "--path", $CratePath,
"--root", $InstallRootPath, ... arguments); alternatively, replace this
Start-Process invocation with a direct invocation using the call operator (&
$cargoExe ...) which preserves argument boundaries — update the code that
creates $process (Start-Process and its -ArgumentList) to use one of these two
approaches so path arguments are correctly quoted.
- Around line 37-48: The try/catch around [System.IO.File]::Open($Path, ...
[System.IO.FileShare]::None) only catches System.IO.IOException; update the
error handling so UnauthorizedAccessException is caught and treated as a
permission failure (return $false) while IOException still indicates a lock
(return $true). Specifically, add a catch for System.UnauthorizedAccessException
for the Open call that returns $false, keep or add the catch for
System.IO.IOException returning $true, and ensure the catch order/clauses (the
try block using $Path and FileShare.None) reflect this behavior.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 549877c7-d372-4376-bba9-b229ac2a5ef8

📥 Commits

Reviewing files that changed from the base of the PR and between b230769 and 77dc2a3.

📒 Files selected for processing (1)
  • install.ps1

Comment thread install.ps1
Comment thread install.ps1 Outdated
Comment thread install.ps1 Outdated
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@install.ps1`:
- Around line 102-127: Rename the unapproved verbs in the functions: change
Normalize-PathEntry to an approved verb name such as
ConvertTo-CanonicalPathEntry or Resolve-PathEntry and rename
Try-Normalize-PathEntry accordingly (e.g., Try-ConvertTo-CanonicalPathEntry or
Try-Resolve-PathEntry); update all references/call sites to use the new names
and keep the same parameter signature and behavior (Normalize-PathEntry,
Try-Normalize-PathEntry, Resolve-CanonicalPath and Resolve-CanonicalPath -Path
usage in the body remain unchanged), so PSScriptAnalyzer won't flag the verbs
while preserving functionality.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: e0b7c840-079d-4b87-b71f-82ba663189cd

📥 Commits

Reviewing files that changed from the base of the PR and between 77dc2a3 and 026fe4e.

📒 Files selected for processing (1)
  • install.ps1

Comment thread install.ps1 Outdated
@cleak cleak merged commit 62eedc8 into master Apr 7, 2026
1 check passed
@cleak cleak deleted the codex/add-installers branch April 7, 2026 18:54
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.

1 participant