rstudio / packrat

Packrat is a dependency management system for R
http://rstudio.github.io/packrat/
401 stars 89 forks source link

cannot open file 'packrat/init.R': No such file or directory in docker container. #503

Open FabianHertwig opened 5 years ago

FabianHertwig commented 5 years ago

Hi,

I want to use packrat to restore a R environment inside a docker container which gets deployed in openshift. So the commands I run are

Rscript -e "packrat::restore()"

and then I want to install another package

Rscript -e 'install.packages("jsonlite")'

which leads to the following output and error.

sh-4.2$ R                                                                                                                                                                                                      
                                                                                                                                                                                                               
R version 3.5.0 (2018-04-23) -- "Joy in Playing"                                                                                                                                                               
Copyright (C) 2018 The R Foundation for Statistical Computing                                                                                                                                                  
Platform: x86_64-redhat-linux-gnu (64-bit)                                                                                                                                                                     
                                                                                                                                                                                                               
R is free software and comes with ABSOLUTELY NO WARRANTY.                                                                                                                                                      
You are welcome to redistribute it under certain conditions.                                                                                                                                                   
Type 'license()' or 'licence()' for distribution details.                                                                                                                                                      
                                                                                                                                                                                                               
  Natural language support but running in an English locale                                                                                                                                                    
                                                                                                                                                                                                               
R is a collaborative project with many contributors.                                                                                                                                                           
Type 'contributors()' for more information and                                                                                                                                                                 
'citation()' on how to cite R or R packages in publications.                                                                                                                                                   
                                                                                                                                                                                                               
Type 'demo()' for some demos, 'help()' for on-line help, or                                                                                                                                                    
'help.start()' for an HTML browser interface to help.                                                                                                                                                          
Type 'q()' to quit R.                                                                                                                                                                                          
                                                                                                                                                                                                               
Packrat mode on. Using library in directory:                                                                                                                                                                   
- "/opt/app-root/src/packrat/lib"                                                                                                                                                                              
> install.packages("jsonlite")                                                                                                                                                                                 
Installing package into ‘/opt/app-root/src/packrat/lib/x86_64-redhat-linux-gnu/3.5.0’                                                                                                                          
(as ‘lib’ is unspecified)                                                                                                                                                                                      
trying URL 'http://cran.rstudio.com/src/contrib/jsonlite_1.5.tar.gz'                                                                                                                                           
Content type 'application/x-gzip' length 1096810 bytes (1.0 MB)                                                                                                                                                
==================================================                                                                                                                                                             
downloaded 1.0 MB                                                                                                                                                                                              
                                                                                                                                                                                                               
* installing *source* package ‘jsonlite’ ...                                                                                                                                                                   
** package ‘jsonlite’ successfully unpacked and MD5 sums checked                                                                                                                                               
** libs                                                                                                                                                                                                        
gcc -m64 -std=gnu99 -I"/usr/include/R" -DNDEBUG -Iyajl/api  -I/usr/local/include   -fpic  -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-g
mtune=generic  -c base64.c -o base64.o                                                                                                                                                                         
Killed                                                                                                                                                                                                         
sh-4.2$ gcc -m64 -std=gnu99 -I"/usr/include/R" -DNDEBUG -Iyajl/api  -I/usr/local/include   -fpic  -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -g
  -m64 -mtune=generic  -c collapse_array.c -o collapse_array.o                                                                                                                                                 
gcc -m64 -std=gnu99 -I"/usr/include/R" -DNDEBUG -Iyajl/api  -I/usr/local/include   -fpic  -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-g
mtune=generic  -c collapse_object.c -o collapse_object.o                                                                                                                                                       
gcc -m64 -std=gnu99 -I"/usr/include/R" -DNDEBUG -Iyajl/api  -I/usr/local/include   -fpic  -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-g
mtune=generic  -c collapse_pretty.c -o collapse_pretty.o                                                                                                                                                       
gcc -m64 -std=gnu99 -I"/usr/include/R" -DNDEBUG -Iyajl/api  -I/usr/local/include   -fpic  -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-g
mtune=generic  -c escape_chars.c -o escape_chars.o                                                                                                                                                             
gcc -m64 -std=gnu99 -I"/usr/include/R" -DNDEBUG -Iyajl/api  -I/usr/local/include   -fpic  -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-g
mtune=generic  -c integer64_to_na.c -o integer64_to_na.o                                                                                                                                                       
gcc -m64 -std=gnu99 -I"/usr/include/R" -DNDEBUG -Iyajl/api  -I/usr/local/include   -fpic  -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-g
mtune=generic  -c is_datelist.c -o is_datelist.o                                                                                                                                                               
gcc -m64 -std=gnu99 -I"/usr/include/R" -DNDEBUG -Iyajl/api  -I/usr/local/include   -fpic  -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-g
mtune=generic  -c is_recordlist.c -o is_recordlist.o 

gcc -m64 -std=gnu99 -I"/usr/include/R" -DNDEBUG -Iyajl/api  -I/usr/local/include   -fpic  -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-g
mtune=generic  -c is_scalarlist.c -o is_scalarlist.o                                                                                                                                                           
gcc -m64 -std=gnu99 -I"/usr/include/R" -DNDEBUG -Iyajl/api  -I/usr/local/include   -fpic  -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-g
mtune=generic  -c modp_numtoa.c -o modp_numtoa.o                                                                                                                                                               
gcc -m64 -std=gnu99 -I"/usr/include/R" -DNDEBUG -Iyajl/api  -I/usr/local/include   -fpic  -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-g
mtune=generic  -c null_to_na.c -o null_to_na.o                                                                                                                                                                 
gcc -m64 -std=gnu99 -I"/usr/include/R" -DNDEBUG -Iyajl/api  -I/usr/local/include   -fpic  -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-g
mtune=generic  -c num_to_char.c -o num_to_char.o                                                                                                                                                               
gcc -m64 -std=gnu99 -I"/usr/include/R" -DNDEBUG -Iyajl/api  -I/usr/local/include   -fpic  -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-g
mtune=generic  -c parse.c -o parse.o                                                                                                                                                                           
gcc -m64 -std=gnu99 -I"/usr/include/R" -DNDEBUG -Iyajl/api  -I/usr/local/include   -fpic  -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-g
mtune=generic  -c prettify.c -o prettify.o                                                                                                                                                                     
gcc -m64 -std=gnu99 -I"/usr/include/R" -DNDEBUG -Iyajl/api  -I/usr/local/include   -fpic  -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-g
mtune=generic  -c push_parser.c -o push_parser.o                                                                                                                                                               
gcc -m64 -std=gnu99 -I"/usr/include/R" -DNDEBUG -Iyajl/api  -I/usr/local/include   -fpic  -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-g
mtune=generic  -c r-base64.c -o r-base64.o                                                                                                                                                                     
gcc -m64 -std=gnu99 -I"/usr/include/R" -DNDEBUG -Iyajl/api  -I/usr/local/include   -fpic  -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-g
mtune=generic  -c register.c -o register.o                                                                                                                                                                     
gcc -m64 -std=gnu99 -I"/usr/include/R" -DNDEBUG -Iyajl/api  -I/usr/local/include   -fpic  -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-g
mtune=generic  -c row_collapse.c -o row_collapse.o                                                                                                                                                             
gcc -m64 -std=gnu99 -I"/usr/include/R" -DNDEBUG -Iyajl/api  -I/usr/local/include   -fpic  -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-g
mtune=generic  -c transpose_list.c -o transpose_list.o                                                                                                                                                         
gcc -m64 -std=gnu99 -I"/usr/include/R" -DNDEBUG -Iyajl/api  -I/usr/local/include   -fpic  -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-g
mtune=generic  -c validate.c -o validate.o                                                                                                                                                                     
gcc -m64 -std=gnu99 -I"/usr/include/R" -DNDEBUG -Iyajl/api  -I/usr/local/include   -fpic  -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-g
mtune=generic  -c yajl/yajl.c -o yajl/yajl.o                                                                                                                                                                   
gcc -m64 -std=gnu99 -I"/usr/include/R" -DNDEBUG -Iyajl/api  -I/usr/local/include   -fpic  -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-g
mtune=generic  -c yajl/yajl_alloc.c -o yajl/yajl_alloc.o                                                                                                                                                       
gcc -m64 -std=gnu99 -I"/usr/include/R" -DNDEBUG -Iyajl/api  -I/usr/local/include   -fpic  -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-g
mtune=generic  -c yajl/yajl_buf.c -o yajl/yajl_buf.o                                                                                                                                                           
gcc -m64 -std=gnu99 -I"/usr/include/R" -DNDEBUG -Iyajl/api  -I/usr/local/include   -fpic  -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-g
mtune=generic  -c yajl/yajl_encode.c -o yajl/yajl_encode.o                                                                                                                                                     
gcc -m64 -std=gnu99 -I"/usr/include/R" -DNDEBUG -Iyajl/api  -I/usr/local/include   -fpic  -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-g
mtune=generic  -c yajl/yajl_gen.c -o yajl/yajl_gen.o                                                                                                                                                           
gcc -m64 -std=gnu99 -I"/usr/include/R" -DNDEBUG -Iyajl/api  -I/usr/local/include   -fpic  -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-g
mtune=generic  -c yajl/yajl_lex.c -o yajl/yajl_lex.o                                                                                                                                                           
gcc -m64 -std=gnu99 -I"/usr/include/R" -DNDEBUG -Iyajl/api  -I/usr/local/include   -fpic  -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-g
mtune=generic  -c yajl/yajl_parser.c -o yajl/yajl_parser.o                                                                                                                                                     
gcc -m64 -std=gnu99 -I"/usr/include/R" -DNDEBUG -Iyajl/api  -I/usr/local/include   -fpic  -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-g
mtune=generic  -c yajl/yajl_tree.c -o yajl/yajl_tree.o                                                                                                                                                         
ar rcs libstatyajl.a yajl/yajl.o yajl/yajl_alloc.o yajl/yajl_buf.o yajl/yajl_encode.o yajl/yajl_gen.o yajl/yajl_lex.o yajl/yajl_parser.o yajl/yajl_tree.o                                                      
gcc -m64 -std=gnu99 -shared -L/usr/lib64/R/lib -Wl,-z,relro -o jsonlite.so base64.o collapse_array.o collapse_object.o collapse_pretty.o escape_chars.o integer64_to_na.o is_datelist.o is_recordlist.o is_scal
.o null_to_na.o num_to_char.o parse.o prettify.o push_parser.o r-base64.o register.o row_collapse.o transpose_list.o validate.o -L. -lstatyajl -L/usr/lib64/R/lib -lR                                          
installing to /opt/app-root/src/packrat/lib/x86_64-redhat-linux-gnu/3.5.0/jsonlite/libs                                                                                                                        
** R        

** inst                                                                                                                                                                                                        
** byte-compile and prepare package for lazy loading                                                                                                                                                           
** help                                                                                                                                                                                                        
*** installing help indices                                                                                                                                                                                    
Warning in file.copy(file.path(R.home("doc"), "html", "R.css"), outman) :                                                                                                                                      
  problem copying /usr/share/doc/R-3.5.0/html/R.css to /opt/app-root/src/packrat/lib/x86_64-redhat-linux-gnu/3.5.0/jsonlite/html/R.css: No such file or directory                                              
  converting help for package ‘jsonlite’                                                                                                                                                                       
    finding HTML links ... done                                                                                                                                                                                
    base64                                  html                                                                                                                                                               
    flatten                                 html                                                                                                                                                               
    fromJSON                                html                                                                                                                                                               
    prettify                                html                                                                                                                                                               
    rbind_pages                             html                                                                                                                                                               
Rd warning: /tmp/RtmpmcGHc8/R.INSTALL3315498b62/jsonlite/man/rbind_pages.Rd:22: file link ‘rbind’ in package ‘base’ does not exist and so has been treated as a topic                                          
    read_json                               html                                                                                                                                                               
    serializeJSON                           html                                                                                                                                                               
    stream_in                               html                                                                                                                                                               
    unbox                                   html                                                                                                                                                               
    validate                                html                                                                                                                                                               
** building package indices                                                                                                                                                                                    
** installing vignettes                                                                                                                                                                                        
** testing if installed package can be loaded                                                                                                                                                                  
Error in file(filename, "r", encoding = encoding) :                                                                                                                                                            
  cannot open the connection                                                                                                                                                                                   
Calls: source -> file                                                                                                                                                                                          
In addition: Warning message:                                                                                                                                                                                  
In file(filename, "r", encoding = encoding) :                                                                                                                                                                  
  cannot open file 'packrat/init.R': No such file or directory                                                                                                                                                 
Execution halted                                                                                                                                                                                               
ERROR: loading failed                                                                                                                                                                                          
* removing ‘/opt/app-root/src/packrat/lib/x86_64-redhat-linux-gnu/3.5.0/jsonlite’ 

The same message appears when I open a bash session inside the docker container and try to install the package with an interactive R session. Any idea what is wrong and what I can do to start troubleshooting?

colearendt commented 5 years ago

Can you share a bit more about the dockerfile you are using? How do you get the packrat.lock file into the container? This sounds to me like it may be a better fit for https://community.rstudio.com

In any case, a certain paradigm of Docker examples w/ Packrat are available here and here. There are many other paradigms to follow, though. I would take a look particularly at what files are in your local directory vs. in the docker image, file permissions, .libPaths() (where you are installing jsonlite), whether packrat::on() works, and other such poking.