{"record":{"id":"f1aeac855595abb7","repo":"iOfficeAI/OfficeCLI","slug":"officecli-install-failed-run-manually-irm","errorCode":null,"errorMessage":"officecli install failed. Run manually:\n    irm ${INSTALL_PS1_MIRROR} | iex","messagePattern":"officecli install failed\\. Run manually:\n    irm (.+?) \\| iex","errorType":"error_code","errorClass":"OfficeCliError","httpStatus":null,"severity":"error","filePath":"sdk/node/index.js","lineNumber":624,"sourceCode":"/**\n * Install the officecli CLI binary via its OFFICIAL installer — explicit by\n * design (this SDK never auto-downloads behind your back). Runs install.ps1 via\n * PowerShell on Windows and install.sh via bash elsewhere. Note: when installed\n * via npm, @officecli/officecli already bundles an auto-updating binary, so this\n * is only needed for a standalone (~/.local/bin or %LOCALAPPDATA%\\OfficeCLI)\n * install.\n */\nfunction install() {\n  if (IS_WIN) {\n    process.stderr.write(`Installing officecli via ${INSTALL_PS1_MIRROR} (github fallback) ...\\n`);\n    // Fetch the script mirror-first, github fallback, then run it. The whole\n    // try/catch is assigned so a mirror failure transparently falls back.\n    const ps = `$s = try { irm '${INSTALL_PS1_MIRROR}' } catch { irm '${INSTALL_PS1_GITHUB}' }; $s | iex`;\n    const r = spawnSync('powershell', ['-NoProfile', '-ExecutionPolicy', 'Bypass', '-Command', ps], {\n      stdio: 'inherit',\n    });\n    if (r.status !== 0) {\n      throw new OfficeCliError(\n        r.status == null ? -1 : r.status,\n        `officecli install failed. Run manually:\\n    irm ${INSTALL_PS1_MIRROR} | iex`\n      );\n    }\n    return;\n  }\n  process.stderr.write(`Installing officecli via ${INSTALL_SH_MIRROR} (github fallback) ...\\n`);\n  // (curl mirror || curl github) | bash — the subshell emits whichever script\n  // fetch succeeds; the group keeps the pipe bound to the whole fallback.\n  const sh = `(curl -fsSL ${INSTALL_SH_MIRROR} 2>/dev/null || curl -fsSL ${INSTALL_SH_GITHUB}) | bash`;\n  const r = spawnSync('bash', ['-c', sh], { stdio: 'inherit' });\n  if (r.status !== 0) {\n    throw new OfficeCliError(\n      r.status == null ? -1 : r.status,\n      `officecli install failed. Run manually:\\n    curl -fsSL ${INSTALL_SH_MIRROR} | bash`\n    );\n  }\n}","sourceCodeStart":606,"sourceCodeEnd":642,"githubUrl":"https://github.com/iOfficeAI/OfficeCLI/blob/1ced45e900782c5083ed550ddf328ee974e425e7/sdk/node/index.js#L606-L642","documentation":"Thrown by install() on Windows when the PowerShell-driven install (install.ps1 fetched mirror-first, GitHub fallback) exits non-zero. The SDK deliberately does not auto-install behind your back; this explicit installer failed and points the user at the manual irm | iex command.","triggerScenarios":"PowerShell execution policy blocks the script; network cannot reach the mirror or GitHub; PowerShell itself is missing/restricted; the install.ps1 script errors partway (e.g. cannot write to %LOCALAPPDATA%\\OfficeCLI); TLS settings on old PowerShell block HTTPS.","commonSituations":"Locked-down corporate Windows with constrained ExecutionPolicy; air-gapped Windows; PowerShell 5.1 default TLS 1.0 failing against TLS-1.2-only endpoints; a user without write permission to the install dir.","solutions":["Run the manual command from an elevated/developer PowerShell: `irm https://d.officecli.ai/install.ps1 | iex`.","If ExecutionPolicy blocks it, run from a session with `Set-ExecutionPolicy -Scope Process Bypass` or invoke with `-ExecutionPolicy Bypass`.","For TLS errors on old PowerShell: `[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12` before irm.","Verify network egress to d.officecli.ai and raw.githubusercontent.com and write access to %LOCALAPPDATA%\\OfficeCLI."],"exampleFix":"# before: install() -> officecli install failed. Run manually: irm ... | iex\n# after: from a developer PowerShell\nSet-ExecutionPolicy -Scope Process Bypass -Force\n[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12\nirm https://d.officecli.ai/install.ps1 | iex","handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":"// Fall back to the documented manual PowerShell command\ntry { require('@officecli/sdk').install(); }\ncatch (e) {\n  if (/install failed/i.test(e.message)) {\n    require('child_process').execSync(\n      'powershell -NoProfile -ExecutionPolicy Bypass -Command \"irm https://d.officecli.ai/install.ps1 | iex\"',\n      { stdio: 'inherit' });\n  } else throw e;\n}","preventionTips":["Pre-run install.ps1 in your image so the SDK finds the binary already present.","Set TLS 1.2 and a permissive ExecutionPolicy for the install session.","Confirm egress to d.officecli.ai and write access to %LOCALAPPDATA%\\OfficeCLI."],"tags":["install","windows","powershell","network","execution-policy"],"backgroundTag":null,"analyzedSha":"1ced45e900782c5083ed550ddf328ee974e425e7","analyzedAt":"2026-08-13T13:01:07.193Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}