Skip to content

Commit cdb3426

Browse files
committed
Fix PowerShell#532: DEVPATH env variable not being set for integrated console
This change adds a workaround for setting the DEVPATH environment variable when launching the language server inside of the integrated terminal UI. This environment variable needs to be set for Windows PowerShell development builds but it currently can't because there's no API parameter for passing along environment variables. The workaround is to generate a batch script which can set the environment variable before launching PowerShell.
1 parent 899377a commit cdb3426

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

src/session.ts

+12-8
Original file line numberDiff line numberDiff line change
@@ -284,15 +284,19 @@ export class SessionManager {
284284
"-Command",
285285
"& '" + startScriptPath + "' " + startArgs);
286286

287-
// Set DEVPATH environment variable if necessary
288287
if (isWindowsDevBuild) {
289-
// The development build looks for this environment variable to
290-
// know where to find its assemblies
291-
process.env.DEVPATH = path.dirname(powerShellExePath);
292-
}
293-
else {
294-
// It's safe to delete this variable even if it doesn't exist
295-
delete process.env.DEVPATH;
288+
// Windows PowerShell development builds need the DEVPATH environment
289+
// variable set to the folder where development binaries are held
290+
291+
// NOTE: This batch file approach is needed temporarily until VS Code's
292+
// createTerminal API gets an argument for setting environment variables
293+
// on the launched process.
294+
var batScriptPath = path.resolve(__dirname, '../sessions/powershell.bat');
295+
fs.writeFileSync(
296+
batScriptPath,
297+
`@set DEVPATH=${path.dirname(powerShellExePath)}\r\n@${powerShellExePath} %*`);
298+
299+
powerShellExePath = batScriptPath;
296300
}
297301

298302
// Make sure no old session file exists

0 commit comments

Comments
 (0)