Make language: r work when there is already a renv in the working directory and RENV_PROJECT is set#2170
Merged
asottile merged 3 commits intopre-commit:masterfrom Dec 24, 2021
Conversation
language: r work within RStudio when there is already a renv in the working directorylanguage: r work when there is already a renv in the working directory and RENV_PROJECT is set
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Hooks with
language: rfail under certain circumstances if there is a virtual R environment present in the repo where a user want's to use hooks. This is because the env variableRENV_PROJECTis set in the terminal by some editors, e.g. RStudio to the virtual R environment of the user, but when pre-commit installs hooks (from that IDE terminal), it should not use that environment (obviously). Hence, we should unset that env variable before installing hooks. See rstudio/renv#900 for an in-depth discussion.In addition, the command line executable
Rscriptshould not be used when called from R itself for some version incompatibility, but instead in that case, the full path should be specified. Hence, if$R_HOMEis set, we should construct the full path to the executable with it, instead of relying on the$PATH.