JuliaCall icon indicating copy to clipboard operation
JuliaCall copied to clipboard

julia_setup() doesn't work

Open JianghuiDu opened this issue 6 years ago • 46 comments

Windows 10, R 3.5.1, Julia 1.0 I installed the development version of JuliaCall and then it reports error.

> library(JuliaCall)
> julia <- julia_setup()
Julia version 1.0.0 at location C:\Users\JD\AppData\Local\Julia-1.0.0\bin will be used.
Error in juliacall_initialize(.julia$dll_file) : 
  jl_init - The specified procedure could not be found.

The installation process was sucessful. Julia is on my windows PATH and I checked it from the command line. Any help?

JianghuiDu avatar Sep 27 '18 00:09 JianghuiDu

The error seems weird. I know where it comes from, but it shouldn't have happened. And it seems like an error from previous versions of JuliaCall.

How about

  • download the source of JuliaCall from Github,
  • open JuliaCall.Rproj in your RStudio or open R from the directory where you download the source of JuliaCall,
  • in the src/libjulia.cpp, find the line: https://github.com/Non-Contradiction/JuliaCall/blob/0a66642c807f0be64e0638191a7427cff156302e/src/libjulia.cpp#L120 and change it to if (!(load_symbol(libjulia_t, "jl_init__threading", (void**) &jl_init)))
  • Rebuild the package, you can use the build panel on the upper right corner of RStudio and click the Install and Restart button.

And then see if the error persists.

Non-Contradiction avatar Sep 27 '18 01:09 Non-Contradiction

I was able to rebuilt it sucessfully, but once I call julia_setup() the session is aborted. I tried a few times and it all get aborted.

JianghuiDu avatar Sep 27 '18 03:09 JianghuiDu

Does it have any error message before the session is aborted?

Non-Contradiction avatar Sep 27 '18 13:09 Non-Contradiction

No. It didn't report anything, just terminated the session outright in Rstudio. I also tried in R's native console, in which case it's stuck (again no error) and nothing happened for half an hour and I have to close it.

JianghuiDu avatar Sep 27 '18 16:09 JianghuiDu

How about trying it from the command line, or use the Check button besides the Install and Restart button in RStudio, which should be equivalent to running from command line.

Non-Contradiction avatar Sep 27 '18 16:09 Non-Contradiction

FWIW, I'm experiencing the same issue. Windows 10 64-bit. R 3.5.0

I did follow these steps below:

  • download the source of JuliaCall from Github,

  • open JuliaCall.Rproj in your RStudio or open R from the directory where you download the source of JuliaCall,

  • in the src/libjulia.cpp, find the line:

      [JuliaCall/src/libjulia.cpp](https://github.com/Non-Contradiction/JuliaCall/blob/0a66642c807f0be64e0638191a7427cff156302e/src/libjulia.cpp#L120)
    
    
         Line 120
      in
      [0a66642](/Non-Contradiction/JuliaCall/commit/0a66642c807f0be64e0638191a7427cff156302e)
    
    
    
    
    
    
    
           if (!(load_symbol(libjulia_t, "jl_init", (void**) &jl_init) || load_symbol(libjulia_t, "jl_init__threading", (void**) &jl_init))) 
    

    and change it to if (!(load_symbol(libjulia_t, "jl_init__threading", (void**) &jl_init)))

  • Rebuild the package, you can use the build panel on the upper right corner of RStudio and click the Install and Restart button.

And then see if the error persists.

Then I tried the Check option in RStudio. The x86 (32-bit) tests failed, but the x64 (64-bit) bit tests passed.

Then, from the command line, I started R and ran:

> library(JuliaCall)
> julia_setup()
Julia version 1.0.0 at location C:\Users\username\AppData\Local\JULIA-~2.0\bin will be used.
Loading setup script for JuliaCall...
Finish loading setup script for JuliaCall.
> julia_command("a = sqrt(2);"); julia_eval("a")
[1] 1.414214

So, from the command line, everything seems to work. However, from R GUI, the command

> library(JuliaCall)
> julia_command("a = sqrt(2);"); julia_eval("a")

just hangs forever.

And, from RStudio, the same command causes the R session to abort immediately.

metanoid avatar Sep 27 '18 17:09 metanoid

Same here. All the checks are passed. I just followed @metanoid and found that I also can run julia_setup() from windows command line, but not from R console or Rstudio.

JianghuiDu avatar Sep 27 '18 17:09 JianghuiDu

Here are the check results if it helps

==> devtools::check(document = FALSE)

Setting env vars --------------------------------------------------------------
CFLAGS  : -Wall -pedantic
CXXFLAGS: -Wall -pedantic
Building JuliaCall ------------------------------------------------------------
"C:/PROGRA~1/R/R-3.5.1/bin/x64/R" --no-site-file --no-environ --no-save  \
  --no-restore --quiet CMD build "C:\Users\JD\Downloads\JuliaCall-master"  \
  --no-resave-data --no-manual 

* checking for file 'C:\Users\JD\Downloads\JuliaCall-master/DESCRIPTION' ... OK
* preparing 'JuliaCall':
* checking DESCRIPTION meta-information ... OK
* cleaning src
* installing the package to build vignettes
* creating vignettes ... OK
* cleaning src
* checking for LF line-endings in source and make files and shell scripts
* checking for empty or unneeded directories
* building 'JuliaCall_0.16.0.9000.tar.gz'

Setting env vars --------------------------------------------------------------
_R_CHECK_CRAN_INCOMING_USE_ASPELL_: TRUE
_R_CHECK_CRAN_INCOMING_           : FALSE
_R_CHECK_FORCE_SUGGESTS_          : FALSE
Checking JuliaCall ------------------------------------------------------------
"C:/PROGRA~1/R/R-3.5.1/bin/x64/R" --no-site-file --no-environ --no-save  \
  --no-restore --quiet CMD check  \
  "C:\Users\JD\AppData\Local\Temp\Rtmpa2zB1A/JuliaCall_0.16.0.9000.tar.gz"  \
  --as-cran --timings --no-manual 

* using log directory 'C:/Users/JD/Downloads/JuliaCall.Rcheck'
* using R version 3.5.1 (2018-07-02)
* using platform: x86_64-w64-mingw32 (64-bit)
* using session charset: ISO8859-1
* using options '--no-manual --as-cran'
* checking for file 'JuliaCall/DESCRIPTION' ... OK
* checking extension type ... Package
* this is package 'JuliaCall' version '0.16.0.9000'
* package encoding: UTF-8
* checking package namespace information ... OK
* checking package dependencies ... OK
* checking if this is a source package ... OK
* checking if there is a namespace ... OK
* checking for executable files ... OK
* checking for hidden files and directories ... OK
* checking for portable file names ... OK
* checking serialization versions ... OK
* checking whether package 'JuliaCall' can be installed ... OK
* checking installed package size ... OK
* checking package directory ... OK
* checking 'build' directory ... OK
* checking DESCRIPTION meta-information ... OK
* checking top-level files ... OK
* checking for left-over files ... OK
* checking index information ... OK
* checking package subdirectories ... OK
* checking R files for non-ASCII characters ... OK
* checking R files for syntax errors ... OK
* checking whether the package can be loaded ... OK
* checking whether the package can be loaded with stated dependencies ... OK
* checking whether the package can be unloaded cleanly ... OK
* checking whether the namespace can be loaded with stated dependencies ... OK
* checking whether the namespace can be unloaded cleanly ... OK
* checking loading without being on the library search path ... OK
* checking dependencies in R code ... OK
* checking S3 generic/method consistency ... OK
* checking replacement functions ... OK
* checking foreign function calls ... OK
* checking R code for possible problems ... OK
* checking Rd files ... OK
* checking Rd metadata ... OK
* checking Rd line widths ... OK
* checking Rd cross-references ... OK
* checking for missing documentation entries ... OK
* checking for code/documentation mismatches ... OK
* checking Rd \usage sections ... OK
* checking Rd contents ... OK
* checking for unstated dependencies in examples ... OK
* checking line endings in C/C++/Fortran sources/headers ... OK
* checking pragmas in C/C++ headers and code ... OK
* checking compilation flags used ... OK
* checking compiled code ... OK
* checking installed files from 'inst/doc' ... OK
* checking files in 'vignettes' ... OK
* checking examples ... OK
** found \donttest examples: check also with --run-donttest
* checking for unstated dependencies in 'tests' ... OK
* checking tests ...
  Running 'testthat.R' OK
 [52s]
* checking for unstated dependencies in vignettes ... OK
* checking package vignettes in 'inst/doc' ... OK
* checking re-building of vignette outputs ... OK
* DONE
Status: OK



R CMD check results
0 errors | 0 warnings | 0 notes

R CMD check succeeded

Seems like a strange problem.

JianghuiDu avatar Sep 27 '18 17:09 JianghuiDu

Thank you for the feedback! R 32-bit can only work with Julia 32-bit and R 64-bit can only work with Julia 64-bit. So it is normal that the 32-bit tests failed, since the Julia is 64-bit.

Since the problem seems to be with RStudio and R GUI and the appveyor CI testing cannot test GUI things, I will try to find Windows machines for testing.

Non-Contradiction avatar Sep 27 '18 17:09 Non-Contradiction

Mine (R and Julia) are both 64-bit. Rstudio is 32-bit though. Hope there will be a solution. Thanks.

JianghuiDu avatar Sep 27 '18 17:09 JianghuiDu

I have a somewhat crazy idea. How about running RStudio from the command line and then do the library(JuliaCall); julia_setup() in the RStudio? I came up with this idea because I found an issue here https://github.com/JuliaLang/julia/issues/28820 that on windows, embedded julia 1.0 will crash if there is no console (command line). Since the problem here is common to both R GUI and RStudio, but not seen from the command line, it seems that these problems may be related.

Non-Contradiction avatar Sep 27 '18 19:09 Non-Contradiction

If you mean to start RStudio from the command line rather than the launch button then it doesn't make a difference. Did I misunderstand you?

JianghuiDu avatar Sep 27 '18 20:09 JianghuiDu

No misunderstanding, this is exactly what I mean. New version of RStudio has a terminal. How about running R from the RStudio terminal and then trying in this R?

Non-Contradiction avatar Sep 27 '18 20:09 Non-Contradiction

Yes, it works as it does using windows terminal. I mean the RStudio terminal is simply calling the windows terminal so they should behave the same, right?

JianghuiDu avatar Sep 27 '18 20:09 JianghuiDu

Yes, it should be the same. And I found that RStudio starts a new session for each terminal, so this cannot solve the real issue, but it does provide a temporary solution: starting an R in the RStudio terminal and then use RStudio's Code -> Send to Terminal to run R codes in the terminal R instead of RStudio's console.

The issue I linked to in my previous post does have a solution (?I'm not sure), but it requires modifying julia source code and build julia yourself, which seems too tedious to try...

Non-Contradiction avatar Sep 27 '18 20:09 Non-Contradiction

That would work but it would be much simpler just doing julia in julia and then export results to be read into R. Thanks. If some simple solution comes up I would appreciate to learn. Thanks.

JianghuiDu avatar Sep 27 '18 21:09 JianghuiDu

Just to report, I experience this same issue on 2 different computers using both R 3.5.1 and R 3.4.4: As soon as I call julia_setup() in RStudio or R GUI session crashes.

I am able to run julia_setup() as expected in R from terminal (cmd).

waldocoetzee avatar Sep 28 '18 10:09 waldocoetzee

The issue https://github.com/JuliaLang/julia/issues/28820 has been fixed on Julia master and should now be included in the Julia windows nightly binary at https://julialang.org/downloads/nightlies.html, the nightly is not stable (but the mac nightly works on my mac without obvious problems) and maybe we can use it to check whether the fix solves the issue here.

If the RStudio and R GUI issue is solved with the nightly, then https://github.com/JuliaLang/julia/issues/28820 is the root of the problem here, and we can expect the fix will be in the Julia patch release like 1.0.2 next month (hopefully). If not, then the root of the problem here is somewhere else, and I need to investigate more into the problem.

Non-Contradiction avatar Oct 02 '18 21:10 Non-Contradiction

After installing Julia windows nightly both my Rstudio and Julia 1.0 stopped working immediately. They just froze and restarting/reinstalling didn't help. I have to uninstall the nightly and everything came back normal...

JianghuiDu avatar Oct 02 '18 22:10 JianghuiDu

@JianghuiDu The nightly Julia itself doesn't work either? Is there anything related to Julia in PATH variable of windows? Maybe we should try to rebuild JuliaCall?

Non-Contradiction avatar Oct 03 '18 03:10 Non-Contradiction

The nightly itself actually worked. Everything else stopped. I wasn't even doing anything with JuliaCall in R yet still my Rstudio stopped working. It's really strange.

JianghuiDu avatar Oct 03 '18 04:10 JianghuiDu

I find myself in the same situation. Loads fine on my MacBook but on my Windows machine, RStudio announces the session has been aborted after the Console shows the message that Julia version 0.7.0 at location c:\JULIA-~1.0\bin will be used. R 3.5.1 on Windows 10, with RStudio 1.1.456. Same thing happens with Julia 1.0.0.

Upgrading to the nightly Julia 1.1.0-DEV.535 (Commit 84024a1f44) seems to have resolved the issue.

samclifford avatar Oct 24 '18 09:10 samclifford

@samclifford Thanks for the feedback! Then the problem root is indeed the Julia issue when embedding on windows, Julia nightly ( and possibly Julia 1.0.2 later?) will fix the RStudio issue.

Non-Contradiction avatar Oct 24 '18 13:10 Non-Contradiction

Julia nightly stopped working after a while. Not sure what's happened there. Testing on a Linux box now.

samclifford avatar Oct 25 '18 13:10 samclifford

1

ghost avatar Nov 02 '18 06:11 ghost

@statli Thanks for reporting! Does it work in R starting from command line? As discussed before, this is likely due to an issue in Julia itself, which crashes the GUI application on windows when embedding, and will (hopefully) be fixed in Julia 1.0.2 as far as I know.

Non-Contradiction avatar Nov 02 '18 14:11 Non-Contradiction

@Non-Contradiction .Thanks for your answer! This is my Windows OS .It does not work in R starting from command line,have same problem.Now,I ues JuliaCall package in CentOS. The package is very good. Thank you again for your work.

ghost avatar Nov 03 '18 05:11 ghost

@Non-Contradiction Now,my problem becomehttps://github.com/Non-Contradiction/JuliaCall/issues/67 21

ghost avatar Nov 03 '18 05:11 ghost

@statli The new problem can be fixed by setting the PATH variable in Windows to contain the path for julia binary, or setwd to the path of julia binary when doing julia_setup(), but I'm afraid once this problem is fixed, the old problem will still occur that julia crashes RStudio.

What is the error message for the R starting from command line? As far as I know, starting R from command line should be fine, or even from RStudio's terminal (not RStudio's console), or from the Rmd document using the "knit" button, because all these three methods are actually the same in invoking a command line (terminal) R.

Non-Contradiction avatar Nov 03 '18 14:11 Non-Contradiction

@Non-Contradiction Thanks,sir.

ghost avatar Nov 04 '18 05:11 ghost