diff --git a/extensions/notebook/package.json b/extensions/notebook/package.json index d6a103bbc9..9f56dd9731 100644 --- a/extensions/notebook/package.json +++ b/extensions/notebook/package.json @@ -54,6 +54,11 @@ "default": true, "description": "%notebook.overrideEditorTheming.description%" }, + "notebook.allowRoot": { + "type": "boolean", + "default": false, + "description": "%notebook.allowRoot.description%" + }, "notebook.maxTableRows": { "type": "number", "default": 5000, diff --git a/extensions/notebook/package.nls.json b/extensions/notebook/package.nls.json index d0f2feb595..8329b47c32 100644 --- a/extensions/notebook/package.nls.json +++ b/extensions/notebook/package.nls.json @@ -13,6 +13,7 @@ "notebook.collapseBookItems.description": "Collapse Book items at root level in the Notebooks Viewlet", "notebook.remoteBookDownloadTimeout.description": "Download timeout in milliseconds for GitHub books", "notebook.pinnedNotebooks.description": "Notebooks that are pinned by the user for the current workspace", + "notebook.allowRoot.description": "Allow Jupyter server to run as root user", "notebook.command.new": "New Notebook", "notebook.command.open": "Open Notebook", "notebook.analyzeJupyterNotebook": "Analyze in Notebook", diff --git a/extensions/notebook/src/common/constants.ts b/extensions/notebook/src/common/constants.ts index 12ae561cc2..aed41b9154 100644 --- a/extensions/notebook/src/common/constants.ts +++ b/extensions/notebook/src/common/constants.ts @@ -24,6 +24,7 @@ export const pinnedBooksConfigKey = 'pinnedNotebooks'; export const maxBookSearchDepth = 'maxBookSearchDepth'; export const remoteBookDownloadTimeout = 'remoteBookDownloadTimeout'; export const collapseBookItems = 'collapseBookItems'; +export const allowRoot = 'allowRoot'; export const winPlatform = 'win32'; export const macPlatform = 'darwin'; diff --git a/extensions/notebook/src/jupyter/serverInstance.ts b/extensions/notebook/src/jupyter/serverInstance.ts index efac428d9e..4dd0e9bea3 100644 --- a/extensions/notebook/src/jupyter/serverInstance.ts +++ b/extensions/notebook/src/jupyter/serverInstance.ts @@ -204,12 +204,16 @@ export class PerFolderServerInstance implements IServerInstance { * started when the log message with URL to connect to is emitted. */ protected async startInternal(): Promise { + let startCommand: string; + let notebookConfig: vscode.WorkspaceConfiguration = vscode.workspace.getConfiguration(constants.notebookConfigKey); + let allowRoot: boolean = notebookConfig.get(constants.allowRoot); if (this.isStarted) { return; } let notebookDirectory = this.getNotebookDirectory(); this._token = await utils.getRandomToken(); - let startCommand = `"${this.options.install.pythonExecutable}" "${this.notebookScriptPath}" --no-browser --ip=127.0.0.1 --allow-root --no-mathjax --notebook-dir "${notebookDirectory}" --NotebookApp.token=${this._token}`; + const allowRootParam = allowRoot ? '--allow-root' : ''; + startCommand = `"${this.options.install.pythonExecutable}" "${this.notebookScriptPath}" --no-browser --ip=127.0.0.1 ${allowRootParam} --no-mathjax --notebook-dir "${notebookDirectory}" --NotebookApp.token=${this._token}`; this.notifyStarting(this.options.install, startCommand); // Execute the command