stefan-m-lenz / JuliaConnectoR

A functionally oriented interface for calling Julia from R
Other
100 stars 6 forks source link

Error in runJuliaServer() #5

Closed zuhengxu closed 3 years ago

zuhengxu commented 3 years ago

Hi, I tried to run

f <- juliaEval('function f(x)
x .^2
end')

and I got an error

Starting Julia ...
Error in runJuliaServer() : 
  Timeout while waiting for response from Julia server

It seems like my julia setup is good based on

> juliaSetupOk()
[1] TRUE

I'm using Ubuntu 20.04 and julia 1.5.3. Do you have any suggestions?

Best, Zuheng

zuhengxu commented 3 years ago

My R version is 4.0.3 and I install JuliaConnectoR from the github link.

stefan-m-lenz commented 3 years ago

Thanks for reporting this. It seems at first like the same problem as reported here: https://github.com/stefan-m-lenz/JuliaConnectoR/issues/4

There is a bug in the latest release (0.6.2), which is fixed now in the development version. Can you please try with the latest development version and report if the error is still there?

devtools::install_github("stefan-m-lenz/JuliaConnectoR")

Can you tell me the path where you installed R and Julia?

zuhengxu commented 3 years ago

Thanks for getting this back. The path is

/home/zuheng/julia/julia

I'll try the development version soon and see whether it work!

stefan-m-lenz commented 3 years ago

Thanks. I also just updated the development to print more information about the error when the timeout occurs. I hope that helps to identify the issue if it still persists.

stefan-m-lenz commented 3 years ago

@zuhengxu Did you have time to check the error again? Was it possible for you to use the development version?

zuhengxu commented 3 years ago

Sorry for not getting back. I have reinstalled the latest development version and it still not working. Here is the error message:

> juliaSetupOk()
[1] TRUE
> f <- juliaEval('function f(x)
+ x .^2
+ end')
Starting Julia ...
ERROR: could not load library "/home/zuheng/julia/../lib/julia/sys.so"
/home/zuheng/julia/../lib/julia/sys.so: cannot open shared object file: No such file or directoryError in runJuliaServer() : 
  Timeout while waiting for response from Julia server

More detailed information: JuliaConnectoR is not able to set up my julia automatically, after I reinstallled the package and call juliaSetupOk() it returns False. So I manually add JULIA_BINDIR = /home/zuheng/julia/ in the .Renviron file. This is not suppose to happen, since

zuheng@zuheng:~$ which julia
/home/zuheng/julia/julia

I have experienced exactly the same issue when I was using another package JuliaCall. After playing around I think the problem is on my julia installation. I get into my julia directory and list all the files (not sure if it will help)

zuheng@zuheng:~/julia$ ls -l
total 468
drwxrwxr-x  8 zuheng zuheng   4096 Feb  8 18:23 base
-rw-rw-r--  1 zuheng zuheng   2657 Feb  8 18:21 CITATION.bib
drwxrwxr-x  4 zuheng zuheng   4096 Feb  8 18:21 contrib
-rw-rw-r--  1 zuheng zuheng  20366 Feb  8 18:21 CONTRIBUTING.md
drwxrwxr-x  8 zuheng zuheng   4096 Feb  8 18:22 deps
drwxrwxr-x  5 zuheng zuheng   4096 Feb  8 18:21 doc
drwxrwxr-x  2 zuheng zuheng   4096 Feb  8 18:20 etc
-rw-rw-r--  1 zuheng zuheng 282205 Feb  8 18:21 HISTORY.md
lrwxrwxrwx  1 zuheng zuheng     13 Feb  8 18:29 julia -> usr/bin/julia
-rw-rw-r--  1 zuheng zuheng   5087 Feb  8 18:21 LICENSE.md
-rw-rw-r--  1 zuheng zuheng  27708 Feb  8 18:21 Makefile
-rw-rw-r--  1 zuheng zuheng  45012 Feb  8 18:21 Make.inc
-rw-rw-r--  1 zuheng zuheng  17126 Feb  8 18:21 NEWS.md
-rw-rw-r--  1 zuheng zuheng   6448 Feb  8 18:21 README.md
drwxrwxr-x  6 zuheng zuheng  12288 Feb  8 18:25 src
drwxrwxr-x 32 zuheng zuheng   4096 Feb  8 18:22 stdlib
-rw-rw-r--  1 zuheng zuheng   3948 Feb  8 18:21 sysimage.mk
drwxrwxr-x 15 zuheng zuheng   4096 Feb  8 18:21 test
drwxrwxr-x  2 zuheng zuheng   4096 Feb  8 18:25 ui
drwxrwxr-x 12 zuheng zuheng   4096 Feb  8 18:22 usr
drwxrwxr-x  2 zuheng zuheng   4096 Feb  8 18:23 usr-staging
-rw-rw-r--  1 zuheng zuheng      6 Feb  8 18:21 VERSION

Again, my apology for not getting back in time. Hope this is helpful!

Best, David

stefan-m-lenz commented 3 years ago

zuheng@zuheng:~$ which julia /home/zuheng/julia/julia

This output seems odd. If you have installed Julia like described on the official Julia site, the Julia executable will be in a folder /path/to/julia/julia-1.5.3/bin/julia and this should be the output of which julia. From the output above, it seems like you did not really install Julia but you cloned the Julia GitHub repository. You need to install Julia via the platform specific build.

zuhengxu commented 3 years ago

Yeh, I think this is the key problem. I cloned Julia repo and build the julia executable inside (as described in the official repo). Actually, this allows me to use the latest version of julia.

zuhengxu commented 3 years ago

Maybe it's better to add some clarification on the README.md, since I believe I am not the only one that builds julia directory from the repo.

stefan-m-lenz commented 3 years ago

Thanks for trying the development version. I think the problem is with your setup.

The README currently says:

The package requires that Julia (version ≥ 1.0) is installed and that the Julia executable is in the system search PATH or that the JULIA_BINDIR environment variable is set to the bin directory of the Julia installation.

In your case, you must have the following to satisfy this:

zuheng@zuheng:~$ which julia
/home/zuheng/julia/usr/bin/julia

("executable", not: "link to executable")

Or:

JULIA_BINDIR = /home/zuheng/julia/usr/bin

(Must be the bin directory, not the directory where the link is.)

Can you try this? Please be sure that you remove the JULIA_BINDIR variable again before trying the first variant.

zuhengxu commented 3 years ago

Thanks! This finally works!

stefan-m-lenz commented 3 years ago

Great, I'll close the issue then.