mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-17 02:51:36 -05:00
Delete duplicate path variables when setting up Jupyter environment config. Also added additional error message info on jupyter start. (#4212)
This commit is contained in:
@@ -225,6 +225,7 @@ export default class JupyterServerInstallation {
|
|||||||
|
|
||||||
// Store the executable options to run child processes with env var without interfering parent env var.
|
// Store the executable options to run child processes with env var without interfering parent env var.
|
||||||
let env = Object.assign({}, process.env);
|
let env = Object.assign({}, process.env);
|
||||||
|
delete env['Path']; // Delete extra 'Path' variable for Windows, just in case.
|
||||||
env['PATH'] = this.pythonEnvVarPath;
|
env['PATH'] = this.pythonEnvVarPath;
|
||||||
this.execOptions = {
|
this.execOptions = {
|
||||||
env: env
|
env: env
|
||||||
|
|||||||
@@ -247,12 +247,12 @@ export class PerNotebookServerInstance implements IServerInstance {
|
|||||||
return new Promise<void>((resolve, reject) => {
|
return new Promise<void>((resolve, reject) => {
|
||||||
let install = this.options.install;
|
let install = this.options.install;
|
||||||
this.childProcess = this.spawnJupyterProcess(install, startCommand);
|
this.childProcess = this.spawnJupyterProcess(install, startCommand);
|
||||||
|
let stdErrLog: string = '';
|
||||||
// Add listeners for the process exiting prematurely
|
// Add listeners for the process exiting prematurely
|
||||||
let onErrorBeforeStartup = (err) => reject(err);
|
let onErrorBeforeStartup = (err) => reject(err);
|
||||||
let onExitBeforeStart = (err) => {
|
let onExitBeforeStart = (err) => {
|
||||||
if (!this.isStarted) {
|
if (!this.isStarted) {
|
||||||
reject(localize('notebookStartProcessExitPremature', 'Notebook process exited prematurely with error: {0}', err));
|
reject(localize('notebookStartProcessExitPremature', 'Notebook process exited prematurely with error: {0}, StdErr Output: {1}', err, stdErrLog));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
this.childProcess.on('error', onErrorBeforeStartup);
|
this.childProcess.on('error', onErrorBeforeStartup);
|
||||||
@@ -275,6 +275,8 @@ export class PerNotebookServerInstance implements IServerInstance {
|
|||||||
|
|
||||||
this.updateListeners(handleStdout, handleStdErr, onErrorBeforeStartup, onExitBeforeStart);
|
this.updateListeners(handleStdout, handleStdErr, onErrorBeforeStartup, onExitBeforeStart);
|
||||||
resolve();
|
resolve();
|
||||||
|
} else {
|
||||||
|
stdErrLog += data.toString();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
this.childProcess.stdout.on('data', handleStdout);
|
this.childProcess.stdout.on('data', handleStdout);
|
||||||
@@ -349,12 +351,9 @@ export class PerNotebookServerInstance implements IServerInstance {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private spawnJupyterProcess(install: JupyterServerInstallation, startCommand: string): ChildProcess {
|
private spawnJupyterProcess(install: JupyterServerInstallation, startCommand: string): ChildProcess {
|
||||||
// Specify the global environment variables
|
// Specify the global environment variables.
|
||||||
let env = this.getEnvWithConfigPaths();
|
// Note: Get env from the install since it gets used elsewhere
|
||||||
// Setting the PATH variable here for the jupyter command. Apparently setting it above will cause the
|
let env = this.getEnvWithConfigPaths(install.execOptions.env);
|
||||||
// notebook process to die even though we don't override it with the for loop logic above.
|
|
||||||
let pathVariableSeparator = process.platform === 'win32' ? ';' : ':';
|
|
||||||
env['PATH'] = install.pythonEnvVarPath + pathVariableSeparator + env['PATH'];
|
|
||||||
|
|
||||||
// 'MSHOST_TELEMETRY_ENABLED' and 'MSHOST_ENVIRONMENT' environment variables are set
|
// 'MSHOST_TELEMETRY_ENABLED' and 'MSHOST_ENVIRONMENT' environment variables are set
|
||||||
// for telemetry purposes used by PROSE in the process where the Jupyter kernel runs
|
// for telemetry purposes used by PROSE in the process where the Jupyter kernel runs
|
||||||
@@ -375,11 +374,11 @@ export class PerNotebookServerInstance implements IServerInstance {
|
|||||||
return childProcess;
|
return childProcess;
|
||||||
}
|
}
|
||||||
|
|
||||||
private getEnvWithConfigPaths(): any {
|
private getEnvWithConfigPaths(env: {}): any {
|
||||||
let env = Object.assign({}, process.env);
|
let newEnv = Object.assign({}, env);
|
||||||
env['JUPYTER_CONFIG_DIR'] = this.instanceConfigRoot;
|
newEnv['JUPYTER_CONFIG_DIR'] = this.instanceConfigRoot;
|
||||||
env['JUPYTER_PATH'] = this.instanceDataRoot;
|
newEnv['JUPYTER_PATH'] = this.instanceDataRoot;
|
||||||
return env;
|
return newEnv;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user