MCPcopy
hub / github.com/codeaashu/claude-code / getIdeLockfilesPaths

Function getIdeLockfilesPaths

src/utils/ide.ts:462–515  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

460 * stat loop compounded startup latency.
461 */
462export async function getIdeLockfilesPaths(): Promise<string[]> {
463 const paths: string[] = [join(getClaudeConfigHomeDir(), 'ide')]
464
465 if (getPlatform() !== 'wsl') {
466 return paths
467 }
468
469 // For Windows, use heuristics to find the potential paths.
470 // See https://learn.microsoft.com/en-us/windows/wsl/filesystems
471
472 const windowsHome = await getWindowsUserProfile()
473
474 if (windowsHome) {
475 const converter = new WindowsToWSLConverter(process.env.WSL_DISTRO_NAME)
476 const wslPath = converter.toLocalPath(windowsHome)
477 paths.push(resolve(wslPath, '.claude', 'ide'))
478 }
479
480 // Construct the path based on the standard Windows WSL locations
481 // This can fail if the current user does not have "List folder contents" permission on C:\Users
482 try {
483 const usersDir = '/mnt/c/Users'
484 const userDirs = await getFsImplementation().readdir(usersDir)
485
486 for (const user of userDirs) {
487 // Skip files (e.g. desktop.ini) — readdir on a file path throws ENOTDIR.
488 // isFsInaccessible covers ENOTDIR, but pre-filtering here avoids the
489 // cost of attempting to readdir non-directories. Symlinks are kept since
490 // Windows creates junction points for user profiles.
491 if (!user.isDirectory() && !user.isSymbolicLink()) {
492 continue
493 }
494 if (
495 user.name === 'Public' ||
496 user.name === 'Default' ||
497 user.name === 'Default User' ||
498 user.name === 'All Users'
499 ) {
500 continue // Skip system directories
501 }
502 paths.push(join(usersDir, user.name, '.claude', 'ide'))
503 }
504 } catch (error: unknown) {
505 if (isFsInaccessible(error)) {
506 // Expected on WSL when C: drive is not mounted or user lacks permissions
507 logForDebugging(
508 `WSL IDE lockfile path detection failed (${error.code}): ${errorMessage(error)}`,
509 )
510 } else {
511 logError(error)
512 }
513 }
514 return paths
515}
516
517/**
518 * Cleans up stale IDE lockfiles

Callers 1

getSortedIdeLockfilesFunction · 0.85

Calls 9

toLocalPathMethod · 0.95
getPlatformFunction · 0.85
getFsImplementationFunction · 0.85
isFsInaccessibleFunction · 0.85
logForDebuggingFunction · 0.85
resolveFunction · 0.70
errorMessageFunction · 0.70
logErrorFunction · 0.70
pushMethod · 0.45

Tested by

no test coverage detected