Non-Contradiction / JuliaCall

Embed Julia in R
https://non-contradiction.github.io/JuliaCall/index.html
Other
266 stars 36 forks source link

Error when using julia_setup #200

Closed EvanCWilson closed 1 year ago

EvanCWilson commented 1 year ago

Hello, Thanks in advance for any assistance, I'm somewhat new to Julia. However, I have gotten this code to work in the (recent) past, but I recently transferred files to a new work computer and now I am unable to use the julia_setup command within Rstudio. I have updated R (4.3.1), RStudio (2023.06.0), Julia (1.9.1), and JuliaCall (0.17.5), to see if that helps with no success. I have been unable to find a workaround, and I don't know whether this is a bug or maybe my antivirus software is causing issues with the communication between R and Julia here? I suspect this is "user error" on my part, but any help would be greatly appreciated. Cheers, Evan

Example Code & Error Messages:

JULIA_HOME <- "C:/Users/wils1909/AppData/Local/Programs/Julia-1.9.1/bin" JuliaCall::julia_setup(JULIA_HOME)

returns the error message: Julia version 1.9.1 at location C:\Users\wils1909\AppData\Local\Programs\JULIA-~1.1\bin will be used. Loading setup script for JuliaCall... Error in .julia$cmd(paste0(Rhomeset, "Base.include(Main,\"", system.file("julia/setup.jl", : Error happens when you try to execute command ENV["R_HOME"] = "C:/PROGRA~1/R/R-43~1.1";Base.include(Main,"C:/Users/wils1909/AppData/Local/R/win-library/4.3/JuliaCall/julia/setup.jl") in Julia. To have more helpful error messages, you could considering running the command in Julia directly

Then when I run the suggested command in Julia I get the error message:

ERROR: LoadError: syntax: Global method definition around C:\Users\wils1909\AppData\Local\R\win-library\4.3\JuliaCall\julia\JuliaObject.jl:77 needs to be placed at the top level, or use "eval". Stacktrace: [1] top-level scope @ C:\Users\wils1909\AppData\Local\R\win-library\4.3\JuliaCall\julia\JuliaObject.jl:75 [2] include(mod::Module, _path::String) @ Base .\Base.jl:457 [3] include(x::String) @ Main.JuliaCall C:\Users\wils1909\AppData\Local\R\win-library\4.3\JuliaCall\julia\setup.jl:16 [4] top-level scope @ C:\Users\wils1909\AppData\Local\R\win-library\4.3\JuliaCall\julia\setup.jl:99 [5] include(mod::Module, _path::String) @ Base .\Base.jl:457 [6] top-level scope @ REPL[1]:1 in expression starting at C:\Users\wils1909\AppData\Local\R\win-library\4.3\JuliaCall\julia\JuliaObject.jl:75 in expression starting at C:\Users\wils1909\AppData\Local\R\win-library\4.3\JuliaCall\julia\setup.jl:16

─ Session info ───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── setting value version R version 4.3.1 (2023-06-16 ucrt) os Windows 11 x64 (build 22621) system x86_64, mingw32 ui RStudio language (EN) collate English_United States.utf8 ctype English_United States.utf8 tz America/New_York date 2023-06-20 rstudio 2023.06.0+421 Mountain Hydrangea (desktop) pandoc NA ─ Packages ───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── package * version date (UTC) lib source cachem 1.0.8 2023-05-01 [1] CRAN (R 4.3.0) callr 3.7.3 2022-11-02 [1] CRAN (R 4.3.0) cli 3.6.1 2023-03-23 [1] CRAN (R 4.3.0) crayon 1.5.2 2022-09-29 [1] CRAN (R 4.3.0) devtools 2.4.5 2022-10-11 [1] CRAN (R 4.3.0) digest 0.6.31 2022-12-11 [1] CRAN (R 4.3.0) ellipsis 0.3.2 2021-04-29 [1] CRAN (R 4.3.0) fastmap 1.1.1 2023-02-24 [1] CRAN (R 4.3.0) fs 1.6.2 2023-04-25 [1] CRAN (R 4.3.0) glue 1.6.2 2022-02-24 [1] CRAN (R 4.3.0) htmltools 0.5.5 2023-03-23 [1] CRAN (R 4.3.0) htmlwidgets 1.6.2 2023-03-17 [1] CRAN (R 4.3.0) httpuv 1.6.11 2023-05-11 [1] CRAN (R 4.3.0) JuliaCall * 0.17.5 2022-09-08 [1] CRAN (R 4.3.1) knitr 1.43 2023-05-25 [1] CRAN (R 4.3.0) later 1.3.1 2023-05-02 [1] CRAN (R 4.3.0) lifecycle 1.0.3 2022-10-07 [1] CRAN (R 4.3.0) magrittr 2.0.3 2022-03-30 [1] CRAN (R 4.3.0) memoise 2.0.1 2021-11-26 [1] CRAN (R 4.3.0) mime 0.12 2021-09-28 [1] CRAN (R 4.3.0) miniUI 0.1.1.1 2018-05-18 [1] CRAN (R 4.3.0) pkgbuild 1.4.1 2023-06-14 [1] CRAN (R 4.3.0) pkgload 1.3.2 2022-11-16 [1] CRAN (R 4.3.0) prettyunits 1.1.1 2020-01-24 [1] CRAN (R 4.3.0) processx 3.8.1 2023-04-18 [1] CRAN (R 4.3.0) profvis 0.3.8 2023-05-02 [1] CRAN (R 4.3.0) promises 1.2.0.1 2021-02-11 [1] CRAN (R 4.3.0) ps 1.7.5 2023-04-18 [1] CRAN (R 4.3.0) purrr 1.0.1 2023-01-10 [1] CRAN (R 4.3.0) R6 2.5.1 2021-08-19 [1] CRAN (R 4.3.0) Rcpp 1.0.10 2023-01-22 [1] CRAN (R 4.3.0) remotes 2.4.2 2021-11-30 [1] CRAN (R 4.3.0) rlang 1.1.1 2023-04-28 [1] CRAN (R 4.3.0) rstudioapi 0.14 2022-08-22 [1] CRAN (R 4.3.0) sessioninfo 1.2.2 2021-12-06 [1] CRAN (R 4.3.0) shiny 1.7.4 2022-12-15 [1] CRAN (R 4.3.0) stringi 1.7.12 2023-01-11 [1] CRAN (R 4.3.0) stringr 1.5.0 2022-12-02 [1] CRAN (R 4.3.0) urlchecker 1.0.1 2021-11-30 [1] CRAN (R 4.3.0) usethis 2.2.0 2023-06-06 [1] CRAN (R 4.3.0) vctrs 0.6.3 2023-06-14 [1] CRAN (R 4.3.0) xfun 0.39 2023-04-20 [1] CRAN (R 4.3.0) xtable 1.8-4 2019-04-21 [1] CRAN (R 4.3.0) [1] C:/Users/wils1909/AppData/Local/R/win-library/4.3 [2] C:/Program Files/R/R-4.3.1/library ```r ```
JGPunier commented 1 year ago

Hello Exact same issue here (same versions of R, Rstudio, julia and JuliaCall), on Windows 10. Any help would be much appreciated! Cheers ! Jerome

Faraz564 commented 1 year ago

I have too the same proble in Julia.setup and JuliaCall Julia_Setup

justanothergithubber commented 1 year ago

The PR #199 written by @JackDunnNZ should fix the problem. As a temporary measure, please try

devtools::install_github("https://github.com/JackDunnNZ/JuliaCall/tree/patch-1")

to install the specific version in that PR. The temporary version should be removed cleanly by calling remove.packages("JuliaCall"), and then calling install.packages("JuliaCall") to install the 'main' version when that PR is merged.

JGPunier commented 1 year ago

It did indeed ! thank you so much (@JackDunnNZ for the fix, @justanothergithubber for the response) !

EvanCWilson commented 1 year ago

Yes, that fixed it for me as well! Thanks @justanothergithubber & @JackDunnNZ!

hwborchers commented 1 year ago

@JackDunnNZ I followed your advice and installed the patch you provided. I still get the same error message, so I think this issue shall not be closed.

Julia version 1.9.1 at location /home/hwb/Programs/julia-1.9.1/bin will be used. Loading setup script for JuliaCall... LoadError("/home/hwb/R/x86_64-pc-linux-gnu-library/4.3/JuliaCall/julia/setup.jl", 16, ArgumentError("Package Suppressor not found in current path.\n- Run import Pkg; Pkg.add(\"Suppressor\") to install the Suppressor package.")) Error in .julia$cmd(paste0(Rhomeset, "Base.include(Main,\"", system.file("julia/setup.jl", : Error happens when you try to execute command ENV["R_HOME"] = "/usr/lib/R";Base.include(Main,"/home/hwb/R/x86_64-pc-linux-gnu-library/4.3/JuliaCall/julia/setup.jl") in Julia. To have more helpful error messages, you could considering running the command in Julia directly In addition: Warning message: In system2(file.path(.julia$bin_dir, "julia"), shQuote(command), : running command ''/home/hwb/Programs/julia-1.9.1/bin/julia' '--startup-file=no' '/home/hwb/R/x86_64-pc-linux-gnu-library/4.3/JuliaCall/julia/install_dependency.jl' '/usr/lib/R' 2>&1' had status 139

Non-Contradiction commented 1 year ago

@hwborchers It seems that the dependency for JuliaCall on the julia side is missing, which is resulted from the failure in the installation script (the last warning). The most direct way to correct this is to open julia and run `using Pkg; Pkg.add("Suppressor"); Pkg.add("RCall") on the julia side, which should finish the installation of the dependency of JuliaCall.