### Install R GitHub Dependency Interactively Source: https://github.com/lorenzwalthert/precommit/wiki/GitHub-dependencies-can't-be-installed Use this command to install an R GitHub dependency interactively after ensuring your `GITHUB_PAT` is set. This bypasses pre-commit's vanilla mode limitations. ```r renv::install("tidyverse/dplyr") ``` -------------------------------- ### Install Package Manually with renv Source: https://github.com/lorenzwalthert/precommit/wiki/Packages-are-not-found-after-R-upgrade After purging, reinstall the package using `renv::install` to add it to the cache with the correct version. This ensures it is available for pre-commit. ```R renv::install('docopt') ``` -------------------------------- ### Install Pre-commit Hooks Source: https://github.com/lorenzwalthert/precommit/wiki/Packages-are-not-found-after-R-upgrade After cleaning the cache, reinstall the pre-commit hooks to ensure they are linked with the correct R version. ```bash pre-commit install --install-hooks ``` -------------------------------- ### Configure CI with pre-commit.ci or GitHub Actions Source: https://context7.com/lorenzwalthert/precommit/llms.txt Sets up CI for running pre-commit hooks on pull requests. Supports pre-commit.ci ('native') or GitHub Actions ('gha'). Pass NA to skip CI setup. ```r library(precommit) # Set up pre-commit.ci (opens browser for GitHub authentication) use_ci(ci = "native") #> • Sign in with GitHub to authenticate https://pre-commit.ci and then come back... # Set up GitHub Actions workflow instead use_ci(ci = "gha", force = TRUE) #> ✔ Added GitHub Action template to ".github/workflows/pre-commit.yaml". # Persist preference in .Rprofile so use_precommit() picks it up automatically # options(precommit.ci = "gha") ``` -------------------------------- ### Set up pre-commit for a git repository Source: https://context7.com/lorenzwalthert/precommit/llms.txt The primary onboarding function. Copies a template .pre-commit-config.yaml, runs autoupdate, installs git hooks, and optionally sets up CI. Detects R package vs. generic project for template selection. ```r library(precommit) # Basic setup — uses built-in template, sets up pre-commit.ci use_precommit() # Supply a custom config file from a URL use_precommit( config_source = "https://raw.githubusercontent.com/org/repo/main/.pre-commit-config.yaml" ) # Setup without CI, without autoupdate, removing any pre-existing legacy hooks use_precommit( ci = NA, autoupdate = FALSE, legacy_hooks = "remove", install_hooks = TRUE, root = "/path/to/my/git/repo" ) #> #> ✔ Copied .pre-commit-config.yaml to /path/to/my/git/repo #> ✔ Ran pre-commit autoupdate to get the latest version of the hooks. #> ✔ Sucessfully installed pre-commit for repo. ``` -------------------------------- ### Interactive Mode Notice for Programs Source: https://github.com/lorenzwalthert/precommit/blob/main/LICENSE.md Display this notice when a program starts in interactive mode to inform users about its licensing, warranty, and redistribution terms. ```text precommit Copyright (C) 2019 Lorenz Watlhert This program comes with ABSOLUTELY NO WARRANTY; for details type 'show w'. This is free software, and you are welcome to redistribute it under certain conditions; type 'show c' for details. ``` -------------------------------- ### Configure Pre-Commit Hooks in .pre-commit-config.yaml Source: https://context7.com/lorenzwalthert/precommit/llms.txt Example configuration for an R package using the precommit repository. Pin to a specific release using 'rev' and specify hooks by 'id'. Some hooks accept 'args' or require 'additional_dependencies'. ```yaml repos: - repo: https://github.com/lorenzwalthert/precommit rev: v0.4.3 # pin to a specific release hooks: # Style R/Rmd/Rnw/qmd files using {styler} - id: style-files args: [--style_pkg=styler, --style_fun=tidyverse_style] # Run roxygen2::roxygenize() when roxygen comments change - id: roxygenize additional_dependencies: - your-pkg-dep-1 - your-pkg-dep-2 # Run usethis::use_tidy_description() to normalize DESCRIPTION - id: use-tidy-description # Spell check documentation with {spelling} - id: spell-check exclude: '(?x)^(.*\[rR\]|.*\.png|.*\.pdf|(.*\/|)NAMESPACE)$' # Lint R files with {lintr} - id: lintr # Ensure README.md is rendered from README.Rmd - id: readme-rmd-rendered # Check R/Rmd files are syntactically valid - id: parsable-R # Check roxygen comments are parsable - id: parsable-roxygen # Forbid browser() statements - id: no-browser-statement # Forbid print() statements - id: no-print-statement # Forbid debug() / debugonce() statements - id: no-debug-statement # Check package dependencies are declared in DESCRIPTION - id: deps-in-desc # Validate pkgdown config with pkgdown::check_pkgdown() - id: pkgdown # Keep codemeta.json in sync with DESCRIPTION - id: codemeta-description-updated # Validate renv.lock against its JSON schema - id: renv-lockfile-validate ``` -------------------------------- ### Install pre-commit executable via conda Source: https://context7.com/lorenzwalthert/precommit/llms.txt Installs the pre-commit Python executable into the 'r-precommit' conda environment. Requires the reticulate package. Use `force = TRUE` to reinstall if needed. ```r library(precommit) # First-time installation (requires reticulate + conda) install_precommit() #> #> ℹ Installing pre-commit into the conda environment `r-precommit`. #> ✔ Sucessfully installed pre-commit on your system. #> • To use it with this project, run `precommit::use_precommit()` # Force reinstall (e.g., after conda environment corruption) install_precommit(force = TRUE) # Check the path to the installed executable path_precommit_exec() #> #> [1] "/Users/you/miniforge3/envs/r-precommit/bin/pre-commit" ``` -------------------------------- ### Get Path to pre-commit Executable Source: https://context7.com/lorenzwalthert/precommit/llms.txt Reads the R option `precommit.executable` and returns the path to the pre-commit executable. Optionally checks if the executable exists. ```r library(precommit) # Get current executable path (errors if not found) path_precommit_exec() #> [1] "/Users/you/miniforge3/envs/r-precommit/bin/pre-commit" # Get path without existence check (useful for diagnostics) path_precommit_exec(check_if_exists = FALSE) #> [1] "/Users/you/miniforge3/envs/r-precommit/bin/pre-commit" # Override executable path manually options(precommit.executable = "/usr/local/bin/pre-commit") path_precommit_exec() #> [1] "/usr/local/bin/pre-commit" ``` -------------------------------- ### use_precommit() Source: https://context7.com/lorenzwalthert/precommit/llms.txt The primary function for setting up pre-commit for a git repository. It copies a template `.pre-commit-config.yaml` to the repository root, runs `autoupdate()` to pin hook revisions, installs the git hook script, and optionally sets up CI. It automatically detects whether the repository is an R package or a generic project to select the appropriate template. ```APIDOC ## use_precommit() ### Description Sets up pre-commit for a git repository by copying a template `.pre-commit-config.yaml`, running `autoupdate()`, installing git hooks, and optionally configuring CI. Detects project type (R package or generic) for template selection. ### Method `use_precommit(config_source = NULL, ci = TRUE, autoupdate = TRUE, legacy_hooks = "skip", install_hooks = TRUE, root = ".")` ### Parameters #### Query Parameters - **config_source** (string or NULL) - Optional - A URL or local path to a custom `.pre-commit-config.yaml` file. If NULL, uses a built-in template. - **ci** (boolean or NA) - Optional - Whether to set up CI integration. Set to `NA` to disable. - **autoupdate** (boolean) - Optional - Whether to run `pre-commit autoupdate()` after copying the config. Defaults to `TRUE`. - **legacy_hooks** (string) - Optional - How to handle legacy hooks. Options: "skip", "remove". Defaults to "skip". - **install_hooks** (boolean) - Optional - Whether to run `pre-commit install --install-hooks`. Defaults to `TRUE`. - **root** (string) - Optional - The path to the repository root. Defaults to the current directory. ### Request Example ```r library(precommit) # Basic setup — uses built-in template, sets up pre-commit.ci use_precommit() # Supply a custom config file from a URL use_precommit( config_source = "https://raw.githubusercontent.com/org/repo/main/.pre-commit-config.yaml" ) # Setup without CI, without autoupdate, removing any pre-existing legacy hooks use_precommit( ci = NA, autoupdate = FALSE, legacy_hooks = "remove", install_hooks = TRUE, root = "/path/to/my/git/repo" ) ``` ### Response #### Success Response (stdout) - Informational messages indicating the steps performed (config copied, autoupdate run, hooks installed). #### Response Example ``` #> ✔ Copied .pre-commit-config.yaml to /path/to/my/git/repo #> ✔ Ran pre-commit autoupdate to get the latest version of the hooks. #> ✔ Sucessfully installed pre-commit for repo. ``` ``` -------------------------------- ### install_precommit() Source: https://context7.com/lorenzwalthert/precommit/llms.txt Installs the upstream `pre-commit` Python executable into a dedicated conda environment (`r-precommit`). This makes the executable available system-wide for use in any git repository. Requires the `{reticulate}` package. Use `force = TRUE` to reinstall if an executable is already present. ```APIDOC ## install_precommit() ### Description Installs the upstream `pre-commit` Python executable via conda into the `r-precommit` environment, making it available system-wide. Requires the `{reticulate}` package. Use `force = TRUE` to reinstall even if an executable is already detected. ### Method `install_precommit(force = FALSE)` ### Parameters #### Query Parameters - **force** (boolean) - Optional - Use `TRUE` to force reinstallation even if an executable is already detected. ### Request Example ```r library(precommit) # First-time installation (requires reticulate + conda) install_precommit() # Force reinstall (e.g., after conda environment corruption) install_precommit(force = TRUE) ``` ### Response #### Success Response (stdout) - Informational messages about the installation process and success. #### Response Example ``` #> ℹ Installing pre-commit into the conda environment `r-precommit`. #> ✔ Sucessfully installed pre-commit on your system. #> • To use it with this project, run `precommit::use_precommit()` ``` ``` -------------------------------- ### Pre-commit GitHub Dependency Installation Error Source: https://github.com/lorenzwalthert/precommit/wiki/GitHub-dependencies-can't-be-installed This error occurs when pre-commit exceeds GitHub's API rate limits while trying to download repositories specified in `.pre-commit-config.yaml`. ```text Error: failed to resolve remote 'r-lib/pkgapi' -- failed to retrieve 'https://api.github.com/repos/r-lib/pkgapi' [error code 22] In addition: Warning message: curl: (22) The requested URL returned error: 401 Traceback (most recent calls last): ``` -------------------------------- ### Update pre-commit Executable Source: https://context7.com/lorenzwalthert/precommit/llms.txt Updates the `pre-commit` Python executable in the conda environment `r-precommit` to the latest version. Only works for conda installations and reports version changes. ```r library(precommit) # Update pre-commit executable update_precommit() #> ✔ Successfully updated pre-commit from version 3.5.0 to 3.7.1. # If already at latest version update_precommit() #> ℹ Nothing to update, your version 3.7.1 is the latest available. ``` -------------------------------- ### path_precommit_exec() — Get path to the pre-commit executable Source: https://context7.com/lorenzwalthert/precommit/llms.txt Reads the R option `precommit.executable` and returns the path to the pre-commit executable. Optionally checks if the executable exists at that path. ```APIDOC ## `path_precommit_exec()` — Get path to the pre-commit executable Reads the R option `precommit.executable` and returns the path to the pre-commit executable. Optionally checks whether the executable exists at that path. ```r library(precommit) # Get current executable path (errors if not found) path_precommit_exec() #> [1] "/Users/you/miniforge3/envs/r-precommit/bin/pre-commit" # Get path without existence check (useful for diagnostics) path_precommit_exec(check_if_exists = FALSE) #> [1] "/Users/you/miniforge3/envs/r-precommit/bin/pre-commit" # Override executable path manually options(precommit.executable = "/usr/local/bin/pre-commit") path_precommit_exec() #> [1] "/usr/local/bin/pre-commit" ``` ``` -------------------------------- ### update_precommit() — Update the pre-commit executable Source: https://context7.com/lorenzwalthert/precommit/llms.txt Updates the `pre-commit` Python executable in the conda environment `r-precommit` to the latest available version. This function only works for conda-based installations. ```APIDOC ## `update_precommit()` — Update the pre-commit executable Updates the `pre-commit` Python executable in the conda environment `r-precommit` to the latest available version. Only works for conda-based installations. Reports old and new versions. ```r library(precommit) # Update pre-commit executable update_precommit() #> ✔ Successfully updated pre-commit from version 3.5.0 to 3.7.1. # If already at latest version update_precommit() #> ℹ Nothing to update, your version 3.7.1 is the latest available. ``` ``` -------------------------------- ### use_ci() — Configure continuous integration for pre-commit Source: https://context7.com/lorenzwalthert/precommit/llms.txt Sets up CI for running pre-commit hooks on pull requests. Supports pre-commit.ci ('native') or GitHub Actions ('gha'). ```APIDOC ## `use_ci()` — Configure continuous integration for pre-commit Sets up CI for running pre-commit hooks on pull requests. Supports [pre-commit.ci](https://pre-commit.ci) (`"native"`) which requires only browser authentication, or GitHub Actions (`"gha"`) which writes a workflow file to `.github/workflows/pre-commit.yaml`. Pass `NA` to skip CI setup. ```r library(precommit) # Set up pre-commit.ci (opens browser for GitHub authentication) use_ci(ci = "native") #> • Sign in with GitHub to authenticate https://pre-commit.ci and then come back... # Set up GitHub Actions workflow instead use_ci(ci = "gha", force = TRUE) #> ✔ Added GitHub Action template to `.github/workflows/pre-commit.yaml`. # Persist preference in .Rprofile so use_precommit() picks it up automatically # options(precommit.ci = "gha") ``` ``` -------------------------------- ### Standard Copyright and GPL Notice Source: https://github.com/lorenzwalthert/precommit/blob/main/LICENSE.md Include this notice at the beginning of each source file to state the copyright and terms of redistribution under the GNU GPL. ```text Copyright (C) 2019 Lorenz Watlhert This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . ``` -------------------------------- ### Retrieve pre-commit Executable Version Source: https://context7.com/lorenzwalthert/precommit/llms.txt Returns the version string of the pre-commit executable by running `pre-commit --version`. Useful for conditional logic based on version. ```r library(precommit) version_precommit() #> [1] "3.7.1" # Use in conditional logic if (package_version(version_precommit()) < "2.13.0") { warning("Please update pre-commit to >= 2.13.0 for full hook support.") } ``` -------------------------------- ### Open Config Files in RStudio Source: https://context7.com/lorenzwalthert/precommit/llms.txt Opens `.pre-commit-config.yaml` or `inst/WORDLIST` in the RStudio editor. These helpers wrap `rstudioapi::navigateToFile()` and require an active RStudio session. ```r library(precommit) # Open .pre-commit-config.yaml in the RStudio editor open_config() # Open inst/WORDLIST for managing spell-check exceptions open_wordlist() # Both accept a root argument for non-standard working directories open_config(root = "/path/to/project") open_wordlist(root = "/path/to/project") ``` -------------------------------- ### version_precommit() — Retrieve the pre-commit executable version Source: https://context7.com/lorenzwalthert/precommit/llms.txt Returns the version string of the currently configured pre-commit executable by running `pre-commit --version`. ```APIDOC ## `version_precommit()` — Retrieve the pre-commit executable version Returns the version string of the currently configured pre-commit executable by running `pre-commit --version`. ```r library(precommit) version_precommit() #> [1] "3.7.1" # Use in conditional logic if (package_version(version_precommit()) < "2.13.0") { warning("Please update pre-commit to >= 2.13.0 for full hook support.") } ``` ``` -------------------------------- ### open_config() / open_wordlist() — Open config files in RStudio Source: https://context7.com/lorenzwalthert/precommit/llms.txt Opens `.pre-commit-config.yaml` or `inst/WORDLIST` in the RStudio editor for interactive editing. These are convenience helpers that wrap `rstudioapi::navigateToFile()`. ```APIDOC ## `open_config()` / `open_wordlist()` — Open config files in RStudio Opens `.pre-commit-config.yaml` or `inst/WORDLIST` in the RStudio editor for interactive editing. These are convenience helpers that wrap `rstudioapi::navigateToFile()` and require an active RStudio session. ```r library(precommit) # Open .pre-commit-config.yaml in the RStudio editor open_config() # Open inst/WORDLIST for managing spell-check exceptions open_wordlist() # Both accept a root argument for non-standard working directories open_config(root = "/path/to/project") open_wordlist(root = "/path/to/project") ``` ``` -------------------------------- ### use_precommit_config() Source: https://context7.com/lorenzwalthert/precommit/llms.txt Copies a `.pre-commit-config.yaml` file into the repository root from a specified source (local path, URL, or built-in template). For R packages, it also appends the config filename to `.Rbuildignore`. This function can be used independently to refresh or set up the configuration file. ```APIDOC ## use_precommit_config() ### Description Copies a `.pre-commit-config.yaml` file into the repository root from a local path, URL, or a built-in template. For R packages, it also appends the config filename to `.Rbuildignore`. Can be called independently to refresh or set up the config file. ### Method `use_precommit_config(config_source = NULL, force = FALSE, verbose = FALSE)` ### Parameters #### Query Parameters - **config_source** (string or NULL) - Optional - A URL, local path, or name of a built-in template for the `.pre-commit-config.yaml` file. If NULL, uses a built-in template. - **force** (boolean) - Optional - Overwrite an existing `.pre-commit-config.yaml` file if it exists. Defaults to `FALSE`. - **verbose** (boolean) - Optional - If `TRUE`, prints verbose output during the process. Defaults to `FALSE`. ### Request Example ```r library(precommit) # Use the built-in package template (auto-detects pkg vs project) use_precommit_config() # Use a custom local config use_precommit_config( config_source = "~/dotfiles/.pre-commit-config.yaml", force = TRUE # overwrite existing config ) # Download from a remote URL use_precommit_config( config_source = "https://raw.githubusercontent.com/lorenzwalthert/precommit/main/inst/pre-commit-config-proj.yaml", verbose = TRUE ) ``` ### Response #### Success Response (stdout) - Informational messages about copying the config file, including download status if applicable. #### Response Example ``` #> ℹ Downloading remote config from https://... #> ✔ Copied .pre-commit-config.yaml to /your/project ``` ``` -------------------------------- ### Copy a pre-commit config file into a repo Source: https://context7.com/lorenzwalthert/precommit/llms.txt Copies a .pre-commit-config.yaml from a local path, URL, or built-in template into the repository root. For R packages, it also appends the config filename to .Rbuildignore. Can refresh the config file independently. ```r library(precommit) # Use the built-in package template (auto-detects pkg vs project) use_precommit_config() # Use a custom local config use_precommit_config( config_source = "~/dotfiles/.pre-commit-config.yaml", force = TRUE # overwrite existing config ) # Download from a remote URL use_precommit_config( config_source = "https://raw.githubusercontent.com/lorenzwalthert/precommit/main/inst/pre-commit-config-proj.yaml", verbose = TRUE ) #> #> ℹ Downloading remote config from https://... #> ✔ Copied .pre-commit-config.yaml to /your/project ``` -------------------------------- ### autoupdate() Source: https://context7.com/lorenzwalthert/precommit/llms.txt Runs the `pre-commit autoupdate` command to update the `rev:` field of each hook repository in the `.pre-commit-config.yaml` file to their latest tagged releases. It also performs validation for renv/pre-commit compatibility before proceeding with the update. ```APIDOC ## autoupdate() ### Description Runs `pre-commit autoupdate` to update the `rev:` field of each hook repository in `.pre-commit-config.yaml` to the latest tagged release. Validates renv/pre-commit compatibility before updating. ### Method `autoupdate(root = ".")` ### Parameters #### Query Parameters - **root** (string) - Optional - The path to the repository root where the `.pre-commit-config.yaml` file is located. Defaults to the current directory. ### Request Example ```r library(precommit) # Update all hook revisions to their latest tags in the current repository autoupdate() # Run in a specific repo root autoupdate(root = "/path/to/project") ``` ### Response #### Success Response (stdout) - Confirmation message that `pre-commit autoupdate` was run successfully. #### Response Example ``` #> ✔ Ran pre-commit autoupdate to get the latest version of the hooks. ``` ``` -------------------------------- ### Generate additional dependencies for roxygenize hook Source: https://github.com/lorenzwalthert/precommit/blob/main/NEWS.md Use this snippet to generate the necessary code for the `additional_dependencies` field in `.pre-commit-config.yaml` when using the `roxygenize` hook. This ensures all package dependencies are listed for isolated hook environments. ```r precommit::snippet_generate("additional-deps-roxygenize") ``` -------------------------------- ### Uninstall pre-commit from Repo or System Source: https://context7.com/lorenzwalthert/precommit/llms.txt Removes pre-commit from the current repository (uninstalls hook, deletes config) or the system (removes conda environment). Interactive prompts can be suppressed. ```r library(precommit) # Remove pre-commit from current repo only (keeps system install) uninstall_precommit(scope = "repo", ask = "none") #> ✔ Uninstalled pre-commit from repo scope. #> ✔ Removed .pre-commit-config.yaml. # Remove the system-level executable too (prompts for confirmation) uninstall_precommit(scope = "user", ask = "user") #> You are about to uninstall pre-commit from the conda env r-precommit... #> Type 'yes' to continue: yes #> ✔ Removed pre-commit from conda env r-precommit. ``` -------------------------------- ### Generate Config Snippets for Hook Dependencies Source: https://context7.com/lorenzwalthert/precommit/llms.txt Generates YAML snippets for `.pre-commit-config.yaml`, especially for `additional_dependencies` required by hooks that load packages. Reads hard dependencies from DESCRIPTION. ```r library(precommit) # Generate additional_dependencies block for the roxygenize hook snippet_generate("additional-deps-roxygenize") #> - id: roxygenize #> # roxygen requires loading pkg -> add dependencies from DESCRIPTION #> additional_dependencies: #> - cli #> - dplyr #> - rlang # Generate additional_dependencies for the lintr hook snippet_generate("additional-deps-lintr") #> - id: lintr #> # lintr requires loading pkg -> add dependencies from DESCRIPTION #> additional_dependencies: #> - cli #> - dplyr ``` -------------------------------- ### Clean Pre-commit Cache Source: https://github.com/lorenzwalthert/precommit/wiki/Packages-are-not-found-after-R-upgrade Run this command to remove the pre-commit cache, which may contain outdated or incompatible binaries after an R upgrade. ```bash pre-commit clean ``` -------------------------------- ### R Hook Script Helpers for Roxygenize and Dependency Checking Source: https://context7.com/lorenzwalthert/precommit/llms.txt Low-level R functions for use in custom hook scripts. `diff_requires_run_roxygenize` checks staged diffs, `roxygenize_with_cache` wraps `roxygen2::roxygenise` with caching, and `robust_purl` extracts R code from Rmd/Rnw files. ```r # Used internally by inst/hooks/exported/roxygenize.R — shown for reference library(precommit) # Check if staged diff contains roxygen changes if (diff_requires_run_roxygenize(root = ".")) { # Assert all declared dependencies are installed roxygen_assert_additional_dependencies() # Roxygenize and save a cache timestamp key <- list("roxygenize", Sys.getenv("PRE_COMMIT_FROM_REF")) roxygenize_with_cache(key = key, dirs = precommit::dirs_R.cache("roxygenize")) } # Extract R code from an Rmd for dependency checking r_code_path <- robust_purl("vignettes/my-vignette.Rmd") # r_code_path is a tempfile with .R extension, ready for parse()/source() ``` -------------------------------- ### Remove Offending Package with renv Source: https://github.com/lorenzwalthert/precommit/wiki/Packages-are-not-found-after-R-upgrade If packages are still not found, use `renv::purge` to remove the problematic package from the renv cache. This command can be run from any working directory. ```R renv::purge('docopt') ``` -------------------------------- ### snippet_generate() — Generate config snippets for hook dependencies Source: https://context7.com/lorenzwalthert/precommit/llms.txt Generates YAML snippets for `.pre-commit-config.yaml`, specifically for `additional_dependencies` required by hooks that load packages. ```APIDOC ## `snippet_generate()` — Generate config snippets for hook dependencies Generates YAML snippets to paste into `.pre-commit-config.yaml`, particularly for listing `additional_dependencies` required by hooks that load the package (such as `roxygenize` and `lintr`). Reads hard dependencies from the `DESCRIPTION` file automatically. ```r library(precommit) # Generate additional_dependencies block for the roxygenize hook snippet_generate("additional-deps-roxygenize") #> - id: roxygenize #> # roxygen requires loading pkg -> add dependencies from DESCRIPTION #> additional_dependencies: #> - cli #> - dplyr #> - rlang # Generate additional_dependencies for the lintr hook snippet_generate("additional-deps-lintr") #> - id: lintr #> # lintr requires loading pkg -> add dependencies from DESCRIPTION #> additional_dependencies: #> - cli #> - dplyr ``` ``` -------------------------------- ### Update hook revisions in .pre-commit-config.yaml Source: https://context7.com/lorenzwalthert/precommit/llms.txt Runs `pre-commit autoupdate` to update the `rev:` field of each hook repository to the latest tagged release. Validates renv/pre-commit compatibility before updating. ```r library(precommit) # Update all hook revisions to their latest tags autoupdate() #> #> ✔ Ran pre-commit autoupdate to get the latest version of the hooks. # Run in a specific repo root autoupdate(root = "/path/to/project") ``` -------------------------------- ### uninstall_precommit() — Remove pre-commit from a repo or system Source: https://context7.com/lorenzwalthert/precommit/llms.txt Removes pre-commit from the current repository (scope = 'repo') or the system entirely (scope = 'user'). Interactive prompts can be suppressed. ```APIDOC ## `uninstall_precommit()` — Remove pre-commit from a repo or system Removes pre-commit from the current repository (`scope = "repo"`) by uninstalling the git hook script and deleting `.pre-commit-config.yaml`, or from the system entirely (`scope = "user"`) by removing the conda environment installation. Interactive prompts can be suppressed with `ask = "none"`. ```r library(precommit) # Remove pre-commit from current repo only (keeps system install) uninstall_precommit(scope = "repo", ask = "none") #> ✔ Uninstalled pre-commit from repo scope. #> ✔ Removed .pre-commit-config.yaml. # Remove the system-level executable too (prompts for confirmation) uninstall_precommit(scope = "user", ask = "user") #> You are about to uninstall pre-commit from the conda env r-precommit... #> Type 'yes' to continue: yes #> ✔ Removed pre-commit from conda env r-precommit. ``` ``` -------------------------------- ### R Package Not Found Error Source: https://github.com/lorenzwalthert/precommit/wiki/Packages-are-not-found-after-R-upgrade This error message indicates that a required R package is missing or incompatible after an R upgrade. It often appears during the R package loading process. ```R Error in loadNamespace(x) : there is no package called ‘docopt’ Calls: loadNamespace -> withRestarts -> withOneRestart -> doWithOneRestart Execution halted ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.