diff --git a/electron/main/utils/process.ts b/electron/main/utils/process.ts index e91986d5..d5cd6802 100644 --- a/electron/main/utils/process.ts +++ b/electron/main/utils/process.ts @@ -168,6 +168,7 @@ function fixPyvenvCfgPlaceholder(pyvenvCfgPath: string): boolean { } // Replace placeholder with actual path + // On Windows, path.join returns paths with backslashes, which matches our placeholder format content = content.replace(/\{\{PREBUILT_PYTHON_DIR\}\}/g, prebuiltPythonDir); fs.writeFileSync(pyvenvCfgPath, content); log.info(`[VENV] Fixed pyvenv.cfg placeholder with: ${prebuiltPythonDir}`); diff --git a/scripts/fix-venv-paths.js b/scripts/fix-venv-paths.js index 60251d73..f5d8afaa 100644 --- a/scripts/fix-venv-paths.js +++ b/scripts/fix-venv-paths.js @@ -77,7 +77,9 @@ function fixPyvenvCfg(venvPath, venvName) { // Replace with placeholder that will be substituted at runtime // {{PREBUILT_PYTHON_DIR}} will be replaced with the actual path on user's machine - const newHome = `{{PREBUILT_PYTHON_DIR}}/${cpythonDir}/${binDir}`; + // Use appropriate path separator for the platform + const pathSep = isWindowsPath ? '\\' : '/'; + const newHome = `{{PREBUILT_PYTHON_DIR}}${pathSep}${cpythonDir}${pathSep}${binDir}`; content = content.replace(/^home\s*=\s*.+$/m, `home = ${newHome}`); // Only write if content changed diff --git a/scripts/test-venv-fix.js b/scripts/test-venv-fix.js index 93f70239..cbd16998 100644 --- a/scripts/test-venv-fix.js +++ b/scripts/test-venv-fix.js @@ -51,13 +51,13 @@ function testVenvFix() { console.log(` ✅ PASS: Using placeholder correctly`); console.log(` Home: ${homePath}`); - // Verify placeholder format - const expectedPattern = /^\{\{PREBUILT_PYTHON_DIR\}\}\/cpython-[\w\.\-]+\/(bin|Scripts)$/; + // Verify placeholder format (accept both / and \ for cross-platform) + const expectedPattern = /^\{\{PREBUILT_PYTHON_DIR\}\}[\/\\]cpython-[\w\.\-]+[\/\\](bin|Scripts)$/; if (expectedPattern.test(homePath)) { console.log(` ✅ PASS: Placeholder format is correct`); } else { console.log(` ⚠️ WARNING: Placeholder format might be incorrect`); - console.log(` Expected: {{PREBUILT_PYTHON_DIR}}/cpython-X.Y.Z-platform/bin`); + console.log(` Expected: {{PREBUILT_PYTHON_DIR}}/cpython-X.Y.Z-platform/bin (or \\ on Windows)`); console.log(` Got: ${homePath}`); } } else {