Skip to content

Commit 16caca3

Browse files
committed
fix: conda partial
1 parent fbf10f5 commit 16caca3

4 files changed

Lines changed: 221 additions & 54 deletions

File tree

src/features/terminal/shells/bash/bashStartup.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,9 @@ const regionEnd = '# <<< vscode python';
4646

4747
function getActivationContent(key: string): string {
4848
const lineSep = '\n';
49-
return [`if [ -n "$${key}" ] && [ "$TERM_PROGRAM" = "vscode" ]; then`, ` . "$${key}"`, 'fi'].join(lineSep);
49+
return [`if [ -n "$${key}" ] && [ "$TERM_PROGRAM" = "vscode" ]; then`, ` eval "$${key}" || true`, 'fi'].join(
50+
lineSep,
51+
);
5052
}
5153

5254
async function isStartupSetup(profile: string, key: string): Promise<ShellSetupState> {

src/features/terminal/shells/common/shellUtils.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,24 @@ function getCommandAsString(command: PythonCommandRunConfiguration[], shell: str
99
const args = cmd.args ?? [];
1010
parts.push(quoteArgs([normalizeShellPath(cmd.executable, shell), ...args]).join(' '));
1111
}
12+
if (shell === ShellConstants.PWSH) {
13+
return parts.map((p) => `(${p})`).join(` ${delimiter} `);
14+
}
1215
return parts.join(` ${delimiter} `);
1316
}
1417

1518
export function getShellCommandAsString(shell: string, command: PythonCommandRunConfiguration[]): string {
1619
switch (shell) {
20+
case ShellConstants.PWSH:
21+
return getCommandAsString(command, shell, ';');
1722
case ShellConstants.NU:
1823
return getCommandAsString(command, shell, ';');
1924
case ShellConstants.FISH:
2025
return getCommandAsString(command, shell, '; and');
2126
case ShellConstants.BASH:
2227
case ShellConstants.SH:
2328
case ShellConstants.ZSH:
24-
case ShellConstants.PWSH:
29+
2530
case ShellConstants.CMD:
2631
case ShellConstants.GITBASH:
2732
default:

src/features/terminal/shells/pwsh/pwshStartup.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,11 @@ function getActivationContent(): string {
7070
const lineSep = isWindows() ? '\r\n' : '\n';
7171
const activationContent = [
7272
`if (($env:TERM_PROGRAM -eq 'vscode') -and ($null -ne $env:${POWERSHELL_ENV_KEY})) {`,
73-
` Invoke-Expression $env:${POWERSHELL_ENV_KEY}`,
73+
' try {',
74+
` Invoke-Expression $env:${POWERSHELL_ENV_KEY}`,
75+
' } catch {',
76+
` Write-Error "Failed to activate Python environment: $_" -ErrorAction Continue`,
77+
' }',
7478
'}',
7579
].join(lineSep);
7680
return activationContent;

0 commit comments

Comments
 (0)