yunabe / tslab

Interactive JavaScript and TypeScript programming with Jupyter
Apache License 2.0
701 stars 44 forks source link

[Breaking Bug] Changing 1 argument in kernel.json to support Hydrogen #36

Closed ed9w2in6 closed 4 years ago

ed9w2in6 commented 4 years ago

tslab works for me at jupyter-notebok. I haven't test for jupyter-lab but i think it will work.

What I am working with is called hydrogen Which is an environment that uses jupyter kernel interfaces to support live code output displaying in the text editor atom by Github.

So the thing is the current generated kernel.json file is like this:

{
 "argv": [
   "tslab", 
   "kernel", 
   "--config-path={connection_file}",
   "--js"
  ], 
  "display_name": "JavaScript", 
  "language": "javascript"
}

Which will break as the string "--config-path={connection_file}" is not matched by jupyter client.

Changing it to this will fix the issue:

{
 "argv": [
   "tslab", 
   "kernel", 
   "--config-path",
   "{connection_file}",
   "--js"
  ], 
  "display_name": "JavaScript", 
  "language": "javascript"
}

The same thing should be done for TypeScript as well.


Note that this is not necessary to change as I believe the problem is with hydrogen.

But since this is an extremely simple fix, why not changing it to support other platform as well?

Especially there starts to have similar plugins for other text editors such as VScode.

yunabe commented 4 years ago

I installed MacOS nteract https://github.com/nteract/nteract and this TypeScript kernel works with it. Is this a hydrogen specific issue?

ed9w2in6 commented 4 years ago

I have not tried nteract before, I am not sure. But I believe this is a Hydrogen specific issue.

This is weird as AFAIK they derived from the same project isn't it?

Again, I already filed an issue on Hydrogen. ( nteract/hydrogen --- issue#1992 ) I think the problem is on Hydrogen because the jupyter_client documentation explicitly says: _"the text {connection_file} in any argument will be replaced with the path to the connection file."_

So this issue is not necessary to be fixed.

Is this easy to change? Or are there any reasons not to change?

yunabe commented 4 years ago

Thank you for the detailed investigation.

Is this easy to change? Or are there any reasons not to change?

It's easy to bypass the issue. I released the new version with the fix (v1.0.13). Let me know if the change does not fix the problem.

we684123 commented 3 years ago

It's easy to bypass the issue. I released the new version with the fix (v1.0.13). Let me know if the change does not fix the problem.

sorry , the problem still exists on v1.0.13 qwq


Versions

OS version: win10 1909

atom --version

Atom    : 1.51.0
Electron: 5.0.13
Chrome  : 73.0.3683.121
Node    : 12.0.0

apm --version

apm  2.5.0
npm  6.14.5
node 10.20.1 x64
atom 1.49.0
python 3.8.2
git 2.28.0.windows.1
visual studio 2015

Hydrogen version:

Hydrogen version: 2.14.5

Logs

UnhandledPromiseRejection: Error: ENOENT: 
no such file or directory, open '{connection_file}' at Object.openSync (fs.js:466:3) at Object.readFileSync (fs.js:369:35) at ZmqServer.init 
(C:\Users\we684123\AppData\Roaming\npm\node_modules\tslab\dist\jupyter.js:411:47) at startKernel 
(C:\Users\we684123\AppData\Roaming\npm\node_modules\tslab\dist\main.js:101:12) at Command. 
(C:\Users\we684123\AppData\Roaming\npm\node_modules\tslab\dist\main.js:165:9) at Command.listener [as _actionHandler] 
(C:\Users\we684123\AppData\Roaming\npm\node_modules\tslab\node_modules\commander\index.js:413:31) at Command._parseCommand 
(C:\Users\we684123\AppData\Roaming\npm\node_modules\tslab\node_modules\commander\index.js:914:14) at Command._dispatchSubcommand 
(C:\Users\we684123\AppData\Roaming\npm\node_modules\tslab\node_modules\commander\index.js:865:18) at Command._parseCommand 
(C:\Users\we684123\AppData\Roaming\npm\node_modules\tslab\node_modules\commander\index.js:882:12) at Command.parse 
(C:\Users\we684123\AppData\Roaming\npm\node_modules\tslab\node_modules\commander\index.js:717:10) { errno: -4058, syscall: 'open', code: 'ENOENT', path: '{connection_file}' }
ed9w2in6 commented 3 years ago

@we684123 I had install tslab v1.0.13 from scratch and the problem is RESOLVED for me. The kernel.json file matches the one I had provided above.

Can you first make sure you are on version v1.0.13? You can know this by running tslab --version

If you are indeed on tslab version v1.0.13, can you also show your kernel.json file? You can find the location of the kernel.json file with the command jupyter kernelspec list

The content should match this:

{
 "argv": [
   "tslab", 
   "kernel", 
   "--config-path",
   "{connection_file}",
   "--js"
  ], 
  "display_name": "JavaScript", 
  "language": "javascript"
}
we684123 commented 3 years ago

yes, i had install tslab v1.0.13

but kernel.json content is :

{ 
"argv": ["tslab.cmd", "kernel", "--config-path={connection_file}"],
"display_name": "TypeScript", 
"language": "typescript"
}

Imgur

and if i change kernel.json content to :

{
"argv": ["tslab", "kernel", "--config-path","{connection_file}","--ts"],
"display_name": "TypeScript", 
"language": "typescript"
}

hydrogen return error : error: unknown option '--ts'


if want to normal work, need change kernel.json content to :

{
"argv": ["tslab", "kernel", "--config-path","{connection_file}"],
"display_name": "TypeScript", 
"language": "typescript"
}
we684123 commented 3 years ago

very sorry Orz v1.0.13 is RESOLVED

I forgot to tslab installafter upgrading v1.0.13

Say sorry again Orz

ed9w2in6 commented 3 years ago

@we684123 😃No worries, it do be like that sometimes.