notablemind / jupyter-nodejs

A node.js kernel for jupyter/ipython
http://nbviewer.ipython.org/gist/jaredly/404a36306fdee6a1737a
MIT License
682 stars 70 forks source link

require relative paths #3

Closed ricardofbarros closed 9 years ago

ricardofbarros commented 9 years ago

I'm using atom with hydrogen plugin, basically is jupyter for the text editor and I have installed your package successfully and everything is working just fine.

screen shot 2015-05-27 at 15 17 20

The problem now is with require for relative paths, which I guess ipython won't know the PATH I'm on and wont pass it to node, does any one know a workaround for this?

var test = require('./test');

Error: Cannot find module './test' at Function.Module._resolveFilename (module.js:336:15) at Function.Module._load (module.js:278:25) at Module.require (module.js:365:17) at require (module.js:384:17) at Object.Contextify.sandbox.run (/Users/rbarros/package/node_modules/contextify/lib/contextify.js:12:24) at Context.rawRun (/Users/rbarros/package/build/context.js:105:23) at Context.rawEvaluate (/Users/rbarros/package/build/context.js:117:23) at Context.execute (/Users/rbarros/package/build/context.js:194:21) at Kernel.executeRequest (/Users/rbarros/package/build/kernel.js:153:16) at Kernel.onShell (/Users/rbarros/package/build/kernel.js:90:14) Runtime error Cannot find module './test'

jaredly commented 9 years ago

In ipython shell, you can type !pwd to get the current working directory (or !some shell cmd for any shell command), and cd somepath (without the !) to change the current working directory of the jupyter kernel. I'm not sure how hydrogen would be able to automatically communicate this for you... but at least this should work for the moment. I assume those same commands should work in your atom shell.

ricardofbarros commented 9 years ago

I don't know if this is normal but running ipython console --kernel nodejsand sending the command !pwd gives me an error.

ReferenceError: pwd is not defined
    at <anonymous>:1:2

But if I run ipython with the default kernel ipython console, the shell commands works just fine.

jaredly commented 9 years ago

Oh! Looks like the !shell stuff was done after the latest release. I just published v1.1.0 https://github.com/notablemind/jupyter-nodejs/releases/tag/v1.1.0, which should get things working for you.

On Wed, May 27, 2015 at 9:14 AM Ricardo Barros notifications@github.com wrote:

I don't know if this is normal but running ipython console --kernel nodejsand sending the command !pwd gives me an error.

ReferenceError: pwd is not defined at :1:2

But if I run ipython with the default kernel ipython console, the shell commands works just fine.

— Reply to this email directly or view it on GitHub https://github.com/notablemind/jupyter-nodejs/issues/3#issuecomment-105981834 .

ricardofbarros commented 9 years ago

I don't think this will resolve the issue by having the possibility to inject shell commands, I think the problem is more deeper than we think it is. Could yoy explain me briefly how do your kernel recieves stdin (node code) and executes it? File and line number would be awesome :smile:

ricardofbarros commented 9 years ago

lib/context.js rawEvaluate function, am I close?

ricardofbarros commented 9 years ago

Now the problem resides on the Atom framework.