JuliaInterop / JuliaCall

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

`julia_setup()` cannot find Julia #91

Closed aguang closed 5 years ago

aguang commented 5 years ago

This may be related to the many other issues that appear to be open with julia_setup(). When I run it with no arguments as described in Basic Usage I get that Julia is not found. It is fine when I supply my own path, but this suggests that julia_setup() has issues actually finding my Julia installation.

> julia <- julia_setup()
sh: NA: command not found
Error in julia_setup() : Julia is not found.
In addition: Warning message:
In system2("bash", "-l -c 'which julia'", stdout = TRUE) :
  running command ''bash' -l -c 'which julia'' had status 1

> julia <- julia_setup(JULIA_HOME= "/Applications/Julia-1.1.app/Contents/Resources/julia/bin/")
Julia version 1.1.0 at location /Applications/Julia-1.1.app/Contents/Resources/julia/bin will be used.
Loading setup script for JuliaCall...
Finish loading setup script for JuliaCall.
Session Info > sessionInfo() R version 3.5.1 (2018-07-02) Platform: x86_64-apple-darwin15.6.0 (64-bit) Running under: macOS 10.14.3 Matrix products: default BLAS: /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib LAPACK: /Library/Frameworks/R.framework/Versions/3.5/Resources/lib/libRlapack.dylib locale: [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8 attached base packages: [1] stats graphics grDevices utils datasets methods base other attached packages: [1] JuliaCall_0.16.4 loaded via a namespace (and not attached): [1] compiler_3.5.1 tools_3.5.1 yaml_2.2.0 Rcpp_1.0.0 knitr_1.21 xfun_0.5
Non-Contradiction commented 5 years ago

Thanks for the feedback!

It seems that there is no Julia installation on PATH, and the Julia installation can't be invoked by just julia in the terminal, which is why there is the warning message running command ''bash' -l -c 'which julia'' had status 1. This is the current design of julia_setup, which either looks for Julia at the location provided by the user or looks for Julia in the PATH, which is a reasonable solution plausible on all os systems (but not ideal). Also, it is documented in README and the R package documentation.

An ideal solution is to try to find Julia harder in a system specific way if the current mechanism fails. For example, JuliaCall may look at /Applications/ folder on mac for Julia, and it can invoke that Julia if there is only one Julia at paths like /Applications/Julia-x.x.app (since it is possible to have multiple versions of Julia at the same time).

I will try to implement the ideal solution step by step when I have time. Thank you for the suggestion!

aguang commented 5 years ago

That sounds fine to me. I would also suggest either

1) documenting that julia_setup() will look within PATH earlier in the Basic Usage section, so that if it can't find it it means that Julia is not within your PATH (for example, I use the alias solution to run from terminal with OSX), or 2) referencing the Troubleshooting section in Basic Usage for any errors with julia_setup().

I understand that this seems to be a OSX specific issue, since all other OSes will allow you to run from command line immediately.

aguang commented 5 years ago

Linking to openjournals/joss-reviews#1284

Non-Contradiction commented 5 years ago

I will add the reference to the Troubleshooting section in the Basic Usage section. Thanks for the suggestion. BTW, JuliaCall should support the alias solution. This sounds like a bug to me. I will investigate more on the issue.

aguang commented 5 years ago

Looks good to me. No pressure on the alias issue, it is also trivial to make a symbolic link in /usr/local/bin or add Julia to my PATH.