CINXE.COM

Project Environments • renv

<!DOCTYPE html> <!-- Generated by pkgdown: do not edit by hand --><html lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> <title>Project Environments • renv</title> <!-- favicons --><link rel="icon" type="image/png" sizes="16x16" href="favicon-16x16.png"> <link rel="icon" type="image/png" sizes="32x32" href="favicon-32x32.png"> <link rel="apple-touch-icon" type="image/png" sizes="180x180" href="apple-touch-icon.png"> <link rel="apple-touch-icon" type="image/png" sizes="120x120" href="apple-touch-icon-120x120.png"> <link rel="apple-touch-icon" type="image/png" sizes="76x76" href="apple-touch-icon-76x76.png"> <link rel="apple-touch-icon" type="image/png" sizes="60x60" href="apple-touch-icon-60x60.png"> <script src="deps/jquery-3.6.0/jquery-3.6.0.min.js"></script><meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> <link href="deps/bootstrap-5.3.1/bootstrap.min.css" rel="stylesheet"> <script src="deps/bootstrap-5.3.1/bootstrap.bundle.min.js"></script><link href="deps/Source_Sans_Pro-0.4.9/font.css" rel="stylesheet"> <link href="deps/Source_Code_Pro-0.4.9/font.css" rel="stylesheet"> <link href="deps/font-awesome-6.5.2/css/all.min.css" rel="stylesheet"> <link href="deps/font-awesome-6.5.2/css/v4-shims.min.css" rel="stylesheet"> <script src="deps/headroom-0.11.0/headroom.min.js"></script><script src="deps/headroom-0.11.0/jQuery.headroom.min.js"></script><script src="deps/bootstrap-toc-1.0.1/bootstrap-toc.min.js"></script><script src="deps/clipboard.js-2.0.11/clipboard.min.js"></script><script src="deps/search-1.0.0/autocomplete.jquery.min.js"></script><script src="deps/search-1.0.0/fuse.min.js"></script><script src="deps/search-1.0.0/mark.min.js"></script><!-- pkgdown --><script src="pkgdown.js"></script><link href="extra.css" rel="stylesheet"> <meta property="og:title" content="Project Environments"> <meta name="description" content="A dependency management toolkit for R. Using renv, you can create and manage project-local R libraries, save the state of these libraries to a lockfile, and later restore your library as required. Together, these tools can help make your projects more isolated, portable, and reproducible."> <meta property="og:description" content="A dependency management toolkit for R. Using renv, you can create and manage project-local R libraries, save the state of these libraries to a lockfile, and later restore your library as required. Together, these tools can help make your projects more isolated, portable, and reproducible."> <meta property="og:image" content="https://rstudio.github.io/renv/logo.svg"> <!-- Google Tag Manager --><script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start': new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src='https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);})(window,document,'script','dataLayer','GTM-KHBDBW7');</script><!-- End Google Tag Manager --> </head> <body> <a href="#container" class="visually-hidden-focusable">Skip to content</a> <nav class="navbar navbar-expand-lg fixed-top bg-none" data-bs-theme="light" aria-label="Site navigation"><div class="container"> <a class="navbar-brand me-2" href="index.html">renv</a> <small class="nav-text text-muted me-auto" data-bs-toggle="tooltip" data-bs-placement="bottom" title="Released version">1.1.1</small> <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbar" aria-controls="navbar" aria-expanded="false" aria-label="Toggle navigation"> <span class="navbar-toggler-icon"></span> </button> <div id="navbar" class="collapse navbar-collapse ms-3"> <ul class="navbar-nav me-auto"> <li class="nav-item"><a class="nav-link" href="articles/renv.html">Get started</a></li> <li class="nav-item"><a class="nav-link" href="reference/index.html">Reference</a></li> <li class="nav-item dropdown"> <button class="nav-link dropdown-toggle" type="button" id="dropdown-articles" data-bs-toggle="dropdown" aria-expanded="false" aria-haspopup="true">Articles</button> <ul class="dropdown-menu" aria-labelledby="dropdown-articles"> <li><hr class="dropdown-divider"></li> <li><h6 class="dropdown-header" data-toc-skip>Basics</h6></li> <li><a class="dropdown-item" href="articles/package-sources.html">Package sources</a></li> <li><a class="dropdown-item" href="articles/package-install.html">Installing packages</a></li> <li><a class="dropdown-item" href="articles/python.html">Using Python with renv</a></li> <li><a class="dropdown-item" href="articles/faq.html">Frequently asked questions</a></li> <li><a class="dropdown-item" href="articles/packrat.html">packrat vs. renv</a></li> <li><hr class="dropdown-divider"></li> <li><h6 class="dropdown-header" data-toc-skip>Deployment</h6></li> <li><a class="dropdown-item" href="articles/ci.html">Using renv with continuous integration</a></li> <li><a class="dropdown-item" href="articles/docker.html">Using renv with Docker</a></li> <li><a class="dropdown-item" href="articles/rsconnect.html">Using renv with Posit Connect</a></li> <li><hr class="dropdown-divider"></li> <li><h6 class="dropdown-header" data-toc-skip>Advanced</h6></li> <li><a class="dropdown-item" href="articles/packages.html">Package development</a></li> <li><a class="dropdown-item" href="articles/profiles.html">Project profiles</a></li> </ul> </li> <li class="nav-item"><a class="nav-link" href="news/index.html">Changelog</a></li> </ul> <ul class="navbar-nav"> <li class="nav-item"><form class="form-inline" role="search"> <input class="form-control" type="search" name="search-input" id="search-input" autocomplete="off" aria-label="Search site" placeholder="Search for" data-search-index="search.json"> </form></li> <li class="nav-item"><a class="external-link nav-link" href="https://github.com/rstudio/renv/" aria-label="GitHub"><span class="fa fab fa-github fa-lg"></span></a></li> </ul> </div> </div> </nav><div class="container template-home" id="container"> <div class="row"> <main id="main" class="col-md-9"><div class="section level1"> <div class="page-header"> <img src="logo.svg" class="logo" alt=""><h1 id="renv-">renv <a class="anchor" aria-label="anchor" href="#renv-"></a> </h1> </div> <!-- badges: start --> <!-- badges: end --> <div class="section level2"> <h2 id="overview">Overview<a class="anchor" aria-label="anchor" href="#overview"></a> </h2> <p>The renv package<a class="footnote-ref" tabindex="0" data-bs-toggle="popover" data-bs-content="&lt;p&gt;Pronounced “R” “env”&lt;/p&gt;"><sup>1</sup></a> helps you create <strong>r</strong>eproducible <strong>env</strong>ironments for your R projects. Use renv to make your R projects more isolated, portable and reproducible.</p> <ul> <li> <strong>Isolated</strong>: Installing a new or updated package for one project won’t break your other projects, and vice versa. That’s because renv gives each project its own private library.</li> <li> <strong>Portable</strong>: Easily transport your projects from one computer to another, even across different platforms. renv makes it easy to install the packages your project depends on.</li> <li> <strong>Reproducible</strong>: renv records the exact package versions you depend on, and ensures those exact versions are the ones that get installed wherever you go.</li> </ul> </div> <div class="section level2"> <h2 id="installation">Installation<a class="anchor" aria-label="anchor" href="#installation"></a> </h2> <p>Install the latest version of renv from CRAN with:</p> <div class="sourceCode" id="cb1"><pre class="downlit sourceCode r"> <code class="sourceCode R"><span><span class="fu"><a href="https://rdrr.io/r/utils/install.packages.html" class="external-link">install.packages</a></span><span class="op">(</span><span class="st">"renv"</span><span class="op">)</span></span></code></pre></div> </div> <div class="section level2"> <h2 id="workflow">Workflow<a class="anchor" aria-label="anchor" href="#workflow"></a> </h2> <p><img src="articles/renv.png" alt="A diagram showing the most important verbs and nouns of renv. Projects start with init(), which creates a project library using packages from the system library. snapshot() updates the lockfile using the packages installed in the project library, where restore() installs packages into the project library using the metadata from the lockfile, and status() compares the lockfile to the project library. You install and update packages from CRAN and GitHub using install() and update(), but because you'll need to do this for multiple projects, renv uses cache to make this fast." width="408" style="display: block; margin: auto;"></p> <p>Use <code><a href="reference/init.html">renv::init()</a></code> to initialize renv in a new or existing project. This will set up a <strong>project library</strong>, containing all the packages you’re currently using. The packages (and all the metadata needed to reinstall them) are recorded into a <strong>lockfile</strong>, <code>renv.lock</code>, and a <code>.Rprofile</code> ensures that the library is used every time you open that project.</p> <p>As you continue to work on your project, you will install and upgrade packages, either using <code><a href="https://rdrr.io/r/utils/install.packages.html" class="external-link">install.packages()</a></code> and <code><a href="https://rdrr.io/r/utils/update.packages.html" class="external-link">update.packages()</a></code> or <code><a href="reference/install.html">renv::install()</a></code> and <code><a href="reference/update.html">renv::update()</a></code>. After you’ve confirmed your code works as expected, use <code><a href="reference/snapshot.html">renv::snapshot()</a></code> to record the packages and their sources in the lockfile.</p> <p>Later, if you need to share your code with someone else or run your code on new machine, your collaborator (or you) can call <code><a href="reference/restore.html">renv::restore()</a></code> to reinstall the specific package versions recorded in the lockfile.</p> </div> <div class="section level2"> <h2 id="learning-more">Learning more<a class="anchor" aria-label="anchor" href="#learning-more"></a> </h2> <p>If this is your first time using renv, we strongly recommend starting with the <a href="https://rstudio.github.io/renv/articles/renv.html">Introduction to renv</a> vignette: this will help you understand the most important verbs and nouns of renv.</p> <p>If you have a question about renv, please first check the <a href="https://rstudio.github.io/renv/articles/faq.html">FAQ</a> to see whether your question has already been addressed. If it hasn’t, please feel free to ask on the <a href="https://forum.posit.co" class="external-link">Posit Forum</a>.</p> <p>If you believe you’ve found a bug in renv, please file a bug (and, if possible, a <a href="https://reprex.tidyverse.org" class="external-link">reproducible example</a>) at <a href="https://github.com/rstudio/renv/issues" class="external-link uri">https://github.com/rstudio/renv/issues</a>.</p> </div> </div> </main><aside class="col-md-3"><div class="links"> <h2 data-toc-skip>Links</h2> <ul class="list-unstyled"> <li><a href="https://cloud.r-project.org/package=renv" class="external-link">View on CRAN</a></li> <li><a href="https://github.com/rstudio/renv/" class="external-link">Browse source code</a></li> <li><a href="https://github.com/rstudio/renv/issues" class="external-link">Report a bug</a></li> </ul> </div> <div class="license"> <h2 data-toc-skip>License</h2> <ul class="list-unstyled"> <li> <a href="https://opensource.org/licenses/mit-license.php" class="external-link">MIT</a> + file <a href="LICENSE-text.html">LICENSE</a> </li> </ul> </div> <div class="citation"> <h2 data-toc-skip>Citation</h2> <ul class="list-unstyled"> <li><a href="authors.html#citation">Citing renv</a></li> </ul> </div> <div class="developers"> <h2 data-toc-skip>Developers</h2> <ul class="list-unstyled"> <li>Kevin Ushey <br><small class="roles"> Author, maintainer </small> <a href="https://orcid.org/0000-0003-2880-7407" target="orcid.widget" aria-label="ORCID" class="external-link"><span class="fab fa-orcid orcid" aria-hidden="true"></span></a> </li> <li> <a href="https://hadley.nz" class="external-link">Hadley Wickham</a> <br><small class="roles"> Author </small> <a href="https://orcid.org/0000-0003-4757-117X" target="orcid.widget" aria-label="ORCID" class="external-link"><span class="fab fa-orcid orcid" aria-hidden="true"></span></a> </li> <li> <a href="https://www.posit.co" class="external-link"><img src="https://www.tidyverse.org/posit-logo.svg" alt="Posit" height="16" width="62" style="margin-bottom: 3px;"></a> <br><small class="roles"> Copyright holder, funder </small> </li> </ul> </div> </aside> </div> </div> <footer><div class="container"> <div class="pkgdown-footer-left"> <p>Developed by Kevin Ushey, <a href="https://hadley.nz" class="external-link">Hadley Wickham</a>, <a href="https://www.posit.co" class="external-link"><img src="https://www.tidyverse.org/posit-logo.svg" alt="Posit" height="16" width="62" style="margin-bottom: 3px;"></a>.</p> </div> <div class="pkgdown-footer-right"> <p>Site built with <a href="https://pkgdown.r-lib.org/" class="external-link">pkgdown</a> 2.1.1.</p> </div> </div></footer><!-- Google Tag Manager (noscript) --><noscript><iframe src="https://www.googletagmanager.com/ns.html?id=GTM-KHBDBW7" height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript> <!-- End Google Tag Manager (noscript) --> </body> </html>

Pages: 1 2 3 4 5 6 7 8 9 10