From 898ca7f7794fc086c0a80098e763cb42dd72eeb7 Mon Sep 17 00:00:00 2001 From: Vitaly Legchilkin Date: Thu, 15 Jan 2026 21:02:55 +0100 Subject: [PATCH] PY-86007 Run the Hatch CLI from the first existing parent folder in the path. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Initially, the ~/PycharmProjects folder does not exist. When we create the first project at ~/PycharmProjects/PythonProject, we can’t run Hatch from its parent folder and have to detect the actual root path instead. GitOrigin-RevId: 89024b6c442ee46051bc0492609eab5928807ded --- .../src/com/jetbrains/python/sdk/add/v2/hatch/HatchViewModel.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/src/com/jetbrains/python/sdk/add/v2/hatch/HatchViewModel.kt b/python/src/com/jetbrains/python/sdk/add/v2/hatch/HatchViewModel.kt index 2fcad116dc24..90a32df1f05d 100644 --- a/python/src/com/jetbrains/python/sdk/add/v2/hatch/HatchViewModel.kt +++ b/python/src/com/jetbrains/python/sdk/add/v2/hatch/HatchViewModel.kt @@ -72,7 +72,7 @@ class HatchViewModel

( val projectPath = projectPathFlows.projectPathWithDefault.first() val hatchExecutablePath = (hatchExecutable as? BinOnEel)?.path ?: return@withContext Result.failure(HatchUIError.HatchExecutablePathIsNotValid(hatchExecutable.toString())) - val hatchWorkingDirectory = if (projectPath.isDirectory()) projectPath else projectPath.parent + val hatchWorkingDirectory = generateSequence(projectPath) { it.parent }.firstOrNull { it.isDirectory() } val hatchService = hatchWorkingDirectory.getHatchService(hatchExecutablePath).getOr { return@withContext it } val hatchEnvironments = hatchService.findVirtualEnvironments().getOr { return@withContext it }