Make language: r
work when there is already a renv in the working directory and RENV_PROJECT
is set
#2170
+9
−2
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: r
fail 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_PROJECT
is 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
Rscript
should 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_HOME
is set, we should construct the full path to the executable with it, instead of relying on the$PATH
.