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

rstudioapi dependency not installed by roxygenize hook #609

Closed
3 tasks done
grst opened this issue Jan 8, 2025 · 3 comments · Fixed by #610
Closed
3 tasks done

rstudioapi dependency not installed by roxygenize hook #609

grst opened this issue Jan 8, 2025 · 3 comments · Fixed by #610

Comments

@grst
Copy link

grst commented Jan 8, 2025

Before filing a bug

  • I have installed the latest dev version of {precommit} with remotes::install_github('lorenzwalthert/precommit')
  • I have installed the latest hook revisions (update with precommit::autoupdate())
  • I have installed the latest release of the upstream Python framework pre-comit as described under the update instructions.

Describe the bug

I have a package that depends on rstudioapi and declares so in its DESCRIPTION

Imports:
    yaml,
    glue,
    here,
    stringr,
    methods,
    rlang,
    rstudioapi (>= 0.11)

The package uses the roxygenize hook:

repos:
  - repo: https://github.com/lorenzwalthert/precommit
    rev: v0.4.3.9003
    hooks:
      - id: roxygenize

When running

pre-commit run --all-files

it fails with

roxygenize...............................................................Failed
- hook id: roxygenize
- exit code: 1

- The project is out-of-sync -- use `renv::status()` for details.
- The project is out-of-sync -- use `renv::status()` for details.
ℹ Loading dso
Error in `precommit::roxygenize_with_cache()`:
! The package "rstudioapi" (>= 0.11) is required.
Backtrace:
    ▆
 1. └─precommit::roxygenize_with_cache(key = wd, dirs = path_relative_cache)
 2.   └─rlang::abort(conditionMessage(out)) at repocskrdn2t/R/roxygen2.R:103:5
Execution halted

Expected behavior
All declared dependencies are automatically installed

Additional context

  • My operating system is: Rocky 9.4
  • [ ] My project uses {renv}.
  • [ ] the output of packageVersion('renv')

I was wondering if this is the same as #589, but it #589 already fails on installing the hook, whereas in my case it only fails open executing the hook. I also tried the pre-commit version from the branch you mention in that issue and it didn't help.

@lorenzwalthert
Copy link
Owner

Please check the docs, you need to add the dependencies manually. It seems the roxygen error changed and hence {precommit} does not show you the custom instructions anymore. Will fix this.

@grst
Copy link
Author

grst commented Jan 13, 2025

That's not how I understand the docs though:

If you specify additional roclets through the Roxygen: field in DESCRIPTION, e.g. from {pkgapi} you must specify the dependencies explicitly such that renv::install() understands it, e.g.

rstudioapi is not a dependency of a roclet, but of my package itself. Do I need to repeat all package dependencies in additional_dependencies?

@lorenzwalthert
Copy link
Owner

Yes, the docs are not very clear. Because with older versions of {roxygen2}, you should be prompted to add them manually (Räder Tue link to tue below function is missing). There is a helper function to generate the text to insert: https://lorenzwalthert.github.io/precommit/reference/snippet_generate.html

maybe this was displayed to you upon use_precommit()?

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

Successfully merging a pull request may close this issue.

2 participants