diff --git a/CLAUDE.md b/CLAUDE.md index 54c7e7c525..4338c0e3ac 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -1,6 +1,7 @@ ## Code Style & Organization - Order method, fields and properties, first by accessibility and then by alphabetical order. - Don't add the Microsoft copyright header to new files. +- Use `Uri.joinPath()` for constructing file paths to ensure platform-correct path separators (e.g., `Uri.joinPath(venvPath, 'share', 'jupyter', 'kernels')` instead of string concatenation with `/`) ## Testing - Unit tests use Mocha/Chai framework with `.unit.test.ts` extension diff --git a/src/kernels/deepnote/deepnoteToolkitInstaller.node.ts b/src/kernels/deepnote/deepnoteToolkitInstaller.node.ts index 38ca4b3f00..b9ee1113dd 100644 --- a/src/kernels/deepnote/deepnoteToolkitInstaller.node.ts +++ b/src/kernels/deepnote/deepnoteToolkitInstaller.node.ts @@ -65,6 +65,8 @@ export class DeepnoteToolkitInstaller implements IDeepnoteToolkitInstaller { const venvPath = this.getVenvPath(deepnoteFileUri); const venvKey = venvPath.fsPath; + logger.info(`Ensuring virtual environment at ${venvKey}`); + // Wait for any pending installation for this venv to complete const pendingInstall = this.pendingInstallations.get(venvKey); if (pendingInstall) { @@ -210,6 +212,7 @@ export class DeepnoteToolkitInstaller implements IDeepnoteToolkitInstaller { logger.info('deepnote-toolkit installed successfully in venv'); // Install kernel spec so the kernel uses this venv's Python + // Install into the venv itself (not --user) so the Deepnote server can discover it logger.info('Installing kernel spec for venv...'); try { // Reuse the process service with system environment @@ -219,7 +222,8 @@ export class DeepnoteToolkitInstaller implements IDeepnoteToolkitInstaller { '-m', 'ipykernel', 'install', - '--user', + '--prefix', + venvPath.fsPath, '--name', `deepnote-venv-${this.getVenvHash(deepnoteFileUri)}`, '--display-name', @@ -227,7 +231,14 @@ export class DeepnoteToolkitInstaller implements IDeepnoteToolkitInstaller { ], { throwOnStdErr: false } ); - logger.info('Kernel spec installed successfully'); + const kernelSpecPath = Uri.joinPath( + venvPath, + 'share', + 'jupyter', + 'kernels', + `deepnote-venv-${this.getVenvHash(deepnoteFileUri)}` + ); + logger.info(`Kernel spec installed successfully to ${kernelSpecPath.fsPath}`); } catch (ex) { logger.warn(`Failed to install kernel spec: ${ex}`); // Don't fail the entire installation if kernel spec creation fails