Skip to content

Windows: Terminal panel uses \\?\ extended-length path prefix, breaking cmd.exe child processes (npm, npx, etc.) #108

Description

@matthewdonsemail-lab

Description

The terminal panel in Berd spawns PowerShell with the session's working_dir set to the repository path. When the path is under C:\Users\... (or any long path), PowerShell resolves it to the Win32 extended-length path format \\?\C:\Users\.... This breaks any child process that spawns cmd.exe — including npm, npx, and many Node.js toolchains.

Symptoms

  1. Terminal prompt shows the extended-length path format:

    PS Microsoft.PowerShell.Core\FileSystem::\\?\C:\Users\0\.buzz\REPOS\inferencesaver>
    
  2. Running npm run dev (or any npm/npx command) fails with:

    '\\?\C:\Users\0\.buzz\REPOS\inferencesaver'
    CMD.EXE was started with the above path as the current directory.
    UNC paths are not supported.  Defaulting to Windows directory.
    
  3. next dev crashes with:

    Error: EISDIR: illegal operation on a directory, lstat 'C:'
    
  4. npm run dev:docs fails with:

    Could not read package.json: Error: ENOENT: no such file or directory, open 'C:\Windows\package.json'
    

Root Cause

  • Berd's terminal panel spawns PowerShell with the session's working_dir as the initial CWD
  • When the working directory is a normal Windows path like C:\Users\0\.buzz\REPOS\inferencesaver, PowerShell's FileSystem provider resolves it to the extended-length path format \\?\C:\Users\...
  • cmd.exe (spawned by npm/npx) does not support \\? UNC paths as a CWD and falls back to C:\Windows
  • This causes all downstream Node.js processes to fail because they're running from the wrong directory
  • Even Git Bash (C:\Program Files\Git\bin\bash.exe --login) spawned from this terminal inherits the \\? CWD environment

Workaround

Run cd C:\Users\0\.buzz\REPOS\inferencesaver once in the terminal to reset the PowerShell provider path to the normal format. This is not obvious and wastes time every time a new terminal is opened.

Affected Environment

  • Berd version: v0.6.2
  • OS: Windows 10 (build 26100)
  • Shell: PowerShell 5.1 (default Windows PowerShell)
  • Node.js: v24.18.1

Suggested Fix

When spawning the terminal, Berd should normalize the working_dir path to its non-extended-length form (C:\... instead of \\?\C:\...) before passing it to PowerShell. This could be done by:

  1. Passing the path without the \\? prefix when spawning the shell process
  2. Or, if using PowerShell, prepending a cd to the non-extended path in the initial command
  3. Or, using Git Bash or Windows Terminal as an alternative shell option

Impact

This is a significant UX issue for any Windows user of Berd who works with Node.js projects, Python projects, or any toolchain that spawns cmd.exe subprocesses. It makes the terminal unusable out of the box for running dev servers, builds, and package managers.

Activity

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions