简体   繁体   中英

R package not available in batch mode

I have been running a bash script (under Ubuntu) that calls and runs some R scripts to plot some maps with ggplot2. As it is a production system I don't update any new R or package releases. But recently I tried to install plotly with an error message output.

Now, when trying to run the script (calling a php webpage trhough a browser; that was running fine for a lot of time) an error with crayon package halts and exits the script without plotting the maps.

    '/usr/lib/R/bin/R --slave --no-restore --no-save --no-restore --file=./RAMS-mapa-onades-zones-manual.R'
    Loading required package: sp
    Loading required package: methods
    Checking rgeos availability: TRUE
    Error : .onLoad failed in loadNamespace() for 'pillar', details:
      call: loadNamespace(name)
      error: there is no package called 'crayon'
    Error: package or namespace load failed for 'ggplot2'
    Execution halted

But if I run from a terminal or with RStudio server crayon package is loaded, ggplot2 is also properly loaded, and the maps are produced.

crayon package (located at /home/meteo/R/i686-pc-linux-gnu-library/3.1 ) called as

library("crayon", lib.loc= c("/home/meteo/R/i686-pc-linux-gnu-library/3.1", "/usr/local/lib/R/site-library", "/usr/lib/R/library"))

R session info on Rstudio Server:

> sessionInfo()
R version 3.2.2 (2015-08-14)
Platform: i686-pc-linux-gnu (32-bit)
Running under: Ubuntu precise (12.04.5 LTS)

locale:
 [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C         LC_TIME=C            LC_COLLATE=C         LC_MONETARY=C        LC_MESSAGES=C       
 [7] LC_PAPER=C           LC_NAME=C            LC_ADDRESS=C         LC_TELEPHONE=C       LC_MEASUREMENT=C     LC_IDENTIFICATION=C 

attached base packages:
[1] grid      stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
 [1] crayon_1.3.4    rgdal_0.9-1     rgeos_0.3-8     raster_2.3-24   gpclib_1.5-5    mapproj_1.2-2   maps_2.3-9     
 [8] stringr_0.6.2   plyr_1.8.1      ggplot2_3.2.0   maptools_0.8-34 sp_1.2-3       

loaded via a namespace (and not attached):
 [1] Rcpp_1.0.1       magrittr_1.5     tidyselect_0.2.5 munsell_0.5.0    colorspace_1.2-4 lattice_0.20-33  R6_2.4.0        
 [8] rlang_0.3.4      dplyr_0.8.1      tools_3.2.2      gtable_0.1.2     withr_2.1.2      digest_0.6.8     lazyeval_0.2.2  
[15] assertthat_0.2.1 tibble_2.1.3     purrr_0.3.2      glue_1.3.1       labeling_0.3     pillar_1.4.1     scales_1.0.0    
[22] foreign_0.8-66   pkgconfig_2.0.2

Maybe there is a version conflict? How do I check?

what version of R is in /usr/lib/R/bin/R ? Basically it appears you are in a slight "dependency hell" I would run /usr/lib/R/bin/R and check to see if crayon is installed there. @Alexis is correct though, it is not wise to mix versions like that. Let R handle library location unless you are trying to separate packages. Check the libraries for 3.2.2 and see if crayon is installed. you may have switched your R version since plotly depends on R >=3.2.0 https://cran.r-project.org/web/packages/plotly/

I think the easy fix would be to correct your .libpaths() ie not call the 3.1 library and install the correct version of the packages you need.

OR

switch from R 3.2 back to R 3.1

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM