diff --git a/.Rprofile b/.Rprofile new file mode 100644 index 0000000000000000000000000000000000000000..81b960f5c6a8ee40840badd620f8af9743787730 --- /dev/null +++ b/.Rprofile @@ -0,0 +1 @@ +source("renv/activate.R") diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index a58bc532478825cbbafbb3a56ae4d02396504185..9c5b63dc35831f79e71ce1230fd5ed990ff3b40b 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,12 +1,31 @@ +image: rocker/verse:4.0.0 + +variables: + RENV_CONFIG_REPOS_OVERRIDE: "http://cran.r-project.org" + RENV_PATHS_CACHE: ${CI_PROJECT_DIR}/cache + RENV_PATHS_LIBRARY: ${CI_PROJECT_DIR}/renv/library + +cache: + key: ${CI_JOB_NAME} + paths: + - ${RENV_PATHS_CACHE} + - ${RENV_PATHS_LIBRARY} + +before_script: + - Rscript -e "if (!requireNamespace('renv', quietly = TRUE)) install.packages('renv')" + - Rscript -e "install.packages('showtext')" + - Rscript -e "renv::restore()" + pages: stage: deploy script: + - Rscript -e "rmarkdown::render('presentation.Rmd', output_file = 'index.html')" - mkdir public - - cp presentation.html public/index.html - - cp xaringan-themer.css mycss.css public/ - - cp -r images/ libs/ public/ + - cp index.html xaringan-themer.css mycss.css public/ + - cp -r images/ public/ artifacts: paths: - public only: - - main + - test_CICD + interruptible: true diff --git a/presentation.html b/presentation.html deleted file mode 100644 index 7dc94a018faf98f4eeea7d6ebec897a5b577825c..0000000000000000000000000000000000000000 --- a/presentation.html +++ /dev/null @@ -1,559 +0,0 @@ -<!DOCTYPE html> -<html lang="" xml:lang=""> - <head> - <title>L’écosystème Git</title> - <meta charset="utf-8" /> - <meta name="author" content="Elise Maigné" /> - <meta name="date" content="2021-11-22" /> - <script src="libs/header-attrs/header-attrs.js"></script> - <script src="libs/htmlwidgets/htmlwidgets.js"></script> - <script src="libs/viz/viz.js"></script> - <link href="libs/DiagrammeR-styles/styles.css" rel="stylesheet" /> - <script src="libs/grViz-binding/grViz.js"></script> - <script src="libs/pymjs/pym.v1.min.js"></script> - <link rel="stylesheet" href="xaringan-themer.css" type="text/css" /> - <link rel="stylesheet" href="mycss.css" type="text/css" /> - </head> - <body> - <textarea id="source"> -class: center, middle, inverse, title-slide - -# L’écosystème Git -## Git : fonctionnement, outils, possibilités -### Elise Maigné -### 2021-11-22 - ---- - - - - - -class: center, middle - -# git c'est quoi ? -<img src="images/logo_git.png", width="300" height="300"> - ---- -# Git - -Un système de gestion de version (voir [Différence avec SVN](#bonus)). - --- - -Qui permet : - -- De sauvegarder ses codes (si serveur distant) -- De conserver l'historique des fichiers (qui a fait quoi ?) -- Visualiser les changements au cours du temps -- Travailler à plusieurs sur le même code -- Revenir en arrière, changer d'avis, tester une solution dans une branche séparée - --- - -.center[] -.center[] - ---- -# Pourquoi je m'y suis pas mise avant ? - -- 1ers mails sur git remontent à 2013 dans mon équipe et 2014 groupe RR. -- J'avais vraiment du mal à comprendre comment ça marchait et ce que je pouvais faire. -- J'étais perdue au milieu de tous les termes "git/push/github/tortoise". -- Différence de langages entre info/stat - --- - -</br></br> - -.center[ -*"Elise j'ai mis en place un SVN, c'est facile tu synchronyse avec tortoise et tu push tes modifs"* - -] - - ---- -class: center, middle - -# Git et son écosystème -<img src="images/logo_git.png", width="300" height="300"> - ---- -# Etape 1 -#### un projet (de code) que l'on veut versionner -<center> -<img src="images/vocab1.png", width="90%"> -</center> - ---- -# Etape 2 (facultatif sur linux et mac) -#### un logiciel plus sympa que la ligne de commande -<center> -<img src="images/vocab2.png", width="90%"> -</center> ---- -# Etape 3 (facultative) -#### choisir un endroit pour déposer son code -<center> -<img src="images/vocab3.png", width="90%"> -</center> - ---- -class: center, middle - -# Git fonctionnement -## Quelques commandes de base - ---- -# Initialisation - -### Sur sa machine -1. Depuis un projet (dossier) : - - -```bash -git init -``` - --- - -### Sur un serveur distant (gitlab par exemple) -1. Création d'un projet sur une forge -2. Clone de ce projet sur sa machine en local avec `git clone` - - -```bash -git clone git@forgemia.inra.fr:elise.maigne/2021_git.git -``` - --- - -<center> -<div id="htmlwidget-e90ffe28e8b51a154c0d" style="width:504px;height:108px;" class="grViz html-widget"></div> -<script>HTMLWidgets.pymChild = new pym.Child();HTMLWidgets.addPostRenderHandler(function(){ - setTimeout(function(){HTMLWidgets.pymChild.sendHeight();},100); - });</script> -<script type="application/json" data-for="htmlwidget-e90ffe28e8b51a154c0d">{"x":{"diagram":"\n digraph {\n rankdir = LR;\n bgcolor = \"#EAEAEA\";\n edge [minlen = 3]\n node [fontsize=40 shape=cylinder style=filled color=\"#822744\" fillcolor=\"#c98399\" fontcolor=\"#822744\" width=2 height=1.5]\n local [label=local penwidth=4]\n remote [label=remote penwidth=4]\n node [fontcolor=\"#b0b0b0\" color=\"#b0b0b0\" fillcolor = \"#ededed\"]\n stage [label=stage]\n head [label=HEAD]\n local -> stage -> head -> remote\n }\n","config":{"engine":"dot","options":null}},"evals":[],"jsHooks":[]}</script> -</center> - ---- -# Un commit = un changement - -#### 1. On indique à git qu'il doit suivre ces fichiers et on intègre les modifications au prochain commit `git add` -.pull-left[ - -```bash -git add * -``` -] - -.pull-right[ - -```bash -git add nomFichier.R -``` -] - --- - -#### 2. On fait un commit avec `git commit` - -```r -git commit -m "Ma belle modification" -``` - --- - -<center> -<div id="htmlwidget-644c432baf33e19b867a" style="width:504px;height:108px;" class="grViz html-widget"></div> -<script>HTMLWidgets.pymChild = new pym.Child();HTMLWidgets.addPostRenderHandler(function(){ - setTimeout(function(){HTMLWidgets.pymChild.sendHeight();},100); - });</script> -<script type="application/json" data-for="htmlwidget-644c432baf33e19b867a">{"x":{"diagram":"\n digraph {\n rankdir = TB;\n bgcolor = \"#EAEAEA\";\n edge [minlen = 3]\n node [fontsize=40 shape=cylinder style=filled color=\"#822744\" fillcolor=\"#c98399\" fontcolor=\"#822744\" width=2 height=1.5]\n local [label=local penwidth=4]\n stage [label=stage]\n head [label=HEAD]\n node [fontcolor=\"#b0b0b0\" color=\"#b0b0b0\" fillcolor = \"#ededed\"]\n remote [label=remote penwidth=4]\n local -> stage [label = add fontsize=30 penwidth=4]\n stage -> head [label=commit fontsize=30 penwidth=4]\n head -> remote\n {rank = same; local; stage; head; remote;}; \n }","config":{"engine":"dot","options":null}},"evals":[],"jsHooks":[]}</script> -</center> - --- - -En pratique (chez moi - sur RStudio) : - - -```bash -git add * -git commit -m "Ce que j'ai fait comme modif" -``` - ---- -# Envoi des modifications au remote - -#### Envoi des commits en attente sur le HEAD - -```bash -git push -``` - -<center> -<div id="htmlwidget-b09f7c264842b595133e" style="width:504px;height:108px;" class="grViz html-widget"></div> -<script>HTMLWidgets.pymChild = new pym.Child();HTMLWidgets.addPostRenderHandler(function(){ - setTimeout(function(){HTMLWidgets.pymChild.sendHeight();},100); - });</script> -<script type="application/json" data-for="htmlwidget-b09f7c264842b595133e">{"x":{"diagram":"\n digraph {\n rankdir = TB;\n bgcolor = \"#EAEAEA\";\n edge [minlen = 3]\n node [fontsize=40 shape=cylinder style=filled color=\"#822744\" fillcolor=\"#c98399\" fontcolor=\"#822744\" width=2 height=1.5]\n head [label=HEAD]\n remote [label=remote penwidth=4]\n node [fontcolor=\"#b0b0b0\" color=\"#b0b0b0\" fillcolor = \"#ededed\"]\n local [label=local penwidth=4]\n stage [label=stage]\n local -> stage -> head\n head -> remote [label = push fontsize=30 penwidth=4]\n {rank = same; local; stage; head; remote;}; \n }","config":{"engine":"dot","options":null}},"evals":[],"jsHooks":[]}</script> -</center> - -#### Récupération de l'état du remote - -```bash -git pull -``` - -<center> -<div id="htmlwidget-f8325999d4dcb613a7d4" style="width:504px;height:108px;" class="grViz html-widget"></div> -<script>HTMLWidgets.pymChild = new pym.Child();HTMLWidgets.addPostRenderHandler(function(){ - setTimeout(function(){HTMLWidgets.pymChild.sendHeight();},100); - });</script> -<script type="application/json" data-for="htmlwidget-f8325999d4dcb613a7d4">{"x":{"diagram":"\n digraph {\n rankdir = TB;\n bgcolor = \"#EAEAEA\";\n edge [minlen = 3]\n node [fontsize=40 shape=cylinder style=filled color=\"#822744\" fillcolor=\"#c98399\" fontcolor=\"#822744\" width=2 height=1.5]\n local [label=local penwidth=4]\n remote [label=remote penwidth=4]\n node [fontcolor=\"#b0b0b0\" color=\"#b0b0b0\" fillcolor = \"#ededed\"]\n head [label=HEAD]\n stage [label=stage]\n local -> stage -> head -> remote\n remote -> local [label = pull fontsize=30 constraint=false penwidth=4]\n {rank = same; local; stage; head; remote;}; \n }","config":{"engine":"dot","options":null}},"evals":[],"jsHooks":[]}</script> -</center> - ---- -# Processus "classique" de travail avec git - -#### 1. Un projet versionné sur un serveur distant -#### 2. Je travaille comme d'habitude sur mes fichiers -#### 3. De temps en temps = une modification en particulier : - -```bash -git add * -git commit -m "Ce que j'ai fait" -git push -``` -#### 4. Si on travaille à plusieurs : on récupère les modifications des autres (avant de me remettre à travailler) - -```bash -git pull -``` - ---- -# Visualiser l'historique = les commits - -[Exemple :](https://forgemia.inra.fr/elise.maigne/2021_package_renv/-/commits/master/) - - - ---- -# Regarder les différences entre le local et un autre état - - -```bash -git diff -git diff --staged -git diff HEAD -``` - - ---- -# Les fichiers git - - - -- Un dossier `.git` : contient tous les fichiers de gestion de version (on ne va jamais dedans). - --- - -- Un fichier `.gitignore` : permet d'exclure certains fichiers ou dossiers des commits. - --- - -Exemple de contenu d'un `.gitignore`: - - -```bash -.Rproj.user -.Rhistory -.RData -.Ruserdata -/data -``` - -En particulier on ne commite pas les données. - ---- -# Les branches - -La branche par défaut est **main** (feu **master**). - -Il est possible de créer de nouvelles branches, pour tester une autre direction, ajouter une fonctionalité. - --- - -.pull-left[ -Projet d'application à plusieurs, 1 branche = 1 fonctionalité, plusieurs fonctionalités en même temps. -<div id="htmlwidget-5f853ca1817e5cd22643" style="width:504px;height:288px;" class="grViz html-widget"></div> -<script>HTMLWidgets.pymChild = new pym.Child();HTMLWidgets.addPostRenderHandler(function(){ - setTimeout(function(){HTMLWidgets.pymChild.sendHeight();},100); - });</script> -<script type="application/json" data-for="htmlwidget-5f853ca1817e5cd22643">{"x":{"diagram":"\ndigraph {\n\trankdir=\"LR\";\n\tbgcolor=\"transparent\";\n\tnode[width=0.15, height=0.15, shape=point, color=\"#822744\"];\n\tedge[weight=2, arrowhead=none, color=\"#822744\"];\n\tnode[group=master];\n\t1 -> 2 -> 3 -> 4 -> 5;\n\tnode[group=branch];\n\t2 -> 6 -> 7 -> 4;\n\tnode[group=branch];\n\t2 -> 8 -> 9 -> 10;\n\tnode[group=branch];\n\t2 -> 11 -> 12 -> 13 -> 14 -> 15;\n}","config":{"engine":"dot","options":null}},"evals":[],"jsHooks":[]}</script> -] - --- - -.pull-right[ -Développement d'un package R : une branche correspond à une modification majeure du code. La branche main est toujours supposée tourner. -<div id="htmlwidget-f73e94314218f55a901c" style="width:504px;height:288px;" class="grViz html-widget"></div> -<script>HTMLWidgets.pymChild = new pym.Child();HTMLWidgets.addPostRenderHandler(function(){ - setTimeout(function(){HTMLWidgets.pymChild.sendHeight();},100); - });</script> -<script type="application/json" data-for="htmlwidget-f73e94314218f55a901c">{"x":{"diagram":"\ndigraph {\n\trankdir=\"LR\";\n\tbgcolor=\"transparent\";\n\tnode[width=0.15, height=0.15, shape=point, color=\"#822744\"];\n\tedge[weight=2, arrowhead=none, color=\"#822744\"];\n\tnode[group=master];\n\t1 -> 2 -> 3 -> 4 -> 5 -> 6 -> 7 -> 8;\n\tnode[group=branch];\n\t2 -> 9 -> 10 -> 11 -> 3;\n\tnode[group=branch];\n\t5 -> 12 -> 13 -> 14 -> 6;\n}","config":{"engine":"dot","options":null}},"evals":[],"jsHooks":[]}</script> -] - ---- -# Les branches - -#### Création d'une branche - - -```bash -git branch mabranche -``` - -#### Changer de branche - - -```bash -git checkout mabranche -git checkout monautrebranche -``` - -On ne peut changer de branche uniquement si toutes les modifications (des fichiers suivis) sont commitées. - ---- -# Les branches -#### Fusionner des branches - -```bash -git checkout mabranche -git merge main -``` - -#### Les conflits -Si un fichier est modifié 2 fois au même endroit. - -```bash -<<<<<<< HEAD:fichier.R -J'avais mis ça avant dans ma (vieille) branche -====== -Et maintenant j'ai ça, je ne suis qu'un logiciel je ne sais pas quoi faire ->>>>>>> iss53:fichier.R -``` - -Il faut choisir entre les 2 versions pour pouvoir finaliser le merge - ---- -# Possibilités (pour des statisticiens) - -#### Publication/partage du code - --- - -#### gitlab pages -Faire des sites webs très facilement ! avec juste un fichier yml à la racine du dépôt - -Exemple : j'ai un projet qui crée un fichier html à l'aide de Rmarkdown. --> Si j'active gitlab pages je peux en faire un site web. -(exemple : https://elise.maigne.pages.mia.inra.fr/2021_git/index.html) - --- - -#### CI/CD (integration continue) -Par exemple compiler ses Rmd automatiquement. -Faire des tests automatiques. - --- - -#### Enseignement -Un projet "principal" forké (`git fork`) par les étudiants qui partent de la même copie et faire leurs propres modifications, indépendemment les un des autres. - ---- -# Vocabulaire - -.pull-left[ -#### Au démarrage -- `git clone` -- `git fork` - -#### Faire des modifications -- `git add` + `git commit -m "Message'` -- `git push` -- `git pull` - -#### Visualiser -- `git diff` -- `git blame` -] - -.pull-right[ -#### Branches -- `git branch` -- `git checkout` -- `git merge` -- `git rebase` - -#### Revenir en arrière -- `git revert` - -#### Savoir où on en est -- `git status` -... -] - ---- -# des questions ? - -Lien vers le dépôt de cette présentation : -https://forgemia.inra.fr/elise.maigne/2021_git/ - -#### Références - -Merci aux sites suivants : -- https://perso.liris.cnrs.fr/pierre-antoine.champin/enseignement/intro-git/ -- http://rogerdudler.github.io/git-guide/index.fr.html -- Doc de la forgemia : https://forgemia.inra.fr/adminforgemia/doc-public/-/wikis/GIT-sous-Windows -- branches git en graphviz : https://correl.phoenixinquis.net/2015/07/12/git-graphs.html - ---- -name: bonus -# Bonus - Différence SVN/Git () -#### SVN - -SVN est un système de contrôle de version **centralisé**. Vous avez un serveur qui contient votre référentiel de code. Vous pouvez en extraire du code sur votre ordinateur local, y apporter des modifications locales, puis les renvoyer dans le référentiel central. - -Votre copie du code correspond généralement à ce que vous avez extrait et à la dernière version. De nombreuses opérations nécessiteront une connexion réseau au référentiel central. - -#### Git - -Git est un système de contrôle de version **décentralisé**. Chaque participant a un clone de l’ensemble du référentiel. Il est utilisé pour suivre les changements dans le code source. - -La plupart des opérations ne nécessitent pas de connexion réseau, car elles ne travaillent que sur votre clone du référentiel. - -*Source : https://waytolearnx.com/2019/03/difference-entre-git-et-svn.html* - </textarea> -<style data-target="print-only">@media screen {.remark-slide-container{display:block;}.remark-slide-scaler{box-shadow:none;}}</style> -<script src="https://remarkjs.com/downloads/remark-latest.min.js"></script> -<script>var slideshow = remark.create({ -"ratio": "16:9", -"highlightStyle": "github", -"highlightLines": true, -"countIncrementalSlides": false -}); -if (window.HTMLWidgets) slideshow.on('afterShowSlide', function (slide) { - window.dispatchEvent(new Event('resize')); -}); -(function(d) { - var s = d.createElement("style"), r = d.querySelector(".remark-slide-scaler"); - if (!r) return; - s.type = "text/css"; s.innerHTML = "@page {size: " + r.style.width + " " + r.style.height +"; }"; - d.head.appendChild(s); -})(document); - -(function(d) { - var el = d.getElementsByClassName("remark-slides-area"); - if (!el) return; - var slide, slides = slideshow.getSlides(), els = el[0].children; - for (var i = 1; i < slides.length; i++) { - slide = slides[i]; - if (slide.properties.continued === "true" || slide.properties.count === "false") { - els[i - 1].className += ' has-continuation'; - } - } - var s = d.createElement("style"); - s.type = "text/css"; s.innerHTML = "@media print { .has-continuation { display: none; } }"; - d.head.appendChild(s); -})(document); -// delete the temporary CSS (for displaying all slides initially) when the user -// starts to view slides -(function() { - var deleted = false; - slideshow.on('beforeShowSlide', function(slide) { - if (deleted) return; - var sheets = document.styleSheets, node; - for (var i = 0; i < sheets.length; i++) { - node = sheets[i].ownerNode; - if (node.dataset["target"] !== "print-only") continue; - node.parentNode.removeChild(node); - } - deleted = true; - }); -})(); -(function() { - "use strict" - // Replace <script> tags in slides area to make them executable - var scripts = document.querySelectorAll( - '.remark-slides-area .remark-slide-container script' - ); - if (!scripts.length) return; - for (var i = 0; i < scripts.length; i++) { - var s = document.createElement('script'); - var code = document.createTextNode(scripts[i].textContent); - s.appendChild(code); - var scriptAttrs = scripts[i].attributes; - for (var j = 0; j < scriptAttrs.length; j++) { - s.setAttribute(scriptAttrs[j].name, scriptAttrs[j].value); - } - scripts[i].parentElement.replaceChild(s, scripts[i]); - } -})(); -(function() { - var links = document.getElementsByTagName('a'); - for (var i = 0; i < links.length; i++) { - if (/^(https?:)?\/\//.test(links[i].getAttribute('href'))) { - links[i].target = '_blank'; - } - } -})(); -// adds .remark-code-has-line-highlighted class to <pre> parent elements -// of code chunks containing highlighted lines with class .remark-code-line-highlighted -(function(d) { - const hlines = d.querySelectorAll('.remark-code-line-highlighted'); - const preParents = []; - const findPreParent = function(line, p = 0) { - if (p > 1) return null; // traverse up no further than grandparent - const el = line.parentElement; - return el.tagName === "PRE" ? el : findPreParent(el, ++p); - }; - - for (let line of hlines) { - let pre = findPreParent(line); - if (pre && !preParents.includes(pre)) preParents.push(pre); - } - preParents.forEach(p => p.classList.add("remark-code-has-line-highlighted")); -})(document);</script> - -<script> -slideshow._releaseMath = function(el) { - var i, text, code, codes = el.getElementsByTagName('code'); - for (i = 0; i < codes.length;) { - code = codes[i]; - if (code.parentNode.tagName !== 'PRE' && code.childElementCount === 0) { - text = code.textContent; - if (/^\\\((.|\s)+\\\)$/.test(text) || /^\\\[(.|\s)+\\\]$/.test(text) || - /^\$\$(.|\s)+\$\$$/.test(text) || - /^\\begin\{([^}]+)\}(.|\s)+\\end\{[^}]+\}$/.test(text)) { - code.outerHTML = code.innerHTML; // remove <code></code> - continue; - } - } - i++; - } -}; -slideshow._releaseMath(document); -</script> -<!-- dynamically load mathjax for compatibility with self-contained --> -<script> -(function () { - var script = document.createElement('script'); - script.type = 'text/javascript'; - script.src = 'https://mathjax.rstudio.com/latest/MathJax.js?config=TeX-MML-AM_CHTML'; - if (location.protocol !== 'file:' && /^https?:/.test(script.src)) - script.src = script.src.replace(/^https?:/, ''); - document.getElementsByTagName('head')[0].appendChild(script); -})(); -</script> - </body> -</html> diff --git a/renv.lock b/renv.lock new file mode 100644 index 0000000000000000000000000000000000000000..7108b7dcd960ffac0a8a0f288208997f5765bf88 --- /dev/null +++ b/renv.lock @@ -0,0 +1,622 @@ +{ + "R": { + "Version": "4.0.3", + "Repositories": [ + { + "Name": "CRAN", + "URL": "https://cran.rstudio.com" + } + ] + }, + "Packages": { + "BH": { + "Package": "BH", + "Version": "1.72.0-3", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "8f9ce74c6417d61f0782cbae5fd2b7b0" + }, + "DiagrammeR": { + "Package": "DiagrammeR", + "Version": "1.0.6.1", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "3cb13b97961593b4a1ed0c8e37df9d9b" + }, + "MASS": { + "Package": "MASS", + "Version": "7.3-53", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "d1bc1c8e9c0ace57ec9ffea01021d45f" + }, + "Matrix": { + "Package": "Matrix", + "Version": "1.2-18", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "08588806cba69f04797dab50627428ed" + }, + "R6": { + "Package": "R6", + "Version": "2.5.0", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "b203113193e70978a696b2809525649d" + }, + "RColorBrewer": { + "Package": "RColorBrewer", + "Version": "1.1-2", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "e031418365a7f7a766181ab5a41a5716" + }, + "Rcpp": { + "Package": "Rcpp", + "Version": "1.0.5", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "125dc7a0ed375eb68c0ce533b48d291f" + }, + "base64enc": { + "Package": "base64enc", + "Version": "0.1-3", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "543776ae6848fde2f48ff3816d0628bc" + }, + "brio": { + "Package": "brio", + "Version": "1.1.0", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "570a24963009b9cce0869a0463c83580" + }, + "callr": { + "Package": "callr", + "Version": "3.7.0", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "461aa75a11ce2400245190ef5d3995df" + }, + "cli": { + "Package": "cli", + "Version": "3.0.1", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "e3ae5d68dea0c55a12ea12a9fda02e61" + }, + "clipr": { + "Package": "clipr", + "Version": "0.7.1", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "ebaa97ac99cc2daf04e77eecc7b781d7" + }, + "colorspace": { + "Package": "colorspace", + "Version": "2.0-0", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "abea3384649ef37f60ef51ce002f3547" + }, + "cpp11": { + "Package": "cpp11", + "Version": "0.4.0", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "40ba3fd26c8f61d8d14d334bc7761df9" + }, + "crayon": { + "Package": "crayon", + "Version": "1.4.1", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "e75525c55c70e5f4f78c9960a4b402e9" + }, + "desc": { + "Package": "desc", + "Version": "1.4.0", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "28763d08fadd0b733e3cee9dab4e12fe" + }, + "diffobj": { + "Package": "diffobj", + "Version": "0.3.4", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "feb5b7455eba422a2c110bb89852e6a3" + }, + "digest": { + "Package": "digest", + "Version": "0.6.27", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "a0cbe758a531d054b537d16dff4d58a1" + }, + "downloader": { + "Package": "downloader", + "Version": "0.4", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "f4f2a915e0dedbdf016a83b63477349f" + }, + "dplyr": { + "Package": "dplyr", + "Version": "1.0.7", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "36f1ae62f026c8ba9f9b5c9a08c03297" + }, + "ellipsis": { + "Package": "ellipsis", + "Version": "0.3.2", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "bb0eec2fe32e88d9e2836c2f73ea2077" + }, + "evaluate": { + "Package": "evaluate", + "Version": "0.14", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "ec8ca05cffcc70569eaaad8469d2a3a7" + }, + "fansi": { + "Package": "fansi", + "Version": "0.4.1", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "7fce217eaaf8016e72065e85c73027b5" + }, + "farver": { + "Package": "farver", + "Version": "2.0.3", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "dad6793a5a1f73c8e91f1a1e3e834b05" + }, + "fastmap": { + "Package": "fastmap", + "Version": "1.1.0", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "77bd60a6157420d4ffa93b27cf6a58b8" + }, + "generics": { + "Package": "generics", + "Version": "0.1.0", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "4d243a9c10b00589889fe32314ffd902" + }, + "ggplot2": { + "Package": "ggplot2", + "Version": "3.3.5", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "d7566c471c7b17e095dd023b9ef155ad" + }, + "glue": { + "Package": "glue", + "Version": "1.4.2", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "6efd734b14c6471cfe443345f3e35e29" + }, + "gridExtra": { + "Package": "gridExtra", + "Version": "2.3", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "7d7f283939f563670a697165b2cf5560" + }, + "gtable": { + "Package": "gtable", + "Version": "0.3.0", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "ac5c6baf7822ce8732b343f14c072c4d" + }, + "highr": { + "Package": "highr", + "Version": "0.8", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "4dc5bb88961e347a0f4d8aad597cbfac" + }, + "hms": { + "Package": "hms", + "Version": "1.1.1", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "5b8a2dd0fdbe2ab4f6081e6c7be6dfca" + }, + "htmltools": { + "Package": "htmltools", + "Version": "0.5.2", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "526c484233f42522278ab06fb185cb26" + }, + "htmlwidgets": { + "Package": "htmlwidgets", + "Version": "1.5.3", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "6fdaa86d0700f8b3e92ee3c445a5a10d" + }, + "httpuv": { + "Package": "httpuv", + "Version": "1.5.4", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "4e6dabb220b006ccdc3b3b5ff993b205" + }, + "igraph": { + "Package": "igraph", + "Version": "1.2.6", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "7b1f856410253d56ea67ad808f7cdff6" + }, + "influenceR": { + "Package": "influenceR", + "Version": "0.1.0", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "611f9a55ad32ccfa17ccbd77be7a2804" + }, + "isoband": { + "Package": "isoband", + "Version": "0.2.3", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "53647fb507373700028b2ce6cd30751a" + }, + "jsonlite": { + "Package": "jsonlite", + "Version": "1.7.2", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "98138e0994d41508c7a6b84a0600cfcb" + }, + "knitr": { + "Package": "knitr", + "Version": "1.30", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "eed7ee0d02eee88d53881cdc92457c62" + }, + "labeling": { + "Package": "labeling", + "Version": "0.4.2", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "3d5108641f47470611a32d0bdf357a72" + }, + "later": { + "Package": "later", + "Version": "1.1.0.1", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "d0a62b247165aabf397fded504660d8a" + }, + "lattice": { + "Package": "lattice", + "Version": "0.20-41", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "fbd9285028b0263d76d18c95ae51a53d" + }, + "lifecycle": { + "Package": "lifecycle", + "Version": "1.0.1", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "a6b6d352e3ed897373ab19d8395c98d0" + }, + "magrittr": { + "Package": "magrittr", + "Version": "2.0.1", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "41287f1ac7d28a92f0a286ed507928d3" + }, + "markdown": { + "Package": "markdown", + "Version": "1.1", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "61e4a10781dd00d7d81dd06ca9b94e95" + }, + "mgcv": { + "Package": "mgcv", + "Version": "1.8-33", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "eb7b6439bc6d812eed2cddba5edc6be3" + }, + "mime": { + "Package": "mime", + "Version": "0.9", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "e87a35ec73b157552814869f45a63aa3" + }, + "munsell": { + "Package": "munsell", + "Version": "0.5.0", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "6dfe8bf774944bd5595785e3229d8771" + }, + "nlme": { + "Package": "nlme", + "Version": "3.1-151", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "42c8ba2b6a32a6bf0874e93e3bd86a43" + }, + "pillar": { + "Package": "pillar", + "Version": "1.6.3", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "3323bc1a0988d63b5c65771ba0d3935d" + }, + "pkgconfig": { + "Package": "pkgconfig", + "Version": "2.0.3", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "01f28d4278f15c76cddbea05899c5d6f" + }, + "pkgload": { + "Package": "pkgload", + "Version": "1.2.2", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "53139eedf68b98eecd5289664969c3f2" + }, + "praise": { + "Package": "praise", + "Version": "1.0.0", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "a555924add98c99d2f411e37e7d25e9f" + }, + "processx": { + "Package": "processx", + "Version": "3.5.2", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "0cbca2bc4d16525d009c4dbba156b37c" + }, + "promises": { + "Package": "promises", + "Version": "1.1.1", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "a8730dcbdd19f9047774909f0ec214a4" + }, + "ps": { + "Package": "ps", + "Version": "1.5.0", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "ebaed51a03411fd5cfc1e12d9079b353" + }, + "purrr": { + "Package": "purrr", + "Version": "0.3.4", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "97def703420c8ab10d8f0e6c72101e02" + }, + "readr": { + "Package": "readr", + "Version": "1.4.0", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "2639976851f71f330264a9c9c3d43a61" + }, + "rematch2": { + "Package": "rematch2", + "Version": "2.1.2", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "76c9e04c712a05848ae7a23d2f170a40" + }, + "renv": { + "Package": "renv", + "Version": "0.12.3", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "b5510c50c7f31d453c385c7b460af2b9" + }, + "rlang": { + "Package": "rlang", + "Version": "0.4.11", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "515f341d3affe0de9e4a7f762efb0456" + }, + "rmarkdown": { + "Package": "rmarkdown", + "Version": "2.6", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "bc4bac38960b446c183957bfd563e763" + }, + "rprojroot": { + "Package": "rprojroot", + "Version": "2.0.2", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "249d8cd1e74a8f6a26194a91b47f21d1" + }, + "rstudioapi": { + "Package": "rstudioapi", + "Version": "0.13", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "06c85365a03fdaf699966cc1d3cf53ea" + }, + "scales": { + "Package": "scales", + "Version": "1.1.1", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "6f76f71042411426ec8df6c54f34e6dd" + }, + "servr": { + "Package": "servr", + "Version": "0.21", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "48d1289a847c801b3f0e76fc619fa65d" + }, + "stringi": { + "Package": "stringi", + "Version": "1.5.3", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "a063ebea753c92910a4cca7b18bc1f05" + }, + "stringr": { + "Package": "stringr", + "Version": "1.4.0", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "0759e6b6c0957edb1311028a49a35e76" + }, + "testthat": { + "Package": "testthat", + "Version": "3.1.0", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "89e55ebe4f5ddd7f43f0f2bc6d96c950" + }, + "tibble": { + "Package": "tibble", + "Version": "3.1.5", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "36eb05ad4cfdfeaa56f5a9b2a1311efd" + }, + "tidyr": { + "Package": "tidyr", + "Version": "1.1.4", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "c8fbdbd9fcac223d6c6fe8e406f368e1" + }, + "tidyselect": { + "Package": "tidyselect", + "Version": "1.1.0", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "6ea435c354e8448819627cf686f66e0a" + }, + "tinytex": { + "Package": "tinytex", + "Version": "0.28", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "ff73961a77fba606fbf944dc3468e5b9" + }, + "utf8": { + "Package": "utf8", + "Version": "1.2.1", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "c3ad47dc6da0751f18ed53c4613e3ac7" + }, + "vctrs": { + "Package": "vctrs", + "Version": "0.3.8", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "ecf749a1b39ea72bd9b51b76292261f1" + }, + "viridis": { + "Package": "viridis", + "Version": "0.5.1", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "6f6b49e5b3b5ee5a6d0c28bf1b4b9eb3" + }, + "viridisLite": { + "Package": "viridisLite", + "Version": "0.3.0", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "ce4f6271baa94776db692f1cb2055bee" + }, + "visNetwork": { + "Package": "visNetwork", + "Version": "2.0.9", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "12545f2acf49d1d346d075580122d89c" + }, + "waldo": { + "Package": "waldo", + "Version": "0.3.1", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "ad8cfff5694ac5b3c354f8f2044bd976" + }, + "whisker": { + "Package": "whisker", + "Version": "0.4", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "ca970b96d894e90397ed20637a0c1bbe" + }, + "widgetframe": { + "Package": "widgetframe", + "Version": "0.3.1", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "0ee89e6cb58182d39b30a5b506e04808" + }, + "withr": { + "Package": "withr", + "Version": "2.4.2", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "ad03909b44677f930fa156d47d7a3aeb" + }, + "xaringan": { + "Package": "xaringan", + "Version": "0.19", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "0d0e49333c8a4841db419aea628ac16f" + }, + "xaringanthemer": { + "Package": "xaringanthemer", + "Version": "0.3.0", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "402482b841f115baa6250a3fc49f802f" + }, + "xfun": { + "Package": "xfun", + "Version": "0.24", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "88cdb9779a657ad80ad942245fffba31" + }, + "yaml": { + "Package": "yaml", + "Version": "2.2.1", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "2826c5d9efb0a88f657c7a679c7106db" + } + } +} diff --git a/renv/.gitignore b/renv/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..62e60ad4a77df42753a26ab8412dfc91898bf4db --- /dev/null +++ b/renv/.gitignore @@ -0,0 +1,4 @@ +library/ +lock/ +python/ +staging/ diff --git a/renv/activate.R b/renv/activate.R new file mode 100644 index 0000000000000000000000000000000000000000..6841a967e3636f27ef4aa1b5d5612ba886a225d8 --- /dev/null +++ b/renv/activate.R @@ -0,0 +1,400 @@ + +local({ + + # the requested version of renv + version <- "0.12.3" + + # the project directory + project <- getwd() + + # avoid recursion + if (!is.na(Sys.getenv("RENV_R_INITIALIZING", unset = NA))) + return(invisible(TRUE)) + + # signal that we're loading renv during R startup + Sys.setenv("RENV_R_INITIALIZING" = "true") + on.exit(Sys.unsetenv("RENV_R_INITIALIZING"), add = TRUE) + + # signal that we've consented to use renv + options(renv.consent = TRUE) + + # load the 'utils' package eagerly -- this ensures that renv shims, which + # mask 'utils' packages, will come first on the search path + library(utils, lib.loc = .Library) + + # check to see if renv has already been loaded + if ("renv" %in% loadedNamespaces()) { + + # if renv has already been loaded, and it's the requested version of renv, + # nothing to do + spec <- .getNamespaceInfo(.getNamespace("renv"), "spec") + if (identical(spec[["version"]], version)) + return(invisible(TRUE)) + + # otherwise, unload and attempt to load the correct version of renv + unloadNamespace("renv") + + } + + # load bootstrap tools + bootstrap <- function(version, library) { + + # read repos (respecting override if set) + repos <- Sys.getenv("RENV_CONFIG_REPOS_OVERRIDE", unset = NA) + if (is.na(repos)) + repos <- getOption("repos") + + # fix up repos + on.exit(options(repos = repos), add = TRUE) + repos[repos == "@CRAN@"] <- "https://cloud.r-project.org" + options(repos = repos) + + # attempt to download renv + tarball <- tryCatch(renv_bootstrap_download(version), error = identity) + if (inherits(tarball, "error")) + stop("failed to download renv ", version) + + # now attempt to install + status <- tryCatch(renv_bootstrap_install(version, tarball, library), error = identity) + if (inherits(status, "error")) + stop("failed to install renv ", version) + + } + + renv_bootstrap_download_impl <- function(url, destfile) { + + mode <- "wb" + + # https://bugs.r-project.org/bugzilla/show_bug.cgi?id=17715 + fixup <- + Sys.info()[["sysname"]] == "Windows" && + substring(url, 1L, 5L) == "file:" + + if (fixup) + mode <- "w+b" + + download.file( + url = url, + destfile = destfile, + mode = mode, + quiet = TRUE + ) + + } + + renv_bootstrap_download <- function(version) { + + # if the renv version number has 4 components, assume it must + # be retrieved via github + nv <- numeric_version(version) + components <- unclass(nv)[[1]] + + methods <- if (length(components) == 4L) { + list(renv_bootstrap_download_github) + } else { + list( + renv_bootstrap_download_cran_latest, + renv_bootstrap_download_cran_archive + ) + } + + for (method in methods) { + path <- tryCatch(method(version), error = identity) + if (is.character(path) && file.exists(path)) + return(path) + } + + stop("failed to download renv ", version) + + } + + renv_bootstrap_download_cran_latest <- function(version) { + + repos <- renv_bootstrap_download_cran_latest_find(version) + + message("* Downloading renv ", version, " from CRAN ... ", appendLF = FALSE) + + info <- tryCatch( + download.packages("renv", repos = repos, destdir = tempdir(), quiet = TRUE), + condition = identity + ) + + if (inherits(info, "condition")) { + message("FAILED") + return(FALSE) + } + + message("OK") + info[1, 2] + + } + + renv_bootstrap_download_cran_latest_find <- function(version) { + + # check for renv on CRAN matching this version + all <- unique(c( + getOption("repos"), + getOption("renv.bootstrap.repos", default = "https://cloud.r-project.org") + )) + + for (repos in all) { + + db <- tryCatch( + as.data.frame(available.packages(repos = repos), stringsAsFactors = FALSE), + error = identity + ) + + if (inherits(db, "error")) + next + + entry <- db[db$Package %in% "renv" & db$Version %in% version, ] + if (nrow(entry) == 0) + next + + return(repos) + + } + + fmt <- "renv %s is not available from your declared package repositories" + stop(sprintf(fmt, version)) + + } + + renv_bootstrap_download_cran_archive <- function(version) { + + name <- sprintf("renv_%s.tar.gz", version) + repos <- getOption("repos") + urls <- file.path(repos, "src/contrib/Archive/renv", name) + destfile <- file.path(tempdir(), name) + + message("* Downloading renv ", version, " from CRAN archive ... ", appendLF = FALSE) + + for (url in urls) { + + status <- tryCatch( + renv_bootstrap_download_impl(url, destfile), + condition = identity + ) + + if (identical(status, 0L)) { + message("OK") + return(destfile) + } + + } + + message("FAILED") + return(FALSE) + + } + + renv_bootstrap_download_github <- function(version) { + + enabled <- Sys.getenv("RENV_BOOTSTRAP_FROM_GITHUB", unset = "TRUE") + if (!identical(enabled, "TRUE")) + return(FALSE) + + # prepare download options + pat <- Sys.getenv("GITHUB_PAT") + if (nzchar(Sys.which("curl")) && nzchar(pat)) { + fmt <- "--location --fail --header \"Authorization: token %s\"" + extra <- sprintf(fmt, pat) + saved <- options("download.file.method", "download.file.extra") + options(download.file.method = "curl", download.file.extra = extra) + on.exit(do.call(base::options, saved), add = TRUE) + } else if (nzchar(Sys.which("wget")) && nzchar(pat)) { + fmt <- "--header=\"Authorization: token %s\"" + extra <- sprintf(fmt, pat) + saved <- options("download.file.method", "download.file.extra") + options(download.file.method = "wget", download.file.extra = extra) + on.exit(do.call(base::options, saved), add = TRUE) + } + + message("* Downloading renv ", version, " from GitHub ... ", appendLF = FALSE) + + url <- file.path("https://api.github.com/repos/rstudio/renv/tarball", version) + name <- sprintf("renv_%s.tar.gz", version) + destfile <- file.path(tempdir(), name) + + status <- tryCatch( + renv_bootstrap_download_impl(url, destfile), + condition = identity + ) + + if (!identical(status, 0L)) { + message("FAILED") + return(FALSE) + } + + message("Done!") + return(destfile) + + } + + renv_bootstrap_install <- function(version, tarball, library) { + + # attempt to install it into project library + message("* Installing renv ", version, " ... ", appendLF = FALSE) + dir.create(library, showWarnings = FALSE, recursive = TRUE) + + # invoke using system2 so we can capture and report output + bin <- R.home("bin") + exe <- if (Sys.info()[["sysname"]] == "Windows") "R.exe" else "R" + r <- file.path(bin, exe) + args <- c("--vanilla", "CMD", "INSTALL", "-l", shQuote(library), shQuote(tarball)) + output <- system2(r, args, stdout = TRUE, stderr = TRUE) + message("Done!") + + # check for successful install + status <- attr(output, "status") + if (is.numeric(status) && !identical(status, 0L)) { + header <- "Error installing renv:" + lines <- paste(rep.int("=", nchar(header)), collapse = "") + text <- c(header, lines, output) + writeLines(text, con = stderr()) + } + + status + + } + + renv_bootstrap_prefix <- function() { + + # construct version prefix + version <- paste(R.version$major, R.version$minor, sep = ".") + prefix <- paste("R", numeric_version(version)[1, 1:2], sep = "-") + + # include SVN revision for development versions of R + # (to avoid sharing platform-specific artefacts with released versions of R) + devel <- + identical(R.version[["status"]], "Under development (unstable)") || + identical(R.version[["nickname"]], "Unsuffered Consequences") + + if (devel) + prefix <- paste(prefix, R.version[["svn rev"]], sep = "-r") + + # build list of path components + components <- c(prefix, R.version$platform) + + # include prefix if provided by user + prefix <- Sys.getenv("RENV_PATHS_PREFIX") + if (nzchar(prefix)) + components <- c(prefix, components) + + # build prefix + paste(components, collapse = "/") + + } + + renv_bootstrap_library_root <- function(project) { + + path <- Sys.getenv("RENV_PATHS_LIBRARY", unset = NA) + if (!is.na(path)) + return(path) + + path <- Sys.getenv("RENV_PATHS_LIBRARY_ROOT", unset = NA) + if (!is.na(path)) { + id <- substring(renv_bootstrap_hash_text(project), 1L, 8L) + name <- paste(basename(project), id, sep = "-") + return(file.path(path, name)) + } + + file.path(project, "renv/library") + + } + + renv_bootstrap_validate_version <- function(version) { + + loadedversion <- utils::packageDescription("renv", fields = "Version") + if (version == loadedversion) + return(TRUE) + + # assume four-component versions are from GitHub; three-component + # versions are from CRAN + components <- strsplit(loadedversion, "[.-]")[[1]] + remote <- if (length(components) == 4L) + paste("rstudio/renv", loadedversion, sep = "@") + else + paste("renv", loadedversion, sep = "@") + + fmt <- paste( + "renv %1$s was loaded from project library, but this project is configured to use renv %2$s.", + "Use `renv::record(\"%3$s\")` to record renv %1$s in the lockfile.", + "Use `renv::restore(packages = \"renv\")` to install renv %2$s into the project library.", + sep = "\n" + ) + + msg <- sprintf(fmt, loadedversion, version, remote) + warning(msg, call. = FALSE) + + FALSE + + } + + renv_bootstrap_hash_text <- function(text) { + + hashfile <- tempfile("renv-hash-") + on.exit(unlink(hashfile), add = TRUE) + + writeLines(text, con = hashfile) + tools::md5sum(hashfile) + + } + + renv_bootstrap_load <- function(project, libpath, version) { + + # try to load renv from the project library + if (!requireNamespace("renv", lib.loc = libpath, quietly = TRUE)) + return(FALSE) + + # warn if the version of renv loaded does not match + renv_bootstrap_validate_version(version) + + # load the project + renv::load(project) + + TRUE + + } + + # construct path to library root + root <- renv_bootstrap_library_root(project) + + # construct library prefix for platform + prefix <- renv_bootstrap_prefix() + + # construct full libpath + libpath <- file.path(root, prefix) + + # attempt to load + if (renv_bootstrap_load(project, libpath, version)) + return(TRUE) + + # load failed; inform user we're about to bootstrap + prefix <- paste("# Bootstrapping renv", version) + postfix <- paste(rep.int("-", 77L - nchar(prefix)), collapse = "") + header <- paste(prefix, postfix) + message(header) + + # perform bootstrap + bootstrap(version, libpath) + + # exit early if we're just testing bootstrap + if (!is.na(Sys.getenv("RENV_BOOTSTRAP_INSTALL_ONLY", unset = NA))) + return(TRUE) + + # try again to load + if (requireNamespace("renv", lib.loc = libpath, quietly = TRUE)) { + message("* Successfully installed and loaded renv ", version, ".") + return(renv::load()) + } + + # failed to download or load renv; warn the user + msg <- c( + "Failed to find an renv installation: the project will not be loaded.", + "Use `renv::activate()` to re-initialize the project." + ) + + warning(paste(msg, collapse = "\n"), call. = FALSE) + +}) diff --git a/renv/settings.dcf b/renv/settings.dcf new file mode 100644 index 0000000000000000000000000000000000000000..bf722e81883bdf3f109d8f4e8d1c0fcbda61815f --- /dev/null +++ b/renv/settings.dcf @@ -0,0 +1,7 @@ +external.libraries: +ignored.packages: +package.dependency.fields: Imports, Depends, LinkingTo +r.version: +snapshot.type: implicit +use.cache: TRUE +vcs.ignore.library: TRUE