Skip to content

Windows installer fails when $env:TEMP uses an 8.3 short path #838

Closed

Description

@coordx3906

Description

The Windows installer aborts while cleaning up its temporary directory when $env:TEMP points to an 8.3 short path.

My Windows user profile directory contains a space:

C:\Users\David X

In the affected PowerShell session, the temporary directory resolves through the corresponding short path:

C:\Users\DAVIDX~1\...

The prebuilt binary downloads and passes SHA-256 verification successfully, but the installer then fails at the Remove-Item call in its finally block.

This is the normal prebuilt installation path. I did not use -BuildFromSource.

Steps to reproduce

Run the standard installer in the affected environment:

irm https://jcode.sh/install.ps1 | iex

Output:

PS C:\Users\David X> irm https://jcode.sh/install.ps1 | iex
Fetching latest release...
Installing jcode v0.68.0
  launcher: C:\Users\David X\AppData\Local\jcode\bin\jcode.exe
Downloading jcode-windows-x86_64.exe from https://github.com/1jehuang/jcode/releases/download/v0.68.0...
Verified SHA256: jcode-windows-x86_64.exe
Remove-Item:
Line |
1094 |      Remove-Item -Path $TempDir -Recurse -Force -ErrorAction SilentlyC …
     |      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     | An object at the specified path C:\Users\DAVIDX~1 does not exist.

Expected behavior

The installer should complete successfully even when $env:TEMP uses an 8.3 short path.

A failure to clean up the temporary directory should also not abort an otherwise successful installation or prevent subsequent steps such as updating the user PATH.

Cause

The installer creates its temporary directory from $env:TEMP:

$TempDir = Join-Path $env:TEMP "jcode-install-$(Get-Random)"
New-Item -ItemType Directory -Path $TempDir -Force | Out-Null

It later removes that directory directly by path:

finally {
    Remove-Item -Path $TempDir -Recurse -Force -ErrorAction SilentlyContinue
}

PowerShell has an existing FileSystemProvider bug where Remove-Item -Path can fail to normalize paths under $env:TEMP when an 8.3 short path is involved:

PowerShell/PowerShell#21070

The upstream issue produces essentially the same error:

An object at the specified path C:\Users\XXXXXX~1 does not exist.

Confirmed workaround

Overriding TEMP and TMP with the long path in the current PowerShell process allows the installation to complete successfully:

$oldTemp = $env:TEMP
$oldTmp  = $env:TMP

$longTemp = Join-Path $env:LOCALAPPDATA "Temp"
New-Item -ItemType Directory -LiteralPath $longTemp -Force | Out-Null

try {
    $env:TEMP = $longTemp
    $env:TMP  = $longTemp

    irm https://jcode.sh/install.ps1 | iex
}
finally {
    $env:TEMP = $oldTemp
    $env:TMP  = $oldTmp
}

With this workaround, jcode installs successfully.

Possible fix

The workaround documented in the upstream PowerShell issue is to resolve the item first and pipe the resulting object to Remove-Item:

Get-Item -LiteralPath $TempDir -ErrorAction SilentlyContinue |
    Remove-Item -Recurse -Force -ErrorAction SilentlyContinue

This could replace the current direct Remove-Item -Path $TempDir cleanup.

Alternatively, cleanup could use a .NET filesystem API, with cleanup errors handled separately so that they do not abort the remaining installation steps.

Activity

  1. added
    bug
    triage: reproducible
    autonomous: clear
    on Aug 7, 2026
  2. 1jehuang commented on Aug 8, 2026

    @1jehuang
    Owner

    Fixed on agent/triage-2026-08-07 in commit 46173b2a4. Cleanup now resolves the temporary directory with Get-Item -LiteralPath before removal, avoiding the PowerShell 8.3-path bug. PowerShell parsing, focused regression checks, and the short-path cleanup exercise pass.

    --- — Jcode agent (automated triage), on behalf of @1jehuang

  3. added
    triage: fixed-pending-release
    on Aug 8, 2026
  4. 1jehuang commented on Aug 8, 2026

    @1jehuang
    Owner

    The validated fix is now available for review in #841 on a clean branch based on the public default branch.

    --- — Jcode agent (automated triage), on behalf of @1jehuang

  5. added a commit that references this issue on Aug 8, 2026
    35e9e4b
  6. added a commit that references this issue on Aug 15, 2026
    a8e0afd
  7. added 5 commits that reference this issue on Aug 30, 2026
    058d7d4
    23bbc44
    0960775
    de72a5b
    d8b6bab
  8. added a commit that references this issue on Sep 18, 2026
    b7b5977
  9. added a commit that references this issue on Oct 9, 2026
    e2e161b
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    autonomous: clearbugtriage: fixed-pending-releasetriage: reproducible

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions