简体   繁体   中英

Installing R package from source using docker file

I am trying to install an r package from source using the dockerfile. Like seen here (using ggplot2 for simplicity)

FROM rocker/r-ver

COPY . /usr/local/src/myscripts
WORKDIR /usr/local/src/myscripts

RUN R -e 'install.packages("ggplot2_3.0.0.tar.gz", repos = NULL, type = "source")'

CMD ["Rscript", "run.R"]

Once I build the image I get this error

> install.packages("ggplot2_3.0.0.tar.gz", repos = NULL, type = "source")
Installing package into ‘/usr/local/lib/R/site-library’
(as ‘lib’ is unspecified)
ERROR: dependencies ‘digest’, ‘gtable’, ‘lazyeval’, ‘plyr’, ‘reshape2’, 
‘rlang’, ‘scales’, ‘tibble’, ‘viridisLite’, ‘withr’ are not available for 
package ‘ggplot2’
* removing ‘/usr/local/lib/R/site-library/ggplot2’
Warning message:
In install.packages("ggplot2_3.0.0.tar.gz", repos = NULL, type = "source") 
:>
> installation of package ‘ggplot2_3.0.0.tar.gz’ had non-zero exit status

The files included in the docker folder can be seen here

Does anyone know what I need to add to the dockerfile to solve (if possible) this error?

Since you set repos = NULL , you will need to install all of the mentioned dependencies first — and their dependencies before that. You can do this manually but figuring out all dependencies is going to be a hassle, and is subject to change with every update.

It's therefore probably better to use a local package manager. I have no personal experience with any of them but you can give {miniCRAN} a try.

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