Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions news/2 Fixes/18455.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix `invalid patch string` error when using conda.
4 changes: 2 additions & 2 deletions src/client/common/process/rawProcessApis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,8 +169,8 @@ function filterOutputUsingCondaRunMarkers(stdout: string) {
}

function removeCondaRunMarkers(out: string) {
out = out.replace('>>>PYTHON-EXEC-OUTPUT', '');
return out.replace('<<<PYTHON-EXEC-OUTPUT', '');
out = out.replace('>>>PYTHON-EXEC-OUTPUT\r\n', '').replace('>>>PYTHON-EXEC-OUTPUT\n', '');
return out.replace('<<<PYTHON-EXEC-OUTPUT\r\n', '').replace('<<<PYTHON-EXEC-OUTPUT\n', '');
}

export function execObservable(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,7 @@ export class Conda {
} else {
args.push('-p', env.prefix);
}
return [this.command, 'run', ...args, '--no-capture-output', 'python', OUTPUT_MARKER_SCRIPT];
return [this.command, 'run', ...args, '--no-capture-output', '--live-stream', 'python', OUTPUT_MARKER_SCRIPT];
}

/**
Expand Down
88 changes: 80 additions & 8 deletions src/test/common/process/pythonEnvironment.unit.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -291,8 +291,26 @@ suite('CondaEnvironment', () => {

expect(result).to.deep.equal({
command: condaFile,
args: ['run', '-n', condaInfo.name, '--no-capture-output', 'python', OUTPUT_MARKER_SCRIPT, ...args],
python: [condaFile, 'run', '-n', condaInfo.name, '--no-capture-output', 'python', OUTPUT_MARKER_SCRIPT],
args: [
'run',
'-n',
condaInfo.name,
'--no-capture-output',
'--live-stream',
'python',
OUTPUT_MARKER_SCRIPT,
...args,
],
python: [
condaFile,
'run',
'-n',
condaInfo.name,
'--no-capture-output',
'--live-stream',
'python',
OUTPUT_MARKER_SCRIPT,
],
pythonExecutable: pythonPath,
});
});
Expand All @@ -305,8 +323,26 @@ suite('CondaEnvironment', () => {

expect(result).to.deep.equal({
command: condaFile,
args: ['run', '-p', condaInfo.path, '--no-capture-output', 'python', OUTPUT_MARKER_SCRIPT, ...args],
python: [condaFile, 'run', '-p', condaInfo.path, '--no-capture-output', 'python', OUTPUT_MARKER_SCRIPT],
args: [
'run',
'-p',
condaInfo.path,
'--no-capture-output',
'--live-stream',
'python',
OUTPUT_MARKER_SCRIPT,
...args,
],
python: [
condaFile,
'run',
'-p',
condaInfo.path,
'--no-capture-output',
'--live-stream',
'python',
OUTPUT_MARKER_SCRIPT,
],
pythonExecutable: pythonPath,
});
});
Expand All @@ -315,8 +351,26 @@ suite('CondaEnvironment', () => {
const condaInfo = { name: 'foo', path: 'bar' };
const expected = {
command: condaFile,
args: ['run', '-n', condaInfo.name, '--no-capture-output', 'python', OUTPUT_MARKER_SCRIPT, ...args],
python: [condaFile, 'run', '-n', condaInfo.name, '--no-capture-output', 'python', OUTPUT_MARKER_SCRIPT],
args: [
'run',
'-n',
condaInfo.name,
'--no-capture-output',
'--live-stream',
'python',
OUTPUT_MARKER_SCRIPT,
...args,
],
python: [
condaFile,
'run',
'-n',
condaInfo.name,
'--no-capture-output',
'--live-stream',
'python',
OUTPUT_MARKER_SCRIPT,
],
pythonExecutable: pythonPath,
};
const env = await createCondaEnv(condaInfo, pythonPath, processService.object, fileSystem.object);
Expand All @@ -330,8 +384,26 @@ suite('CondaEnvironment', () => {
const condaInfo = { name: '', path: 'bar' };
const expected = {
command: condaFile,
args: ['run', '-p', condaInfo.path, '--no-capture-output', 'python', OUTPUT_MARKER_SCRIPT, ...args],
python: [condaFile, 'run', '-p', condaInfo.path, '--no-capture-output', 'python', OUTPUT_MARKER_SCRIPT],
args: [
'run',
'-p',
condaInfo.path,
'--no-capture-output',
'--live-stream',
'python',
OUTPUT_MARKER_SCRIPT,
...args,
],
python: [
condaFile,
'run',
'-p',
condaInfo.path,
'--no-capture-output',
'--live-stream',
'python',
OUTPUT_MARKER_SCRIPT,
],
pythonExecutable: pythonPath,
};
const env = await createCondaEnv(condaInfo, pythonPath, processService.object, fileSystem.object);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -481,14 +481,14 @@ suite('Conda and its environments are located correctly', () => {
expect(args).to.not.equal(undefined);
assert.deepStrictEqual(
args,
['conda', 'run', '-n', 'envName', '--no-capture-output', 'python', OUTPUT_MARKER_SCRIPT],
['conda', 'run', '-n', 'envName', '--no-capture-output', '--live-stream', 'python', OUTPUT_MARKER_SCRIPT],
'Incorrect args for case 1',
);

args = await conda?.getRunPythonArgs({ name: '', prefix: 'envPrefix' });
assert.deepStrictEqual(
args,
['conda', 'run', '-p', 'envPrefix', '--no-capture-output', 'python', OUTPUT_MARKER_SCRIPT],
['conda', 'run', '-p', 'envPrefix', '--no-capture-output', '--live-stream', 'python', OUTPUT_MARKER_SCRIPT],
'Incorrect args for case 2',
);
});
Expand Down