Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VS Code: Failed to start the Kernel #101

Open
egg-juxt opened this issue Jul 30, 2024 · 5 comments
Open

VS Code: Failed to start the Kernel #101

egg-juxt opened this issue Jul 30, 2024 · 5 comments

Comments

@egg-juxt
Copy link

Hi, my tslab kernel is not starting when inside the VS Code Jupyter Extension I select the tslab TypeScript kernel.

Not sure if it is a problem with the extension, because it seems the JSON config file doesn't get created, so tslab is not able to open it. But I have tested with the Deno kernel and it does start.

From jupyter lab it does work.

Visual Studio Code (1.91.1, undefined, desktop)
Jupyter Extension Version: 2024.6.0.
Python Extension Version: 2024.10.0.
Pylance Extension Version: 2024.7.1.
Platform: linux (x64).
Workspace folder ~/src/temp/node-xtdb, Home = /home/egg
14:28:12.734 [debug] Start refreshing Kernel Picker (1722342492734)
14:28:12.852 [debug] KernelProvider switched kernel to id = .tslab./tslab./.tslab#kernel#--config-path#{connection_file}
14:28:12.852 [debug] start the kernel, options.disableUI=true for ~/src/temp/node-xtdb/src/sample2.ipynb
14:28:12.865 [trace] Registering commtarget jupyter.widget
14:28:12.868 [debug] Controller selection change completed
14:28:12.868 [trace] Version of IPyWidgets 7 determined after 0.001s
14:28:12.912 [info] Starting Kernel (TypeScript) for '~/src/temp/node-xtdb/src/sample2.ipynb' (disableUI=true)
14:28:12.913 [trace] Creating raw notebook for resource '~/src/temp/node-xtdb/src/sample2.ipynb'
14:28:12.981 [trace] Search for KernelSpecs in Interpreter /bin/python
14:28:12.982 [trace] Search for KernelSpecs in Interpreter /sbin/python
14:28:12.982 [trace] Search for KernelSpecs in Interpreter /usr/bin/python
14:28:12.983 [trace] Search for KernelSpecs in Interpreter /usr/sbin/python
14:28:12.983 [trace] Kernel Spec for 'Python 3 (ipykernel)' (/usr/share/jupyter/kernels/python3/kernel.json) is hidden. (isDefaultKernelSpec = true, language = python, registrationInfo = undefined)
14:28:12.985 [debug] Get Custom Env Variables, Class name = Sm, completed in 250ms, has a truthy return value, Arg 1: undefined, Arg 2: "RunPythonCode"
14:28:12.985 [debug] Jupyter Paths /kernels: 
14:28:12.985 [debug] Kernel Spec Root Paths, /usr/share/jupyter/kernels, /usr/local/share/jupyter/kernels, ~/.local/share/jupyter/kernels
14:28:13.290 [debug] End refreshing Kernel Picker (1722342492734)
14:28:13.292 [debug] Launching kernel .tslab./tslab./.tslab#kernel#--config-path#{connection_file} for ~/src/temp/node-xtdb/src/sample2.ipynb in //home/~/src/temp/node-xtdb/src with ports 9001, 9000, 9004, 9002, 9003
14:28:13.292 [info] Launching Raw Kernel TypeScript # tslab
14:28:13.292 [debug] Create ProcessService, Class name = Im (started execution), Arg 1: "~/src/temp/node-xtdb/src/sample2.ipynb", Arg 2: {"a":false,"b":{"z":3,"w":{"i":-1,"end":0},"u":[{"id":1034},{"id":1035},null,{"id":1038}]}}
14:28:13.298 [debug] Get Custom Env Variables, Class name = Sm, completed in 6ms, has a truthy return value, Arg 1: "~/src/temp/node-xtdb/src/sample2.ipynb", Arg 2: "RunNonPythonCode", Arg 3: {"a":false,"b":{"z":3,"w":{"i":-1,"end":0},"u":[{"id":1034},{"id":1035},null,{"id":1038}]}}
14:28:13.298 [debug] Create ProcessService, Class name = Im, completed in 6ms, has a truthy return value, Arg 1: "~/src/temp/node-xtdb/src/sample2.ipynb", Arg 2: {"a":false,"b":{"z":3,"w":{"i":-1,"end":0},"u":[{"id":1034},{"id":1035},null,{"id":1038}]}}
14:28:13.305 [info] Process Execution: /tslab kernel --config-path /home/~/.local/share/jupyter/runtime/kernel-v2-29663rdSmjgt0v06u.json
    > cwd: //home/~/src/temp/node-xtdb/src
14:28:13.305 [debug] Kernel process undefined.
14:28:13.308 [error] Kernel died [Error: spawn tslab ENOENT
	at ChildProcess._handle.onexit (node:internal/child_process:286:19)
	at onErrorNT (node:internal/child_process:484:16)
	at process.processTicksAndRejections (node:internal/process/task_queues:82:21)] {
  errno: -2,
  code: 'ENOENT',
  syscall: 'spawn tslab',
  path: 'tslab',
  spawnargs: [
    'kernel',
    '--config-path',
    '/home/~/.local/share/jupyter/runtime/kernel-v2-29663rdSmjgt0v06u.json'
  ]
} 
14:28:13.309 [error] Disposing kernel process due to an error [Error: spawn tslab ENOENT
	at ChildProcess._handle.onexit (node:internal/child_process:286:19)
	at onErrorNT (node:internal/child_process:484:16)
	at process.processTicksAndRejections (node:internal/process/task_queues:82:21)] {
  errno: -2,
  code: 'ENOENT',
  syscall: 'spawn tslab',
  path: 'tslab',
  spawnargs: [
    'kernel',
    '--config-path',
    '/home/~/.local/share/jupyter/runtime/kernel-v2-29663rdSmjgt0v06u.json'
  ]
}
14:28:13.310 [error] 
14:28:13.310 [debug] Dispose Kernel process undefined.
14:28:13.313 [error] Failed to connect raw kernel session: Error: The kernel died. Error: ... View Jupyter [log](command:jupyter.viewOutput) for further details.
14:28:13.314 [error] Failed to connect raw kernel session: Error: The kernel died. Error: ... View Jupyter [log](command:jupyter.viewOutput) for further details.
14:28:13.314 [warn] Failed to shutdown kernel, .tslab./tslab./.tslab#kernel#--config-path#{connection_file} [TypeError: Cannot read properties of undefined (reading 'dispose')
	at R_.shutdown (/home/~/.vscode/extensions/ms-toolsai.jupyter-2024.6.0-linux-x64/dist/extension.node.js:304:13629)
	at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
	at async A_.shutdown (/home/~/.vscode/extensions/ms-toolsai.jupyter-2024.6.0-linux-x64/dist/extension.node.js:304:22107)]
14:28:13.314 [trace] failed to create IJupyterKernelConnectionSession in kernel, UI Disabled = true [Ud [Error]: 
	at new n (/home/~/.vscode/extensions/ms-toolsai.jupyter-2024.6.0-linux-x64/dist/extension.node.js:98:4480)
	at new ml (/home/~/.vscode/extensions/ms-toolsai.jupyter-2024.6.0-linux-x64/dist/extension.node.js:181:13608)
	at new Ud (/home/~/.vscode/extensions/ms-toolsai.jupyter-2024.6.0-linux-x64/dist/extension.node.js:270:26489)
	at ky.launch (/home/~/.vscode/extensions/ms-toolsai.jupyter-2024.6.0-linux-x64/dist/extension.node.js:301:4)
	at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

Error: spawn tslab ENOENT
	at ChildProcess._handle.onexit (node:internal/child_process:286:19)
	at onErrorNT (node:internal/child_process:484:16)
	at process.processTicksAndRejections (node:internal/process/task_queues:82:21)] {
  category: 'unknown',
  isJupyterError: true,
  originalException: [Error: spawn tslab ENOENT
  	at ChildProcess._handle.onexit (node:internal/child_process:286:19)
  	at onErrorNT (node:internal/child_process:484:16)
  	at process.processTicksAndRejections (node:internal/process/task_queues:82:21)] {
    errno: -2,
    code: 'ENOENT',
    syscall: 'spawn tslab',
    path: 'tslab',
    spawnargs: [
      'kernel',
      '--config-path',
      '/home/~/.local/share/jupyter/runtime/kernel-v2-29663rdSmjgt0v06u.json'
    ]
  },
  kernelConnectionMetadata: n {
    kind: 'startUsingLocalKernelSpec',
    kernelSpec: {
      specFile: '/home/~/.local/share/jupyter/kernels/tslab/kernel.json',
      name: 'tslab',
      argv: [Array],
      language: 'typescript',
      executable: 'tslab',
      display_name: 'TypeScript',
      metadata: [Object]
    },
    interpreter: undefined,
    id: '.tslab./tslab./.tslab#kernel#--config-path#{connection_file}'
  },
  stdErr: '\n\n'
}
14:28:13.316 [warn] Error occurred while trying to start the kernel, options.disableUI=true [Ud [Error]: 
	at new n (/home/~/.vscode/extensions/ms-toolsai.jupyter-2024.6.0-linux-x64/dist/extension.node.js:98:4480)
	at new ml (/home/~/.vscode/extensions/ms-toolsai.jupyter-2024.6.0-linux-x64/dist/extension.node.js:181:13608)
	at new Ud (/home/~/.vscode/extensions/ms-toolsai.jupyter-2024.6.0-linux-x64/dist/extension.node.js:270:26489)
	at ky.launch (/home/~/.vscode/extensions/ms-toolsai.jupyter-2024.6.0-linux-x64/dist/extension.node.js:301:4)
	at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

Error: spawn tslab ENOENT
	at ChildProcess._handle.onexit (node:internal/child_process:286:19)
	at onErrorNT (node:internal/child_process:484:16)
	at process.processTicksAndRejections (node:internal/process/task_queues:82:21)] {
  category: 'unknown',
  isJupyterError: true,
  originalException: [Error: spawn tslab ENOENT
  	at ChildProcess._handle.onexit (node:internal/child_process:286:19)
  	at onErrorNT (node:internal/child_process:484:16)
  	at process.processTicksAndRejections (node:internal/process/task_queues:82:21)] {
    errno: -2,
    code: 'ENOENT',
    syscall: 'spawn tslab',
    path: 'tslab',
    spawnargs: [
      'kernel',
      '--config-path',
      '/home/~/.local/share/jupyter/runtime/kernel-v2-29663rdSmjgt0v06u.json'
    ]
  },
  kernelConnectionMetadata: n {
    kind: 'startUsingLocalKernelSpec',
    kernelSpec: {
      specFile: '/home/~/.local/share/jupyter/kernels/tslab/kernel.json',
      name: 'tslab',
      argv: [Array],
      language: 'typescript',
      executable: 'tslab',
      display_name: 'TypeScript',
      metadata: [Object]
    },
    interpreter: undefined,
    id: '.tslab./tslab./.tslab#kernel#--config-path#{connection_file}'
  },
  stdErr: '\n\n'
}
14:28:13.361 [debug] Disposed Kernel process undefined.
14:28:13.396 [trace] Conda file is conda
14:28:13.404 [trace] Web view is ready to receive widget messages
@0xjgv
Copy link

0xjgv commented Aug 12, 2024

It looks like the kernel replaces your username egg for ~ in the path 🤔 Jupyter extension changes in VSCode @yunabe?

@egg-juxt
Copy link
Author

Yeah. I'm not completely sure if it is an issue of finding the kernel executable, or the config file.

It seems to be unable to find the executable, because of the syscall that caused the Exception? (see originalException data above: syscall: 'spawn tslab')

It does work when using the Deno kernel though:

18:12:53.392 [info] Process Execution: ~/.deno/bin/deno jupyter --kernel --conn /home/~/.local/share/jupyter/runtime/kernel-v2-2665438FY804s8yRH8M.json
    > cwd: //home/~/src/temp/typeorm-xtdb/src
18:12:53.392 [debug] Kernel process 32993.

@egg-juxt
Copy link
Author

Solved by adding the following to my ~/.profile:

# Enable nvm if available
if [ -f ~/.nvm/nvm.sh ]; then
  source ~/.nvm/nvm.sh
fi

tslab starts with #!/usr/bin/env node, and the task started by VS Code (non-interactive) wasn't finding node in the PATH.

I wonder if there'd be any VS Code settings, or something could be done in tslab in order to locate a proper node executable?

@zzyx2021
Copy link

Solved by adding the following to my ~/.profile:

# Enable nvm if available
if [ -f ~/.nvm/nvm.sh ]; then
  source ~/.nvm/nvm.sh
fi

tslab starts with #!/usr/bin/env node, and the task started by VS Code (non-interactive) wasn't finding node in the PATH.

I wonder if there'd be any VS Code settings, or something could be done in tslab in order to locate a proper node executable?

I can't solve this on windows

@alxlu
Copy link

alxlu commented Sep 20, 2024

i have this issue too on macOS. adding it to my .profile didn't work. however, i solved it by hardcoding the path to the tslab kernel.json

{"argv": ["/Users/[username]/.config/nvm/versions/node/v20.10.0/bin/tslab", "kernel", "--config-path", "{connection_file}"], "display_name": "TypeScript", "language": "typescript"}

probably not the ideal way to solve the issue, but it should work on Windows as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants