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
7 changes: 6 additions & 1 deletion src/dotnet-interactive-vscode-ads/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,11 @@
],
"description": "Command and arguments used to start a notebook session."
},
"dotnet-interactive.kernelEnvironmentVariables": {
"type": "object",
"default": {},
"description": "Environment variables to set when starting a notebook session."
},
"dotnet-interactive.notebookParserArgs": {
"type": "array",
"default": [
Expand Down Expand Up @@ -529,4 +534,4 @@
"uuid": "8.3.2",
"rxjs": "7.5.6"
}
}
}
4 changes: 3 additions & 1 deletion src/dotnet-interactive-vscode-common/src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ export async function activate(context: vscode.ExtensionContext) {
}

async function kernelChannelCreator(notebookUri: vscodeLike.Uri): Promise<KernelCommandAndEventChannel> {
const config = vscode.workspace.getConfiguration('dotnet-interactive');
const launchOptions = await getInteractiveLaunchOptions();
if (!launchOptions) {
throw new Error(`Unable to get interactive launch options. Please see the '${diagnosticsChannel.getName()}' output window for details.`);
Expand All @@ -120,7 +121,8 @@ export async function activate(context: vscode.ExtensionContext) {

const workspaceFolderUris = vscode.workspace.workspaceFolders?.map(folder => folder.uri) || [];
const workingDirectory = getWorkingDirectoryForNotebook(notebookUri, workspaceFolderUris, fallbackWorkingDirectory);
const processStart = processArguments(argsTemplate, workingDirectory, DotNetPathManager.getDotNetPath(), launchOptions!.workingDirectory);
const environmentVariables = config.get<{ [key: string]: string }>('kernelEnvironmentVariables');
const processStart = processArguments(argsTemplate, workingDirectory, DotNetPathManager.getDotNetPath(), launchOptions!.workingDirectory, environmentVariables);
let notification = {
displayError: async (message: string) => { await vscode.window.showErrorMessage(message, { modal: false }); },
displayInfo: async (message: string) => { await vscode.window.showInformationMessage(message, { modal: false }); },
Expand Down
1 change: 1 addition & 0 deletions src/dotnet-interactive-vscode-common/src/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export interface ProcessStart {
command: string;
args: Array<string>;
workingDirectory: string;
env: { [key: string]: string };
}

// interactive acquisition
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ export class StdioDotnetInteractiveChannel implements DotnetInteractiveChannel {
let args = processStart.args;
// launch the process
this.diagnosticChannel.appendLine(`Starting kernel for '${notebookPath}' using: ${processStart.command} ${args.join(' ')}`);
let childProcess = cp.spawn(processStart.command, args, { cwd: processStart.workingDirectory });
let childProcess = cp.spawn(processStart.command, args, { cwd: processStart.workingDirectory, env: processStart.env });
let pid = childProcess.pid;

this.childProcess = childProcess;
Expand Down
5 changes: 3 additions & 2 deletions src/dotnet-interactive-vscode-common/src/utilities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ export async function getDotNetVersionOrThrow(dotnetPath: string, outputChannel:
return dotnetVersion;
}

export function processArguments(template: { args: Array<string>, workingDirectory: string }, workingDirectory: string, dotnetPath: string, globalStoragePath: string): ProcessStart {
export function processArguments(template: { args: Array<string>, workingDirectory: string }, workingDirectory: string, dotnetPath: string, globalStoragePath: string, env?: { [key: string]: string }): ProcessStart {
let map: { [key: string]: string } = {
'dotnet_path': dotnetPath,
'global_storage_path': globalStoragePath,
Expand All @@ -100,7 +100,8 @@ export function processArguments(template: { args: Array<string>, workingDirecto
return {
command: processed[0],
args: [...processed.slice(1)],
workingDirectory: performReplacement(template.workingDirectory, map)
workingDirectory: performReplacement(template.workingDirectory, map),
env: env || {},
};
}

Expand Down
3 changes: 2 additions & 1 deletion src/dotnet-interactive-vscode-common/tests/misc.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,8 @@ describe('Miscellaneous tests', () => {
'--working-dir',
'replacement-working-dir'
],
workingDirectory: 'replacement-global-storage-path'
workingDirectory: 'replacement-global-storage-path',
env: {}
});
});

Expand Down
7 changes: 6 additions & 1 deletion src/dotnet-interactive-vscode-insiders/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,11 @@
],
"description": "Command and arguments used to start a notebook session."
},
"dotnet-interactive.kernelEnvironmentVariables": {
"type": "object",
"default": {},
"description": "Environment variables to set when starting a notebook session."
},
"dotnet-interactive.notebookParserArgs": {
"type": "array",
"default": [
Expand Down Expand Up @@ -552,4 +557,4 @@
"uuid": "8.3.2",
"rxjs": "7.5.6"
}
}
}
7 changes: 6 additions & 1 deletion src/dotnet-interactive-vscode/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,11 @@
],
"description": "Command and arguments used to start a notebook session."
},
"dotnet-interactive.kernelEnvironmentVariables": {
"type": "object",
"default": {},
"description": "Environment variables to set when starting a notebook session."
},
"dotnet-interactive.notebookParserArgs": {
"type": "array",
"default": [
Expand Down Expand Up @@ -552,4 +557,4 @@
"uuid": "8.3.2",
"rxjs": "7.5.6"
}
}
}