{"record":{"id":"748b32be0f5a3f99","repo":"langflow-ai/langflow","slug":"could-not-find-valid-windows-user-directory-in-wsl","errorCode":null,"errorMessage":"Could not find valid Windows user directory in WSL","messagePattern":"Could not find valid Windows user directory in WSL","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"src/backend/base/langflow/api/v1/mcp_projects.py","lineNumber":1279,"sourceCode":"\n                    # Fallback: try to find the Windows user directory\n                    users_dir = Path(\"/mnt/c/Users\")\n                    if users_dir.exists():\n                        # Get the first non-system user directory\n                        user_dirs = [\n                            d\n                            for d in users_dir.iterdir()\n                            if d.is_dir() and not d.name.startswith((\"Default\", \"Public\", \"All Users\"))\n                        ]\n                        if user_dirs:\n                            return user_dirs[0] / \"AppData\" / \"Roaming\" / \"Claude\" / \"claude_desktop_config.json\"\n\n                    if not Path(\"/mnt/c\").exists():\n                        msg = \"Windows C: drive not mounted at /mnt/c in WSL\"\n                        raise ValueError(msg)\n\n                    msg = \"Could not find valid Windows user directory in WSL\"\n                    raise ValueError(msg)\n                except (OSError, CalledProcessError) as e:\n                    await logger.awarning(\"Failed to determine Windows user path in WSL: %s\", str(e))\n                    msg = f\"Could not determine Windows Claude config path in WSL: {e!s}\"\n                    raise ValueError(msg) from e\n            # Regular Windows\n            return Path(os.environ[\"APPDATA\"]) / \"Claude\" / \"claude_desktop_config.json\"\n\n        msg = \"Unsupported operating system for Claude configuration\"\n        raise ValueError(msg)\n\n    msg = \"Unsupported client\"\n    raise ValueError(msg)\n\n\ndef remove_server_by_urls(config_data: dict, urls: Sequence[str] | str) -> tuple[dict, list[str]]:\n    \"\"\"Remove any MCP servers that use one of the specified URLs from config data.\n\n    Returns:","sourceCodeStart":1261,"sourceCodeEnd":1297,"githubUrl":"https://github.com/langflow-ai/langflow/blob/976ec789d2886a86de109c044d089d68e96c9a35/src/backend/base/langflow/api/v1/mcp_projects.py#L1261-L1297","documentation":"Raised by get_config_path() in Langflow's MCP projects API when resolving the Claude Desktop config file from inside WSL. The code first tries to run Windows cmd.exe to discover the Windows username, then falls back to scanning /mnt/c/Users for the first non-system directory. If /mnt/c exists but /mnt/c/Users is missing or contains only filtered system directories (Default*, Public, All Users), no path can be derived and this ValueError is thrown.","triggerScenarios":"Calling get_config_path(\"claude\") on Linux where 'microsoft' appears in platform.uname().release (WSL), the cmd.exe subprocess fails or returns empty output, /mnt/c exists, and either /mnt/c/Users does not exist or every entry under it starts with 'Default', 'Public', or 'All Users'. Also hit on WSL distros that mount the Windows drive at a non-standard location while /mnt/c happens to exist but is empty.","commonSituations":"Running Langflow in WSL2 with the Windows drive auto-mounted under a different path (custom wsl.conf automount root), a hardened WSL setup where /mnt/c is an empty stub directory, a Windows install whose user profiles live on a non-C drive, or a fresh Windows profile state where only default/public directories exist under C:\\Users.","solutions":["Verify /mnt/c/Users actually contains your Windows profile directory: ls /mnt/c/Users — if it is missing or only shows Default/Public, fix the WSL automount (check /etc/wsl.conf [automount] root setting) so C:\\ mounts at /mnt/c.","If your Windows user profile is on another drive or a custom mount point, create /mnt/c/Users/<yourname> visibility by mounting the real Windows drive at /mnt/c (sudo mount -t drvfs C: /mnt/c).","Run Langflow on native Windows or macOS where the Claude config path resolves directly, or run it in a plain Linux environment and configure an MCP client that is supported there (cursor, windsurf).","As a last resort, call the MCP config endpoints for a supported client, or patch get_config_path to accept an explicit path override via an environment variable (e.g. CLAUDE_CONFIG_PATH)."],"exampleFix":"# before: relies on /mnt/c/Users containing a real profile\n# (raises 'Could not find valid Windows user directory in WSL')\n\n# after: explicit override honored before WSL probing\ndef get_config_path(client: str) -> Path:\n    if client.lower() == \"claude\":\n        override = os.environ.get(\"CLAUDE_CONFIG_PATH\")\n        if override:\n            return Path(override)\n        ...","handlingStrategy":"validation","validationCode":"from pathlib import Path\nimport platform\n\ndef wsl_claude_config_resolvable() -> bool:\n    \"\"\"Pre-check the WSL fallback conditions get_config_path('claude') needs.\"\"\"\n    if platform.system() != \"Linux\" or \"microsoft\" not in platform.uname().release.lower():\n        return True  # not WSL; other code path applies\n    users = Path(\"/mnt/c/Users\")\n    if not users.is_dir():\n        return False\n    return any(\n        d.is_dir() and not d.name.startswith((\"Default\", \"Public\", \"All Users\"))\n        for d in users.iterdir()\n    )","typeGuard":null,"tryCatchPattern":"try:\n    path = await get_config_path(\"claude\")\nexcept ValueError as e:\n    if \"Windows user directory\" in str(e) or \"Windows Claude config path\" in str(e):\n        # fall back to asking the user for the config path explicitly\n        path = Path(user_supplied_claude_config_path)\n    else:\n        raise","preventionTips":["Keep /etc/wsl.conf automount pointing at /mnt/c so /mnt/c/Users is the real Windows profile tree","On custom WSL mounts, symlink or bind-mount the real Windows Users directory under /mnt/c/Users","Surface the availability-check endpoint result (installed/available flags) in the UI before offering Claude config actions on WSL"],"tags":["mcp","wsl","claude-desktop","filesystem","path-resolution"],"backgroundTag":null,"analyzedSha":"976ec789d2886a86de109c044d089d68e96c9a35","analyzedAt":"2026-08-14T18:23:12.227Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}