copilot-cli icon indicating copy to clipboard operation
copilot-cli copied to clipboard

Windows Ramdisk Directory does not exist or cannot be accessed

Open huanggefan opened this issue 6 months ago • 1 comments

Describe the bug

OS: Windows11 Node: node-v24.11.1-win-x64

When launching copilot under Ramdisk, I cannot access any directories.

When launching copilot under a non-Ramdisk environment, you can access directories normally, including those of Ramdisk.

Image Image Image Image

Affected version

after 1.0.43

Steps to reproduce the behavior

  1. Set up a Ramdisk, R:
  2. Start copilot under R:
  3. Have the Agent list the directory structure of any directory
  4. In any non-Ramdisk directory, such as C:, start copilot
  5. Have the Agent list the directory structure of any directory

Expected behavior

Ramdisk should not be a limiting factor for copilot

Additional context

https://sourceforge.net/projects/imdisk-toolkit/

huanggefan avatar May 27 '26 06:05 huanggefan

Same issue here, also hit through VS Code (Copilot agent session), which shows up as:

Error: (sendFailed) Request session.create failed with message: session construction failed: Directory does not exist or cannot be accessed: m:\a

Environment: Windows 11 Enterprise 10.0.26200, VS Code 1.141.0, Copilot extension 0.69.0 (built into VS Code) with bundled @github/copilot 1.0.73 / copilot-runtime.exe 1.0.92-4.unstable.r37397886721.gad270aa (the error string comes from the native runtime.node), ImDisk RAM disk (exFAT) mounted as M:

Root cause (I think): the directory exists, but it can't be canonicalized. ImDisk volumes aren't registered with the Windows Mount Manager, so GetFinalPathNameByHandleW with VOLUME_NAME_DOS fails. Node's fs.realpath.native and Rust's std::fs::canonicalize both depend on that call.

Call on a handle to M:\a Result
GetFinalPathNameByHandleW, VOLUME_NAME_DOS (0) ❌ ERROR_INVALID_FUNCTION (1)
GetFinalPathNameByHandleW, VOLUME_NAME_GUID (1) ❌ ERROR_PATH_NOT_FOUND (3)
GetFinalPathNameByHandleW, VOLUME_NAME_NT (2) ✅ \Device\ImDisk0\a
Same call on C:\Users, flags=0 (control) ✅ \\?\C:\Users
mountvol M: /L ❌ Incorrect function.
Test-Path M:\a ✅ True

PowerShell repro (no Node needed):

Add-Type @'
using System; using System.Runtime.InteropServices; using System.Text; using Microsoft.Win32.SafeHandles;
public static class FP {
 [DllImport("kernel32.dll", SetLastError=true, CharSet=CharSet.Unicode)] public static extern SafeFileHandle CreateFileW(string n,uint a,uint s,IntPtr sa,uint c,uint f,IntPtr t);
 [DllImport("kernel32.dll", SetLastError=true, CharSet=CharSet.Unicode)] public static extern uint GetFinalPathNameByHandleW(SafeFileHandle h,StringBuilder b,uint l,uint f);
 public static string Get(string p,uint flags){ var h=CreateFileW(p,0,7,IntPtr.Zero,3,0x02000000,IntPtr.Zero); if(h.IsInvalid) return "CreateFile ERR "+Marshal.GetLastWin32Error(); var sb=new StringBuilder(1024); var r=GetFinalPathNameByHandleW(h,sb,1024,flags); return r==0? "ERR "+Marshal.GetLastWin32Error() : sb.ToString(); }
}
'@
[FP]::Get('M:\a', 0)   # -> ERR 1
[FP]::Get('M:\a', 2)   # -> \Device\ImDisk0\a

Suggested fix: if native canonicalization fails but fs.stat succeeds, fall back to the JS fs.realpath (it walks components with lstat/readlink and doesn't need VOLUME_NAME_DOS) or to path.resolve(), instead of rejecting the directory. The error message should also say that canonicalization failed, not that the directory doesn't exist. This probably affects other non-Mount-Manager volumes too (some VeraCrypt, WinFsp and Dokan mounts). #2168 looks like the same root cause, hit through TEMP on a RAM disk.

herquan-docusign avatar Oct 09 '26 17:10 herquan-docusign