Environment:20000419 Fauxnix Windows PowerShell 5 1
| Knowledge Sources | |
|---|---|
| Domains | Infrastructure, Windows, Shell |
| Last Updated | 2026-10-26 00:00 GMT |
Overview
Windows environment with PowerShell 5.1 (Desktop, default) or PowerShell 7 (Core, opt-in via `FAUXNIX_PS=pwsh`) as the native execution backend.
Description
Fauxnix translates bash-style commands to PowerShell and executes them natively — no WSL or VM. The default host is Windows PowerShell 5.1, resolved via the trusted `SystemRoot\System32\WindowsPowerShell\v1.0\powershell.exe` path. PowerShell 7 (Core) is opt-in via the `FAUXNIX_PS=pwsh` environment variable, resolved through eligible absolute PATH entries (excluding the current working directory). The host is started with `-NoProfile -NonInteractive -ExecutionPolicy Bypass`. A resident host process persists across calls within a session, framing I/O as UTF-8 JSON lines with base64-encoded stdout/stderr to survive PowerShell 5.1's UTF-16LE pipe encoding.
Usage
Use this environment for any fauxnix command execution — the CLI default verb, MCP server tool calls, the bash.exe facade, and the differential runner. The `translate` verb is the only subcommand that does not require PowerShell (pure AST-to-PowerShell code generation). On non-Windows hosts without PowerShell on PATH, the bash tool returns exit code 127 with an actionable error.
System Requirements
| Category | Requirement | Notes |
|---|---|---|
| OS | Windows 10/11 | PowerShell 5.1 ships with Windows; not available on Linux/macOS |
| Hardware | Any Windows-capable machine | No GPU required |
| Disk | ~50 MB | Temp files for session state (cwd, env, scripts) |
Dependencies
System Packages
- Windows PowerShell 5.1 (default; pre-installed on Windows 10/11)
- PowerShell 7+ (optional; opt-in via `FAUXNIX_PS=pwsh`)
Environment Variables
- `SystemRoot` — Must be set to a drive-absolute path (e.g. `C:\Windows`); used to locate the trusted PowerShell executable
- `FAUXNIX_PS` — Optional: `powershell` / `powershell.exe` (Desktop) or `pwsh` / `pwsh.exe` (Core); unset = default Desktop
- `FAUXNIX_NATIVE_ENCODING` — Optional: `utf8` (default) or `ansi` for GBK admin tools
- `FAUXNIX_HOST_READY_TIMEOUT_MS` — Optional: host ready timeout in ms (minimum 1000, default 30000)
- `FAUXNIX_TOOL_NAME` — Optional: MCP tool name override (default `bash`)
Credentials
No external credentials required. All environment variables are configuration knobs, not secrets.
Quick Install
# PowerShell 5.1 ships with Windows — no install needed for the default host
# To opt into PowerShell 7 (Core):
winget install Microsoft.PowerShell
# Then set the environment variable:
set FAUXNIX_PS=pwsh
# Install fauxnix:
npm install -g fauxnix-cli
Code Evidence
Host resolution from `src/powershell.ts:125-154`:
export function resolvePowerShell(
env: NodeJS.ProcessEnv = process.env,
options: PowerShellResolveOptions = {},
): PowerShellSelection {
const requested = envValue(env, 'FAUXNIX_PS')?.trim();
const exists = options.exists ?? existsSync;
const cwd = options.cwd ?? process.cwd();
if (!requested) {
return desktopSelection(env, false, undefined, exists);
}
switch (requested.toLowerCase()) {
case 'powershell':
case 'powershell.exe':
return desktopSelection(env, true, requested, exists);
case 'pwsh':
case 'pwsh.exe':
return coreSelection(env, requested, cwd, exists);
default:
return { executable: '', expectedEdition: 'Desktop', configured: true, requested,
error: `fauxnix: invalid FAUXNIX_PS=${JSON.stringify(requested)}; expected "powershell" or "pwsh". Unset it to use Windows PowerShell 5.1.` };
}
}
Trusted system path from `src/powershell.ts:48-82`:
function desktopSelection(env, configured, requested, exists): PowerShellSelection {
const systemRoot = envValue(env, 'SystemRoot')?.trim();
if (!systemRoot || !/^[a-z]:[\\/]/i.test(systemRoot)) {
return { executable: '', expectedEdition: 'Desktop', configured, requested,
error: 'fauxnix: cannot resolve Windows PowerShell safely because SystemRoot is missing or not drive-absolute.' };
}
const executable = win32.join(systemRoot, 'System32', 'WindowsPowerShell', 'v1.0', 'powershell.exe');
if (!exists(executable)) {
return { executable, expectedEdition: 'Desktop', configured, requested,
error: `fauxnix: Windows PowerShell not found at trusted system path ${executable}.` };
}
return { executable, expectedEdition: 'Desktop', configured, requested };
}
Host launch arguments from `src/powershell.ts:4-9`:
export const POWERSHELL_ARGS = [
'-NoProfile',
'-NonInteractive',
'-ExecutionPolicy',
'Bypass',
] as const;
Common Errors
| Error Message | Cause | Solution |
|---|---|---|
| `fauxnix: cannot resolve Windows PowerShell safely because SystemRoot is missing or not drive-absolute.` | `SystemRoot` env var unset or not drive-absolute | Ensure `SystemRoot` is set (default on Windows); run fauxnix on Windows |
| `fauxnix: Windows PowerShell not found at trusted system path ...` | `powershell.exe` missing from `SystemRoot\System32\WindowsPowerShell\v1.0\` | Repair Windows PowerShell installation or set `FAUXNIX_PS=pwsh` |
| `fauxnix: invalid FAUXNIX_PS=...; expected "powershell" or "pwsh"` | Unrecognized `FAUXNIX_PS` value | Set `FAUXNIX_PS` to `powershell` or `pwsh`, or unset it |
| `fauxnix: pwsh.exe not found in eligible PATH entries` | PowerShell 7 not installed in an absolute PATH directory | Install PowerShell 7 or unset `FAUXNIX_PS` to use 5.1 |
Compatibility Notes
- PowerShell 5.1 (Desktop): Default host; always available on Windows 10/11. Resolved via trusted `SystemRoot` path, never via PATH search, to prevent spoofing.
- PowerShell 7 (Core): Opt-in via `FAUXNIX_PS=pwsh`; resolved through absolute PATH entries only — the current working directory is excluded to prevent DLL planting.
- Linux/macOS: PowerShell not available; `fauxnix check` and the bash tool return exit 127. The `translate` verb works without PowerShell.
- Encoding: PS 5.1 has a single console-encoding knob; UTF-8 dev tools and GBK admin tools cannot both decode cleanly. See `FAUXNIX_NATIVE_ENCODING`.
Related Pages
- Implementation:20000419_Fauxnix_runCli
- Implementation:20000419_Fauxnix_translateCommandList
- Implementation:20000419_Fauxnix_FauxnixSession
- Implementation:20000419_Fauxnix_Output_Normalization
- Implementation:20000419_Fauxnix_PowerShellHost
- Implementation:20000419_Fauxnix_Command_Registry
- Implementation:20000419_Fauxnix_startMcpServer
- Implementation:20000419_Fauxnix_resolvePowerShell
- Implementation:20000419_Fauxnix_Differential_Runner
- Implementation:20000419_Fauxnix_buildLauncher
- Implementation:20000419_Fauxnix_installClaudeShell
- Implementation:20000419_Fauxnix_runFacade
- Implementation:20000419_Fauxnix_tryClaudeCodeAdapter