diff --git a/python/services/system-python/tests/com/intellij/python/junit5Tests/env/systemPython/impl/SystemPythonRootsFixer.kt b/python/services/system-python/tests/com/intellij/python/junit5Tests/env/systemPython/impl/SystemPythonRootsFixer.kt index 0239f5adbb93..c766116d8e8f 100644 --- a/python/services/system-python/tests/com/intellij/python/junit5Tests/env/systemPython/impl/SystemPythonRootsFixer.kt +++ b/python/services/system-python/tests/com/intellij/python/junit5Tests/env/systemPython/impl/SystemPythonRootsFixer.kt @@ -5,16 +5,23 @@ import com.intellij.ide.ApplicationInitializedListener import com.intellij.openapi.application.ApplicationManager import com.intellij.openapi.vfs.newvfs.impl.VfsRootAccess import com.intellij.python.community.services.systemPython.SystemPythonService -import org.jetbrains.annotations.TestOnly +import java.nio.file.FileSystemException import kotlin.io.path.pathString -@TestOnly internal class SystemPythonRootsFixer : ApplicationInitializedListener { override suspend fun execute() { val disposable = ApplicationManager.getApplication() val pythonDirs = SystemPythonService() .findSystemPythons() - .map { it.pythonBinary.toRealPath().parent.pathString } + .map { + try { + // It might throw FSE on Windows for pythons installed from store, see WinAppxTools + it.pythonBinary.toRealPath() + } + catch (_: FileSystemException) { + it.pythonBinary + }.parent.pathString + } .toTypedArray() VfsRootAccess.allowRootAccess(disposable, *pythonDirs) }