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
{precommit} can't be used when a {renv} is already present in repo #342
Comments
I fixed this by finding the automatically created pre-commit R project and manually installing packages for both renv and renv-default folders. |
Thanks for letting me know @smingerson.
Did this involve the clean up suggested in #316, namely
? Were you using {renv} in this project (just to make sure we are on the same page: the {renv} used by {precommit} is not located in your repository directory.
Ok, this seem like a hack -.- sorry for the bad experience. |
Yes, it did.
Correct. My own project used renv, and I was deactivating/reactivating renv within my own project. At the time, I didn't understand that precommit was building its own instance somewhere.
It most certainly is a hack! No worries on the bad experience, precommit is more than worth it! |
Is this a public repo? We have not yet explored compatibility of {precommit} with {renv} in a {renv} project. Maybe that's causing the problems. |
Work project so I cannot share. I will spend some time this weekend to see if I can reproduce it in a public repo. |
Thanks a lot. Would be great to see a minimal reproducible example of this. Also note that I created release |
I tried to reproduce on my personal computer, and ended up with some very different errors. I suspect the difference being going from no precommit to 0.2.0, rather than 0.1.3 to 0.2.0, and not having had reticulate installed anywhere prior. Progress so far:
|
oh dear this does not look great indeed. Thanks for your time. I'll also try with a local {renv}. |
I've made some progress. I think a lot of the errors weren't really precommit related, but due to python/reticulate pain. I did the below, and now its looking more like my original problem
Back to something I'm familiar with! I noticed in the pre-commit python project, there is now a py_env-python3.9 folder -- there was nothing like that previously. Perhaps the miniconda install not being on path caused problems? Both the precommit project renv and renv-default libraries are empty. Note however, that my local project DOES have all these dependencies, so it is using the correct renv. |
I noticed that too in my repo. |
Setup:
The problem seems RStudio, as the following workflow does error in a system terminal opened with RStudio, but not with a terminal like iTerm. Workflow with system terminal in RStudio (fails)
style-files..............................................................Failed
- hook id: style-files
- exit code: 1
Error in packageVersion("precommit") :
there is no package called ‘precommit’
Execution halted
spell-check..........................................(no files to check)Skipped
lintr....................................................................Failed
- hook id: lintr
- exit code: 1
Error in loadNamespace(x) : there is no package called ‘docopt’
Calls: loadNamespace -> withRestarts -> withOneRestart -> doWithOneRestart
Execution halted Workflow with system terminal outside RStudio (succeeds)The same as the above workflow, run outside RStudio Workflow with R in RStudioA slightly different workflow in R alone:
What is unknown
How to go forward
> source('renv/activate.R')
Warning message:
could not load renv from project "~/.cache/pre-commit/repoop2cc2mv/renv-default"; reloading previously-loaded renv
> Which means the project renv is loaded instead of the {precommit} renv. This should be reproducible for any two renvs.
|
@smingerson I think one workaround for you is to use the dev version of {renv} from GitHub now. Also requires dev version of {precommit}. Do you want to give it a try? Kevin updated it due to rstudio/renv#900. |
Closed with release |
Hey I am using precommit v0.3.2 and still I experienced the issues from above. The workaround worked for me. Thank you! Is there an update regarding this issue? |
|
precommit v0.3.2 But I updated renv after using the workaround. So I guess this might have been the problem on my side. I think for now my comment from before can be ignored. |
This looks good. But you also have a pre-commit executable, which needs to be reasonably recent ideally, i.e. after pre-commit/pre-commit#2170, that is, at least v2.17.0. What does |
I think updating the used renv package would have solved my problems. |
Ok great. Also note that if you have many projects and you don’t want to use the defaults config file ( |
If an URL, it must be a raw file at the target, like this: you could contribute that example to the docs if you wanted under the examples of |
Similar to #316, I'm having trouble. I recently updated from 0.1.3 to 0.2.0, and I can't get anything working again. I followed the updating instructions which failed, and then tried to remove everything and try with a fresh installation. It doesn't seems to have something to do with the fact I use renv -- I tried deactivating it and still have the same issues.
I'm on Windows 10 with R 4.1.1.
The text was updated successfully, but these errors were encountered: