Fix WSL for systems that don't have windows paths (#5480)

Attempt to fix #5476. As far as I can tell `process.env.winTmp` is
needed just for windows executables and WslVcCompiler. It should be
possible to just ignore the exec error and continue. If for some reason
the user doesn't have windows paths in their WSL but does want to run
windows executables they can pass `-tmpDir`.
This commit is contained in:
Jeremy Rifkin
2023-09-16 15:59:26 -04:00
committed by GitHub
parent 1c08f17a46
commit fb147126e8
4 changed files with 13 additions and 7 deletions

12
app.ts
View File

@@ -156,10 +156,14 @@ if (opts.tmpDir) {
} else if (process.env.wsl) {
// Dec 2017 preview builds of WSL include /bin/wslpath; do the parsing work for now.
// Parsing example %TEMP% is C:\Users\apardoe\AppData\Local\Temp
const windowsTemp = child_process.execSync('cmd.exe /c echo %TEMP%').toString().replaceAll('\\', '/');
const driveLetter = windowsTemp.substring(0, 1).toLowerCase();
const directoryPath = windowsTemp.substring(2).trim();
process.env.winTmp = path.join('/mnt', driveLetter, directoryPath);
try {
const windowsTemp = child_process.execSync('cmd.exe /c echo %TEMP%').toString().replaceAll('\\', '/');
const driveLetter = windowsTemp.substring(0, 1).toLowerCase();
const directoryPath = windowsTemp.substring(2).trim();
process.env.winTmp = path.join('/mnt', driveLetter, directoryPath);
} catch (e) {
logger.warn('Unable to invoke cmd.exe to get windows %TEMP% path.');
}
}
const distPath = utils.resolvePathFromAppRoot('.');