waTeim / node-julia

Fast and simple access to Julia embedded in node
MIT License
80 stars 15 forks source link

External library support in Julia scripts #24

Open parth9615 opened 8 years ago

parth9615 commented 8 years ago

When using node Julia the .exec command to execute scripts works for Julia scripts that don't use any outside libraries. As in if I try to use the .exec command on a Julia script that uses packages like Cairo or clustering then the I get an error making the script not execute. Is there any way to get around this?

sebastiang commented 8 years ago

I’ve run into this problem in several ways. Some of the complete hangs I’ve solved with pre-compiling everything on the same machine, i.e. during install. But there are other kinds of errors I’ve never been able to debug.

waTeim commented 8 years ago

This is likely connected to the import/include mechanism that Julia uses and how Julia uses libuv to do it. There has always been a tension between Julia and node-julia and node because to the double use of libuv, which is mostly solved by the system linker. Each platform (Linux, OS/X, Windows) solves the problem in slightly different ways. This works when use of libuv is done implicitly by libjulia, and possibly in compiled format which supports @sebastiang experience, but not always, especially when libuv calls are exposed directly. Some of a workaround you can see here in nj.jl where pwd() is copied from base, but the source library is qualified explicitly as opposed to pwd() from base defined in file.jl where the library name is left out.

The real and complete solution and difficult part is this probably requires a change to Julia itself so that embedders can modify the Julia library search path. This warrants a node-julia issue though.

Until that time, can you try do something like make you own module file and then import that like I do here and here.