Non-Contradiction / JuliaCall

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

Error running package with JuliaCall #97

Open wpeterman opened 5 years ago

wpeterman commented 5 years ago

I'm trying to use JuliaCall to run Circuitscape from R. This works fine on several different computer I have access to, but not on one. It seems that something is missing or preventing JuliaCall from working properly. The above listed package works fine when executed directly from Julia, so it is not an issue with that package. Any ideas of what is missing or mis-configured on my computer that is causing this issue?

Error Message:

Error: Error happens in Julia.
error compiling read_cellmap: error compiling _ascii_grid_reader: error compiling gzopen: could not load library "zlib1"
The specified module could not be found.

Stacktrace:
 [1] load_raster_data(::Type, ::Type, ::Dict{String,String}) at C:\Users\peterman.73\.julia\packages\Circuitscape\1UJ9H\src\io.jl:410
 [2] raster_pairwise(::Type, ::Type, ::Dict{String,String}) at C:\Users\peterman.73\.julia\packages\Circuitscape\1UJ9H\src\raster\pairwise.jl:18
 [3] _compute(::Type, ::Type, ::Dict{String,String}) at C:\Users\peterman.73\.julia\packages\Circuitscape\1UJ9H\src\run.jl:42
 [4] macro expansion at .\util.jl:213 [inlined]
 [5] compute(::String) at C:\Users\peterman.73\.julia\packages\Circuitscape\1UJ9H\src\run.jl:31
 [6] docall(::Ptr{Nothing}) at C:\Program Files\R\R-3.5.3\library\JuliaCall\julia\setup.jl:168 

The noted zlib1 is in the Julia bin folder.

Any thoughts will be greatly appreciated!

Session Info ```r - Session info ---------------------------------------------------------------------------------------------------------------- setting value version R version 3.5.3 (2019-03-11) os Windows 7 x64 SP 1 system x86_64, mingw32 ui RStudio language (EN) collate English_United States.1252 ctype English_United States.1252 tz America/New_York date 2019-03-16 - Packages -------------------------------------------------------------------------------------------------------------------- package * version date lib source abind 1.4-5 2016-07-21 [1] CRAN (R 3.5.2) akima 0.6-2 2016-12-20 [1] CRAN (R 3.5.3) assertthat 0.2.0 2017-04-11 [1] CRAN (R 3.5.3) backports 1.1.3 2018-12-14 [1] CRAN (R 3.5.2) boot 1.3-20 2017-08-06 [1] CRAN (R 3.5.3) callr 3.1.1 2018-12-21 [1] CRAN (R 3.5.3) cli 1.0.1 2018-09-25 [1] CRAN (R 3.5.3) codetools 0.2-16 2018-12-24 [1] CRAN (R 3.5.3) colorspace 1.4-0 2019-01-13 [1] CRAN (R 3.5.3) crayon 1.3.4 2017-09-16 [1] CRAN (R 3.5.3) deldir 0.1-16 2019-01-04 [1] CRAN (R 3.5.2) desc 1.2.0 2018-05-01 [1] CRAN (R 3.5.3) devtools 2.0.1 2018-10-26 [1] CRAN (R 3.5.3) digest 0.6.18 2018-10-10 [1] CRAN (R 3.5.3) dplyr 0.8.0.1 2019-02-15 [1] CRAN (R 3.5.3) foreach 1.4.4 2017-12-12 [1] CRAN (R 3.5.3) fs 1.2.6 2018-08-23 [1] CRAN (R 3.5.3) GA 3.2 2019-01-10 [1] CRAN (R 3.5.3) gdistance 1.2-2 2018-05-07 [1] CRAN (R 3.5.3) ggExtra 0.8 2018-04-04 [1] CRAN (R 3.5.3) ggplot2 3.1.0 2018-10-25 [1] CRAN (R 3.5.3) glue 1.3.1 2019-03-12 [1] CRAN (R 3.5.3) goftest 1.1-1 2017-04-03 [1] CRAN (R 3.5.2) gtable 0.2.0 2016-02-26 [1] CRAN (R 3.5.3) htmltools 0.3.6 2017-04-28 [1] CRAN (R 3.5.3) httpuv 1.4.5.1 2018-12-18 [1] CRAN (R 3.5.3) igraph 1.2.4 2019-02-13 [1] CRAN (R 3.5.3) iterators 1.0.10 2018-07-13 [1] CRAN (R 3.5.3) jsonlite 1.6 2018-12-07 [1] CRAN (R 3.5.3) JuliaCall * 0.16.5 2019-03-16 [1] Github (Non-Contradiction/JuliaCall@3a167ba) knitr 1.22 2019-03-08 [1] CRAN (R 3.5.3) labeling 0.3 2014-08-23 [1] CRAN (R 3.5.2) later 0.8.0 2019-02-11 [1] CRAN (R 3.5.3) lattice 0.20-38 2018-11-04 [1] CRAN (R 3.5.3) lazyeval 0.2.1 2017-10-29 [1] CRAN (R 3.5.3) lme4 1.1-21 2019-03-05 [1] CRAN (R 3.5.3) magrittr 1.5 2014-11-22 [1] CRAN (R 3.5.3) MASS 7.3-51.1 2018-11-01 [1] CRAN (R 3.5.3) Matrix 1.2-15 2018-11-01 [1] CRAN (R 3.5.3) memoise 1.1.0 2017-04-21 [1] CRAN (R 3.5.3) mgcv 1.8-27 2019-02-06 [1] CRAN (R 3.5.3) mime 0.6 2018-10-05 [1] CRAN (R 3.5.2) miniUI 0.1.1.1 2018-05-18 [1] CRAN (R 3.5.3) minqa 1.2.4 2014-10-09 [1] CRAN (R 3.5.3) MuMIn 1.42.1 2018-07-23 [1] CRAN (R 3.5.3) munsell 0.5.0 2018-06-12 [1] CRAN (R 3.5.3) nlme 3.1-137 2018-04-07 [1] CRAN (R 3.5.3) nloptr 1.2.1 2018-10-03 [1] CRAN (R 3.5.2) pillar 1.3.1 2018-12-15 [1] CRAN (R 3.5.3) pkgbuild 1.0.2 2018-10-16 [1] CRAN (R 3.5.3) pkgconfig 2.0.2 2018-08-16 [1] CRAN (R 3.5.3) pkgload 1.0.2 2018-10-29 [1] CRAN (R 3.5.3) plyr 1.8.4 2016-06-08 [1] CRAN (R 3.5.3) polyclip 1.10-0 2019-03-14 [1] CRAN (R 3.5.3) prettyunits 1.0.2 2015-07-13 [1] CRAN (R 3.5.3) processx 3.3.0 2019-03-10 [1] CRAN (R 3.5.3) promises 1.0.1 2018-04-13 [1] CRAN (R 3.5.3) ps 1.3.0 2018-12-21 [1] CRAN (R 3.5.3) purrr 0.3.1 2019-03-03 [1] CRAN (R 3.5.3) R6 2.4.0 2019-02-14 [1] CRAN (R 3.5.3) raster * 2.8-19 2019-01-30 [1] CRAN (R 3.5.3) Rcpp 1.0.0 2018-11-07 [1] CRAN (R 3.5.3) remotes 2.0.2 2018-10-30 [1] CRAN (R 3.5.3) ResistanceGA * 4.1-0.24 2019-03-16 [1] local rgdal 1.4-3 2019-03-14 [1] CRAN (R 3.5.3) rlang 0.3.1 2019-01-08 [1] CRAN (R 3.5.3) rpart 4.1-13 2018-02-23 [1] CRAN (R 3.5.3) rprojroot 1.3-2 2018-01-03 [1] CRAN (R 3.5.3) rstudioapi 0.9.0 2019-01-09 [1] CRAN (R 3.5.3) scales 1.0.0 2018-08-09 [1] CRAN (R 3.5.3) sessioninfo 1.1.1 2018-11-05 [1] CRAN (R 3.5.3) shiny 1.2.0 2018-11-02 [1] CRAN (R 3.5.3) sp * 1.3-1 2018-06-05 [1] CRAN (R 3.5.3) spatstat 1.58-2 2019-01-10 [1] CRAN (R 3.5.3) spatstat.data 1.4-0 2018-10-04 [1] CRAN (R 3.5.3) spatstat.utils 1.13-0 2018-10-31 [1] CRAN (R 3.5.3) tensor 1.5 2012-05-05 [1] CRAN (R 3.5.2) tibble 2.0.1 2019-01-12 [1] CRAN (R 3.5.3) tidyselect 0.2.5 2018-10-11 [1] CRAN (R 3.5.3) usethis 1.4.0 2018-08-14 [1] CRAN (R 3.5.3) withr 2.1.2 2018-03-15 [1] CRAN (R 3.5.3) xfun 0.5 2019-02-20 [1] CRAN (R 3.5.3) XR 0.7.2 2018-03-18 [1] CRAN (R 3.5.3) XRJulia 0.7.7 2018-03-18 [1] CRAN (R 3.5.3) xtable 1.8-3 2018-08-29 [1] CRAN (R 3.5.3) yaml 2.2.0 2018-07-25 [1] CRAN (R 3.5.2) [1] C:/Program Files/R/R-3.5.3/library ```
Non-Contradiction commented 5 years ago

Thanks for the feedback. The cause of the problem seems that R cannot find where the zlib1 is. Although the library is just in the bin folder of Julia, the default of R (and other windows applications) is to look into its own bin folder. So Julia can find the library and R cannot. This kind of problem usually happens on an older system, since the older system may not have the (new) dynamical library Julia need. One solution is to add the bin folder of Julia into the PATH environment variable, so R can easily find the library. I hope the solution works for you, and I will investigate whether there is another way for R to find Julia's libraries.

wpeterman commented 5 years ago

Thanks for the quick reply. Unfortunately, adding the bin folder to the PATH didn't correct or change anything.

Non-Contradiction commented 5 years ago

Really? It seems strange. Does the R session start after the setting of the PATH variable?

wpeterman commented 5 years ago

Everything works the same. Seems as though nothing changed with addition of the Julia bin folder to the PATH.

Non-Contradiction commented 5 years ago

From the error message, it seems that the problem is with the GZopen. Is it possible to extract the file and then try again? If you succeed, then the issue is restricted to GZip. By the way, what are the successful OSes? Is one of them also Windows 7?

wpeterman commented 5 years ago

I'm not sure how/why GZip is being called by package I'm using. None of the files used in the analysis are zipped. The inputs are all simple text files (.txt, .asc, and .ini extensions). This has worked fine on three different Windows 7 machines, as well as on a UNIX based super computer.

Non-Contradiction commented 5 years ago

Then I guess it is the compilation procedure that triggers GZip... So GZip will be triggered unless we modify the package's code or suppress Julia's compilation... I'm still not sure why adding the bin folder of Julia into PATH does not solve the problem. Maybe we could set the bin folder as the working directory by setwd?

wpeterman commented 5 years ago

I noticed a difference in the load message between two computers that worked, and the one that currently doesn't. Load and runs code without issue: Julia version 1.1.0 at location C:\Users\Bill\AppData\Local\JULIA-~1.0\bin will be used. Loading setup script for JuliaCall...
Finish loading setup script for JuliaCall.

Loads and completes setup, then throws error when trying to use package: Julia version 1.1.0 at location C:\Users\Bill\AppData\Local\JULIA-~2.0\bin will be used. Loading setup script for JuliaCall...
Finish loading setup script for JuliaCall.

What's the difference between the location folders JULIA-~1.0 and JULIA-~2.0 being called? In both cases I specified JULIA_HOME to be the bin folder in the 1.1.0 directory.

wpeterman commented 5 years ago

Setting the working directory to the bin folder solved the issue! Thanks for your insights and quick replies.

Non-Contradiction commented 5 years ago

I'm happy that the method solved your problem! Although I still don't understand why the PATH solution failed and the working directory solution worked...

BTW, the folder names in the messages are the Windows short form filenames. I'm not sure how they are generated and whether they have anything to do with this particular issue (they have something to do with other problems of JuliaCall on Windows). And they are difficult to deal with (I tried to deal with them in R or Julia but failed). Thank you for bringing this up.