diff --git a/src/main/server.ts b/src/main/server.ts index 7eb79e2d..fcfde8fb 100644 --- a/src/main/server.ts +++ b/src/main/server.ts @@ -9,10 +9,10 @@ import { request as httpRequest } from 'http'; import { request as httpsRequest } from 'https'; import { IDisposable, IEnvironmentType, IPythonEnvironment } from './tokens'; import { + activatePathForEnvPath, createTempFile, getEnvironmentPath, getFreePort, - getSchemasDir, getUserDataDir, waitForDuration } from './utils'; @@ -32,7 +32,6 @@ const SERVER_RESTART_LIMIT = 3; // max server restarts function createLaunchScript( serverInfo: JupyterServer.IInfo, baseCondaPath: string, - schemasDir: string, port: number, token: string ): string { @@ -71,6 +70,7 @@ function createLaunchScript( // conda-packed environments let condaActivatePath = ''; + let condaShellScriptPath = ''; let isBaseCondaActivate = true; // use activate from the environment instead of base when possible @@ -94,10 +94,18 @@ function createLaunchScript( isBaseCondaActivate = false; } else { condaActivatePath = path.join(baseCondaPath, 'bin', 'activate'); + condaShellScriptPath = path.join( + baseCondaPath, + 'etc', + 'profile.d', + 'conda.sh' + ); } } } + const envActivatePath = activatePathForEnvPath(envPath); + if (isWin) { if (isConda) { script = ` @@ -106,18 +114,22 @@ function createLaunchScript( CALL ${launchCmd}`; } else { script = ` - CALL ${envPath}\\activate.bat + CALL ${envActivatePath} CALL ${launchCmd}`; } } else { if (isConda) { script = ` source "${condaActivatePath}" - ${isBaseCondaActivate ? `conda activate "${envPath}"` : ''} + ${ + isBaseCondaActivate + ? `source ${condaShellScriptPath} && conda activate "${envPath}"` + : '' + } ${launchCmd}`; } else { script = ` - source "${envPath}/bin/activate" + source "${envActivatePath}" ${launchCmd}`; } } @@ -264,7 +276,6 @@ export class JupyterServer { const launchScriptPath = createLaunchScript( this._info, baseCondaPath, - getSchemasDir(), this._info.port, this._info.token );