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:
Cory Rivera
2019-02-27 13:30:27 -08:00
committed by Raj
parent 5625ef956d
commit 5a48c52a95
2 changed files with 13 additions and 13 deletions

View File

@@ -225,6 +225,7 @@ export default class JupyterServerInstallation {
// Store the executable options to run child processes with env var without interfering parent env var.
let env = Object.assign({}, process.env);
delete env['Path']; // Delete extra 'Path' variable for Windows, just in case.
env['PATH'] = this.pythonEnvVarPath;
this.execOptions = {
env: env

View File

@@ -247,12 +247,12 @@ export class PerNotebookServerInstance implements IServerInstance {
return new Promise<void>((resolve, reject) => {
let install = this.options.install;
this.childProcess = this.spawnJupyterProcess(install, startCommand);
let stdErrLog: string = '';
// Add listeners for the process exiting prematurely
let onErrorBeforeStartup = (err) => reject(err);
let onExitBeforeStart = (err) => {
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);
@@ -275,6 +275,8 @@ export class PerNotebookServerInstance implements IServerInstance {
this.updateListeners(handleStdout, handleStdErr, onErrorBeforeStartup, onExitBeforeStart);
resolve();
} else {
stdErrLog += data.toString();
}
};
this.childProcess.stdout.on('data', handleStdout);
@@ -349,12 +351,9 @@ export class PerNotebookServerInstance implements IServerInstance {
}
private spawnJupyterProcess(install: JupyterServerInstallation, startCommand: string): ChildProcess {
// Specify the global environment variables
let env = this.getEnvWithConfigPaths();
// Setting the PATH variable here for the jupyter command. Apparently setting it above will cause the
// 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'];
// Specify the global environment variables.
// Note: Get env from the install since it gets used elsewhere
let env = this.getEnvWithConfigPaths(install.execOptions.env);
// 'MSHOST_TELEMETRY_ENABLED' and 'MSHOST_ENVIRONMENT' environment variables are set
// 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;
}
private getEnvWithConfigPaths(): any {
let env = Object.assign({}, process.env);
env['JUPYTER_CONFIG_DIR'] = this.instanceConfigRoot;
env['JUPYTER_PATH'] = this.instanceDataRoot;
return env;
private getEnvWithConfigPaths(env: {}): any {
let newEnv = Object.assign({}, env);
newEnv['JUPYTER_CONFIG_DIR'] = this.instanceConfigRoot;
newEnv['JUPYTER_PATH'] = this.instanceDataRoot;
return newEnv;
}
}