{"record":{"id":"4bef03f2346b66f3","repo":"iOfficeAI/OfficeCLI","slug":"officecli-install-failed-exit-r-returncode-ru","errorCode":null,"errorMessage":"officecli install failed (exit {r.returncode}). Run manually:\n    irm https://d.officecli.ai/install.ps1 | iex","messagePattern":"officecli install failed \\(exit (.+?)\\)\\. Run manually:\n    irm https://d\\.officecli\\.ai/install\\.ps1 \\| iex","errorType":"exception","errorClass":"OfficeCliError","httpStatus":null,"severity":"error","filePath":"sdk/python/officecli.py","lineNumber":598,"sourceCode":"    unix, install.ps1 on Windows. Reuses officecli's own installers (platform\n    detection + checksum + ~/.local/bin or %LOCALAPPDATA%\\\\OfficeCLI), rather than\n    reimplementing download logic that would drift from upstream.\n\n    Called automatically by open()/create() when the CLI is missing (pass\n    auto_install=False to disable), and exposed directly as `python -m officecli\n    install`. Returns None on success; raises OfficeCliError on failure. Output is\n    NOT captured, so the installer's progress and checksum lines stream to the\n    user.\"\"\"\n    if _IS_WIN:\n        print(f\"Installing officecli via {_INSTALL_PS1_MIRROR} (github fallback) ...\", file=sys.stderr)\n        # Windows PowerShell (powershell.exe) ships with the OS; -ExecutionPolicy\n        # Bypass lets the remote script run without changing machine policy. Fetch\n        # the script mirror-first, github fallback, then run it.\n        ps = (f\"$s = try {{ irm '{_INSTALL_PS1_MIRROR}' }} \"\n              f\"catch {{ irm '{_INSTALL_PS1_GITHUB}' }}; $s | iex\")\n        r = subprocess.run([\"powershell\", \"-NoProfile\", \"-ExecutionPolicy\", \"Bypass\", \"-Command\", ps])\n        if r.returncode != 0:\n            raise OfficeCliError(r.returncode,\n                f\"officecli install failed (exit {r.returncode}). Run manually:\\n\"\n                f\"    irm {_INSTALL_PS1_MIRROR} | iex\")\n        return None\n    print(f\"Installing officecli via {_INSTALL_SH_MIRROR} (github fallback) ...\", file=sys.stderr)\n    # (curl mirror || curl github) | bash — the subshell emits whichever fetch\n    # succeeds; the group keeps the pipe bound to the whole fallback. Output is\n    # NOT captured, so progress and checksum lines stream to the user.\n    sh = f\"(curl -fsSL {_INSTALL_SH_MIRROR} 2>/dev/null || curl -fsSL {_INSTALL_SH_GITHUB}) | bash\"\n    r = subprocess.run([\"bash\", \"-c\", sh])\n    if r.returncode != 0:\n        raise OfficeCliError(r.returncode,\n            f\"officecli install failed (exit {r.returncode}). Run manually:\\n\"\n            f\"    curl -fsSL {_INSTALL_SH_MIRROR} | bash\")\n    return None\n\n\n# Advertised surface = the command shell + its error. pipe_paths stays importable\n# (officecli.pipe_paths) as a debug helper but isn't part of the command API.","sourceCodeStart":580,"sourceCodeEnd":616,"githubUrl":"https://github.com/iOfficeAI/OfficeCLI/blob/1ced45e900782c5083ed550ddf328ee974e425e7/sdk/python/officecli.py#L580-L616","documentation":"Raised by officecli.install() on Windows when the PowerShell installer (irm of the .ps1 mirror with GitHub fallback, piped to iex) exits with a non-zero return code. The SDK streams installer output to the user and, on failure, reports the exit code and the manual irm | iex command to run.","triggerScenarios":"Running officecli.install() on Windows where PowerShell execution fails: network blocked from fetching the script, ExecutionPolicy conflict, mirror and GitHub both unreachable, or the installer script itself errors.","commonSituations":"Corporate proxy/firewall blocking irm; restricted PowerShell execution context; transient mirror outage; partial download/checksum failure.","solutions":["Run the manual command: irm https://d.officecli.ai/install.ps1 | iex in a PowerShell window to see full output.","Check network/proxy access to d.officecli.ai and the GitHub raw mirror.","If ExecutionPolicy blocks it, run from an elevated shell or adjust policy as your admin permits."],"exampleFix":"# before — installer failed non-interactively\nofficecli.install()\n# after — run manually in PowerShell to see errors\n# PS> irm https://d.officecli.ai/install.ps1 | iex","handlingStrategy":"fallback","validationCode":"null","typeGuard":"null","tryCatchPattern":"import subprocess, officecli\n\ntry:\n    officecli.install()\nexcept officecli.OfficeCliError as e:\n    # fall back to running the manual PowerShell command with full output\n    subprocess.run(['powershell', '-NoProfile', '-ExecutionPolicy', 'Bypass',\n                    '-Command', 'irm https://d.officecli.ai/install.ps1 | iex'])","preventionTips":["On install failure, run irm https://d.officecli.ai/install.ps1 | iex manually to see full output.","Confirm network/proxy access to d.officecli.ai and the GitHub raw mirror.","Run from a shell with adequate PowerShell execution rights."],"tags":["python-sdk","install","windows","powershell","network"],"backgroundTag":null,"analyzedSha":"1ced45e900782c5083ed550ddf328ee974e425e7","analyzedAt":"2026-08-13T13:01:07.193Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}