Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make language: r work when there is already a renv in the working directory and RENV_PROJECT is set #2170

Merged
merged 3 commits into from Dec 24, 2021

Conversation

lorenzwalthert
Copy link
Contributor

@lorenzwalthert lorenzwalthert commented Dec 24, 2021

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 variable RENV_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.

@lorenzwalthert lorenzwalthert changed the title Make language: r work within RStudio when there is already a renv in the working directory Make language: r work when there is already a renv in the working directory and RENV_PROJECT is set Dec 24, 2021
Copy link
Member

@asottile asottile left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants