Skip to content

npm install fails on Windows when user path contains spaces (Expand-Archive path splitting) #561

@tommylee1115

Description

@tommylee1115

Bug Description

npm install -g @googleworkspace/cli fails on Windows when the user's home directory path contains a space (e.g. C:\Users\Tommy Lee\...). The installer downloads the zip successfully but fails to extract it, leaving gws.exe missing.

Error

Error fetching release: An error occurred unzipping the artifact: 
stdout: ; stderr: New-Item : Access to the path 'Tommy' is denied.

PowerShell splits the path C:\Users\Tommy Lee\... at the space, treating Tommy as the destination path and Lee\... as a separate token.

Root Cause

In the generated binary-install.js, the Windows extraction uses spawnSync with tempFile and installDirectory passed as separate array arguments after the -Command scriptblock:

result = spawnSync("powershell.exe", [
  "-NoProfile",
  "-NonInteractive",
  "-Command",
  `& {
      param([string]$LiteralPath, [string]$DestinationPath)
      Expand-Archive -LiteralPath $LiteralPath -DestinationPath $DestinationPath -Force
  }`,
  tempFile,           // ← passed as separate arg
  this.installDirectory, // ← passed as separate arg
]);

PowerShell's -Command flag concatenates all arguments after it into a single string. So C:\Users\Tommy Lee\... becomes two tokens: C:\Users\Tommy and Lee\....

Fix

Embed the paths directly inside the -Command string with single quotes:

result = spawnSync("powershell.exe", [
  "-NoProfile",
  "-NonInteractive",
  "-Command",
  `Expand-Archive -LiteralPath '${tempFile}' -DestinationPath '${this.installDirectory}' -Force`,
]);

Single-quoted strings in PowerShell are treated as literals — the path is never split regardless of spaces.

Note on generated code

binary-install.js is generated by cargo-dist. The fix may need to be applied upstream in axodotdev/cargo-dist rather than in this repo directly.

Environment

  • OS: Windows 11
  • Username path: C:\Users\Tommy Lee\ (space in username)
  • npm version: global install via npm install -g @googleworkspace/cli
  • Package version: 0.18.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions