-
-
Notifications
You must be signed in to change notification settings - Fork 48
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
Error in loadNamespace(x) : there is no package called ‘precommit’ with {renv} #602
Comments
A related issue is also reported on renv: rstudio/renv#1983 |
Thanks for noting that. There are several packages can be in the renv package library but do not appear in the lock.file, e.g. lintr and style in my case as they do not appear in a require or library call in the code since they are just used as part of development. One can force precommit to appear in the lock.file with a one line script that just uses library(precommit), but that does not change the behavior. The hooks in question use the code |
Ok, that should not be necessary. If this is not already part of the search heuristic, we should add this location.
Not from the docs, since it's not written there (sorry), but from rstudio/renv#1983:
|
Can you please try the steps explained in https://github.com/lorenzwalthert/precommit/wiki/Packages-are-not-found-after-R-upgrade and report back? |
Thanks for the references. I saw some older references from 2021 but was not sure if they were still valid or things had changed. The extra detail helped.
Bottom line though it still fails.
I went through the steps multiple times, restarting RStudio in between just to try to make sure things were clean.
I confirmed the cache at I checked the renv.lock file in the new cache and precommit is not listed. Should it be? After the commit failed I tried to purge from the cache.
I then tried the reinstall. However, it installed in the normal R location, not in the cache, or in my project renv (where it already exists).
Close RStudio and open it with my project again Try to commit and it fails with the above error message. I am happy to try something else. I understand what the activate.R is trying to do but I am not familiar enough with it to troubleshoot how it is actually working in my situation. Thanks, |
Thanks for your help and thorough docs.
Yes. But {precommit} itself won't be listed in that lockfile since it is placed in a clone of lorenzwalthert/precommit and it should install the package upon
These I have seen as well before, but they seem unrelated.
{precommit} itself won't be listed in that lockfile since it is placed in a clone of lorenzwalthert/precommit and it should install the package upon I see two ways forward:
|
Thanks for the additional info. I think we have success!!
I included the specific output as well as the precommit yaml and my .lintr file below in case that helps. Thanks so much! My problem appears to be solved but I will not close this yet in case you want to make comments. You can feel free to close or I can close in a few days. Thanks so much!! Ran it with the verbose flag.
I then ran without the -verbose flag and got the following results.
Complete config file follows:
Complete .lintr file
|
I am facing a slightly different issue with the installation (I am using a Windows machine). Whether I run When I try to run
I have installed the following version of {precommit} on RStudio:
|
@SaranjeetKaur sorry, this is not an R {precommit} problem, but rather an upstream / installation problem. What could help to locate to locate the executable: |
Some success - the I also tried
|
Are you saying if you do the cleaning and installing outside RStudio and then |
@lorenzwalthert the above error occurs when I run If I run all the three commands
|
I am on a silicon mac have installed the latest versions of pre-commit (using Homebrew) and precommit. 26 October 2024.
options(precommit.executable = "/opt/homebrew/bin/pre-commit")
The first three hooks in the default .pre-commit-config.yaml all fail. with the error:
Error in loadNamespace(x) : there is no package called ‘precommit’
I am able to get the hooks to work by adding an RScript to ensure the
renv::load()
occurs. I thought this was supposed to happen withactivate.R
.I am able to fix the first hook by adding an entry value.
I am able to fix the second hook, but one file at a time. I could use regex to get more but you get the idea.
I am able to fix the lintr hook as well.
I would like to be able to use the default pre-commit-config.yaml file without having to force renv to load for those hooks that use precommit in their code.
Originally, precommit was only installed in this repo. I then installed it for all users. It made no difference.
I checked the paths to packages as well.
Am I missing something in linking precommit, pre-commit, and renv? Please let me know.
Thanks
The text was updated successfully, but these errors were encountered: