title: How to maintain R (renv) project
body: <p>My colleagues and I are working on a book with Bookdown in RStudio. Since I create a lot of graphics with ggplot and therefore I have many dependencies to other packages (ggplot, ggforce, gganimate, ...), I added renv in the course of the book to take care of package management. After a clean installation of my Windows I do now have problems to set up the project again, because there were updates from R to version 3.6.3 and used packages. </p>
  
  <p>Initial state of the project with renv was R with version 3.6.2, which I reinstalled. After opening the project I run <code>renv::restore()</code> to restore the environment with all packages. Currently only the package nloptr (version 1.2.1) has a bug, because it has to build the package from source. </p>
  
  <pre><code>Installing minqa [1.2.4] ...
      OK (linked cache)
  Installing nloptr [1.2.1] ...
      FAILED
  Error installing package 'nloptr':
  ==================================
  
  * installing *source* package 'nloptr' ...
  ** package 'nloptr' successfully unpacked and MD5 sums checked
  ** using staged installation
  
     **********************************************
     WARNING: this package has a configure script
           It probably needs manual configuration
     **********************************************
  
  
  ** libs
  C:/Rtools/mingw_64/bin/g++ -std=gnu++11  -I"C:/PROGRA~1/R/R-36~1.2/include" -DNDEBUG          -O2 -Wall  -mtune=generic -c dummy.cpp -o dummy.o
  C:/Rtools/mingw_64/bin/gcc  -I"C:/PROGRA~1/R/R-36~1.2/include" -DNDEBUG       -I"/x64/include"   -O2 -Wall  -std=gnu99 -mtune=generic -c init_nloptr.c -o init_nloptr.o
  init_nloptr.c:35:19: fatal error: nlopt.h: No such file or directory
   #include "nlopt.h"
                     ^
  compilation terminated.
  make: *** [C:/PROGRA~1/R/R-36~1.2/etc/x64/Makeconf:208: init_nloptr.o] Error 1
  ERROR: compilation failed for package 'nloptr'
  * removing 'C:/Users/Ralph/DOCUME~1/ML2/ml2-buch/renv/staging/1/nloptr'
  Fehler: install of package 'nloptr' failed
  </code></pre>
  
  <p>To work around this error I install the package manually via: </p>
  
  <pre><code>packageurl &lt;- "https://cran.r-project.org/bin/windows/contrib/3.7/nloptr_1.2.1.zip"
  install.packages(packageurl, repos=NULL, type="binary")
  </code></pre>
  
  <p>After that all packages can be installed but now, many of them show the warning <code>package 'X' was built under R version 3.6.3</code>.</p>
  
  <p>What's the point of <em>renv</em> if it can't restore the original state, because all packages have been changed by an update of R? How can I manage an R project properly ?  </p>