Skip to content

fix(install): return failure exit codes - #7123

Merged
danielhanchen merged 1 commit into
unslothai:mainfrom
ShiroKSH:fix/installer-failure-exit-code
Jul 15, 2026
Merged

danielhanchen merged 1 commit into
unslothai:mainfrom
ShiroKSH:fix/installer-failure-exit-code

Conversation

@ShiroKSH

Copy link
Copy Markdown
Contributor

Summary

  • make non-Tauri Windows installer failures terminate after rollback instead of returning success
  • retain the existing Tauri exit-code behavior
  • add a process regression test for invalid --package input

Verification

  • parsed install.ps1 under Windows PowerShell 5.1
  • verified invalid --package returns exit code 1 in standard and Tauri modes
  • ran python -m py_compile tests/test_installer_skip_autostart.py

@ShiroKSH
ShiroKSH requested a review from danielhanchen as a code owner July 14, 2026 13:47

@gemini-code-assist gemini-code-assist Bot left a comment

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.

Code Review

This pull request updates the Windows installer script (install.ps1) to throw an error message on failure when not in Tauri mode, and adds a regression test to verify that invalid package names cause the installer to fail. The review feedback suggests improving the test's robustness on Windows systems by falling back to powershell if pwsh is unavailable, and resolving the executable path to an absolute path to prevent potential path resolution issues.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment on lines +123 to +141
@pytest.mark.skipif(shutil.which("pwsh") is None, reason = "PowerShell is unavailable")
def test_windows_installer_invalid_package_fails():
result = subprocess.run(
[
"pwsh",
"-NoProfile",
"-NonInteractive",
"-File",
str(INSTALL_PS1),
"--package",
"bad!",
],
capture_output = True,
text = True,
timeout = 30,
)

assert result.returncode != 0
assert "package name contains invalid characters" in result.stdout + result.stderr

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.

medium

On Windows systems, PowerShell Core (pwsh) may not be installed by default, whereas Windows PowerShell (powershell) is always available. To ensure this regression test runs and provides coverage on standard Windows environments, we can dynamically fall back to powershell if pwsh is not found on the system PATH. Additionally, when resolving executable paths to be passed to subprocesses, we should always return an absolute path (e.g., using Path.resolve()) to prevent relative paths without directory separators from being incorrectly resolved via the system PATH.

@pytest.mark.skipif(
    shutil.which("pwsh") is None and shutil.which("powershell") is None,
    reason="PowerShell is unavailable",
)
def test_windows_installer_invalid_package_fails():
    resolved_shell = shutil.which("pwsh") or shutil.which("powershell")
    ps_cmd = str(pathlib.Path(resolved_shell).resolve())
    result = subprocess.run(
        [
            ps_cmd,
            "-NoProfile",
            "-NonInteractive",
            "-File",
            str(INSTALL_PS1.resolve()),
            "--package",
            "bad!",
        ],
        capture_output=True,
        text=True,
        timeout=30,
    )

    assert result.returncode != 0
    assert "package name contains invalid characters" in result.stdout + result.stderr
References
  1. Skip tests that invoke platform-specific shells (like 'sh' or 'pwsh') via subprocesses when those shells are unavailable on the host system (e.g., using pytest.mark.skipif), or structure the test suite to run the native shell of each platform.
  2. When resolving executable paths to be passed to subprocesses, always return an absolute path (e.g., using Path.resolve()). This prevents relative paths without directory separators from being incorrectly resolved via the system PATH, which can lead to FileNotFoundError.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Leaving as-is. INSTALL_PS1 is already absolute (REPO_ROOT uses Path(file).resolve()) and shutil.which() already returns an absolute path, so the extra .resolve() calls are no-ops here. windows-latest ships pwsh preinstalled, so this test runs (not skips) in CI, and skipif only skips on a host without pwsh rather than failing. The invalid-package path returns exit code 1 identically under Windows PowerShell 5.1 and 7, so a powershell fallback would not add coverage.

@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Jul 15, 2026
@danielhanchen

Copy link
Copy Markdown
Member

@codex review

1 similar comment
@danielhanchen

Copy link
Copy Markdown
Member

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 👍

Reviewed commit: 0ab8838f73

ℹ️ 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".

@danielhanchen
danielhanchen merged commit 3eb3259 into unslothai:main Jul 15, 2026
1 check passed
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.

2 participants