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

Unable to load dependency for roxygenize #589

Open
3 of 5 tasks
pschloss opened this issue Sep 4, 2024 · 9 comments
Open
3 of 5 tasks

Unable to load dependency for roxygenize #589

pschloss opened this issue Sep 4, 2024 · 9 comments

Comments

@pschloss
Copy link

pschloss commented Sep 4, 2024

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'm trying to use the roxygenize hook with my package and went through the setup to copy and paste the package dependencies into the yaml. It complains that it cannot install {Rfast}, which I have installed on my computer for the package so I wouldn't think it should be a problem. There's also a lot of stuff popping up about rvest::setup() - I'm not using {rvest} with this package.

My .pre-commit-config.yml file is:

# All available hooks: https://pre-commit.com/hooks.html
# R specific hooks: https://github.com/lorenzwalthert/precommit
repos:
-   repo: https://github.com/lorenzwalthert/precommit
    rev: v0.4.3
    hooks:
    -   id: style-files
        args: [--style_pkg=styler, --style_fun=tidyverse_style]
    -   id: roxygenize
        # roxygen requires loading pkg -> add dependencies from DESCRIPTION
        additional_dependencies:
        -    Rcpp
        -    readr
        -    Rfast
        -    stats
        -    stringi
    # codemeta must be above use-tidy-description when both are used
    # -   id: codemeta-description-updated
    -   id: use-tidy-description
    -   id: spell-check
        exclude: >
          (?x)^(
          .*\.[rR]|
          .*\.feather|
          .*\.jpeg|
          .*\.pdf|
          .*\.png|
          .*\.py|
          .*\.RData|
          .*\.rds|
          .*\.Rds|
          .*\.Rproj|
          .*\.sh|
          (.*/|)\.gitignore|
          (.*/|)\.gitlab-ci\.yml|
          (.*/|)\.lintr|
          (.*/|)\.pre-commit-.*|
          (.*/|)\.Rbuildignore|
          (.*/|)\.Renviron|
          (.*/|)\.Rprofile|
          (.*/|)\.travis\.yml|
          (.*/|)appveyor\.yml|
          (.*/|)NAMESPACE|
          (.*/|)renv/settings\.dcf|
          (.*/|)renv\.lock|
          (.*/|)WORDLIST|
          \.github/workflows/.*|
          data/.*|
          )$
    -   id: lintr
    -   id: readme-rmd-rendered
    -   id: parsable-R
    -   id: no-browser-statement
    -   id: no-print-statement
    -   id: no-debug-statement
    -   id: deps-in-desc
    -   id: pkgdown

-   repo: https://github.com/pre-commit/pre-commit-hooks
    rev: v4.6.0
    hooks:
    -   id: check-added-large-files
        args: ['--maxkb=200']
    -   id: file-contents-sorter
        files: '^\.Rbuildignore$'
    -   id: end-of-file-fixer
        exclude: '\.Rd'
-   repo: https://github.com/pre-commit-ci/pre-commit-ci-config
    rev: v1.6.1
    hooks:
    # Only required when https://pre-commit.ci is used for config validation
    -   id: check-pre-commit-ci-config
-   repo: local
    hooks:
    -   id: forbid-to-commit
        name: Don't commit common R artifacts
        entry: Cannot commit .Rhistory, .RData, .Rds or .rds.
        language: fail
        files: '\.(Rhistory|RData|Rds|rds)$'
        # `exclude: <regex>` to allow committing specific files

ci:
    autoupdate_schedule: monthly
    skip: [pkgdown]

To Reproduce

$ git commit -m "Testing roxygenize hook"
[INFO] Installing environment for https://github.com/lorenzwalthert/precommit.
[INFO] Once installed this environment will be reused.
[INFO] This may take a few minutes...
An unexpected error has occurred: CalledProcessError: command: ('/Library/Frameworks/R.framework/Resources/bin/Rscript', '--no-save', '--no-restore', '--no-site-file', '--no-environ', '/var/folders/zk/8t6nr57d6_l_s0hvcc7j2xxw0000gr/T/tmpjbd15eep/script.R', 'Rcpp', 'readr', 'Rfast', 'stats', 'stringi')
return code: 1
stdout:
    - The project is out-of-sync -- use `renv::status()` for details.
    - The project is out-of-sync -- use `renv::status()` for details.
    # Downloading packages -------------------------------------------------------
    - Downloading readr from RSPM ...               OK [file is up to date]
    - Downloading clipr from RSPM ...               OK [file is up to date]
    - Downloading hms from RSPM ...                 OK [file is up to date]
    - Downloading pkgconfig from RSPM ...           OK [file is up to date]
    - Downloading tibble from RSPM ...              OK [file is up to date]
    - Downloading fansi from RSPM ...               OK [file is up to date]
    - Downloading pillar from RSPM ...              OK [file is up to date]
    - Downloading utf8 from RSPM ...                OK [file is up to date]
    - Downloading vroom from RSPM ...               OK [file is up to date]
    - Downloading bit64 from RSPM ...               OK [file is up to date]
    - Downloading bit from RSPM ...                 OK [file is up to date]
    - Downloading tidyselect from RSPM ...          OK [file is up to date]
    - Downloading tzdb from RSPM ...                OK [file is up to date]
    - Downloading progress from RSPM ...            OK [file is up to date]
    - Downloading prettyunits from RSPM ...         OK [file is up to date]
    Traceback (most recent calls last):
    15: renv::install(commandArgs(trailingOnly = TRUE))
    14: retrieve(packages)
    13: handler(package, renv_retrieve_impl(package))
    12: renv_retrieve_impl(package)
    11: withCallingHandlers(renv_available_packages_latest(package), 
            error = function(err) stopf("package '%s' is not available", 
                package))
    10: renv_available_packages_latest(package)
     9: map(errors$data(), warning)
     8: lapply(x, f, ...)
     7: FUN(X[[i]], ...)
     6: withRestarts({
            .Internal(.signalCondition(cond, message, call))
            .Internal(.dfltWarn(message, call))
        }, muffleWarning = function() NULL)
     5: withOneRestart(expr, restarts[[1L]])
     4: doWithOneRestart(return(expr), restart)
     3: <condition-handler>(...)
     2: stopf("package '%s' is not available", package)
     1: stop(sprintf(fmt, ...), call. = call.)
stderr:
    Error: package 'Rfast' is not available
    Execution halted
Check the log at /Users/pschloss/.cache/pre-commit/pre-commit.log

Expected behavior
I would expect it to flag an Rd file for being out of step with the roxygen comments in one of my code files.

Additional context

  • My operating system is: Mac OS X 14.6.1
  • My project uses {renv}.
  • the output of packageVersion('renv')
@lorenzwalthert
Copy link
Owner

lorenzwalthert commented Sep 4, 2024

I think it can’t work because that package is not available as binary from the public ppm, which is the repo we rely on and during the installation, we only allow binaries I think. Can you install with renv::install() interactively, then clean the pre-commit cache with pre-commit clean and see if afterwards, run pre-commit install and then check if committing works?

@pschloss
Copy link
Author

pschloss commented Sep 4, 2024

Thanks for the help. That didn't help. I posted to the Posit dev community forum to see if it would be possible to get a binary posted.

Pat

@lorenzwalthert
Copy link
Owner

Did you install the exact same version that you listed in your pre-commit config file?

@lorenzwalthert
Copy link
Owner

Because rent has a cache and if a package is already installed, installing again will take it from the cache. You should see that interactively when you install the same package twice.

@pschloss
Copy link
Author

pschloss commented Sep 5, 2024

I'm not 100% that I follow what you're asking me to try, so here's the transcript...

$ R

R version 4.4.1 (2024-06-14) -- "Race for Your Life"
Copyright (C) 2024 The R Foundation for Statistical Computing
Platform: aarch64-apple-darwin20

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

  Natural language support but running in an English locale

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> remove.packages("Rfast")
Removing package from ‘/Library/Frameworks/R.framework/Versions/4.4-arm64/Resources/library’
(as ‘lib’ is unspecified)
> q()
$ R

R version 4.4.1 (2024-06-14) -- "Race for Your Life"
Copyright (C) 2024 The R Foundation for Statistical Computing
Platform: aarch64-apple-darwin20

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

  Natural language support but running in an English locale

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> renv::install()
The following package(s) will be installed:
- Rfast [2.1.0]
These packages will be installed into "/Library/Frameworks/R.framework/Versions/4.4-arm64/Resources/library".

Do you want to proceed? [Y/n]: Y

# Installing packages --------------------------------------------------------
- Installing Rfast ...                          OK [copied from cache]
Successfully installed 1 package in 85 milliseconds.
> q()
$ pre-commit clean
Cleaned /Users/pschloss/.cache/pre-commit.
$ pre-commit install
pre-commit installed at .git/hooks/pre-commit
$ git commit -m "Correct typo"
[INFO] Initializing environment for https://github.com/lorenzwalthert/precommit.
[INFO] Initializing environment for https://github.com/lorenzwalthert/precommit:Rcpp,readr,Rfast,stats,stringi.
[INFO] Initializing environment for https://github.com/pre-commit/pre-commit-hooks.
[INFO] Initializing environment for https://github.com/pre-commit-ci/pre-commit-ci-config.
[INFO] Installing environment for https://github.com/lorenzwalthert/precommit.
[INFO] Once installed this environment will be reused.
[INFO] This may take a few minutes...
[INFO] Installing environment for https://github.com/lorenzwalthert/precommit.
[INFO] Once installed this environment will be reused.
[INFO] This may take a few minutes...
An unexpected error has occurred: CalledProcessError: command: ('/usr/local/bin/Rscript', '--no-save', '--no-restore', '--no-site-file', '--no-environ', '/var/folders/zk/8t6nr57d6_l_s0hvcc7j2xxw0000gr/T/tmp59havxjp/script.R', 'Rcpp', 'readr', 'Rfast', 'stats', 'stringi')
return code: 1
stdout:
    - The project is out-of-sync -- use `renv::status()` for details.
    - The project is out-of-sync -- use `renv::status()` for details.
    # Downloading packages -------------------------------------------------------
    - Downloading readr from RSPM ...               OK [file is up to date]
    - Downloading clipr from RSPM ...               OK [file is up to date]
    - Downloading hms from RSPM ...                 OK [file is up to date]
    - Downloading pkgconfig from RSPM ...           OK [file is up to date]
    - Downloading tibble from RSPM ...              OK [file is up to date]
    - Downloading fansi from RSPM ...               OK [file is up to date]
    - Downloading pillar from RSPM ...              OK [file is up to date]
    - Downloading utf8 from RSPM ...                OK [file is up to date]
    - Downloading vroom from RSPM ...               OK [file is up to date]
    - Downloading bit64 from RSPM ...               OK [file is up to date]
    - Downloading bit from RSPM ...                 OK [file is up to date]
    - Downloading tidyselect from RSPM ...          OK [file is up to date]
    - Downloading tzdb from RSPM ...                OK [file is up to date]
    - Downloading progress from RSPM ...            OK [file is up to date]
    - Downloading prettyunits from RSPM ...         OK [file is up to date]
    Traceback (most recent calls last):
    15: renv::install(commandArgs(trailingOnly = TRUE))
    14: retrieve(packages)
    13: handler(package, renv_retrieve_impl(package))
    12: renv_retrieve_impl(package)
    11: withCallingHandlers(renv_available_packages_latest(package), 
            error = function(err) stopf("package '%s' is not available", 
                package))
    10: renv_available_packages_latest(package)
     9: map(errors$data(), warning)
     8: lapply(x, f, ...)
     7: FUN(X[[i]], ...)
     6: withRestarts({
            .Internal(.signalCondition(cond, message, call))
            .Internal(.dfltWarn(message, call))
        }, muffleWarning = function() NULL)
     5: withOneRestart(expr, restarts[[1L]])
     4: doWithOneRestart(return(expr), restart)
     3: <condition-handler>(...)
     2: stopf("package '%s' is not available", package)
     1: stop(sprintf(fmt, ...), call. = call.)
stderr:
    Error: package 'Rfast' is not available
    Execution halted
Check the log at /Users/pschloss/.cache/pre-commit/pre-commit.log

It's installing Rfast v.2.1.0, which is what I have in DESCRIPTION

@lorenzwalthert
Copy link
Owner

lorenzwalthert commented Sep 5, 2024

sorry I mean't renv::install('[email protected]') (to install Rfast, same version as you have in your .pre-commit-config.yaml), not renv::install() to install all dependencies of a project.

@pschloss
Copy link
Author

pschloss commented Sep 5, 2024

Thanks again. Unfortunately, that gives the same type of error...

$ R

R version 4.4.1 (2024-06-14) -- "Race for Your Life"
Copyright (C) 2024 The R Foundation for Statistical Computing
Platform: aarch64-apple-darwin20

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

  Natural language support but running in an English locale

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> remove.packages("Rfast")
Removing package from ‘/Library/Frameworks/R.framework/Versions/4.4-arm64/Resources/library’
(as ‘lib’ is unspecified)
> renv::install('[email protected]')
The following package(s) will be installed:
- Rfast [2.1.0]
These packages will be installed into "/Library/Frameworks/R.framework/Versions/4.4-arm64/Resources/library".

Do you want to proceed? [Y/n]: Y

# Installing packages --------------------------------------------------------
- Installing Rfast ...                          OK [copied from cache in 0.43s]
Successfully installed 1 package in 0.44 seconds.
> q()
$ pre-commit clean
Cleaned /Users/pschloss/.cache/pre-commit.
$ pre-commit install
pre-commit installed at .git/hooks/pre-commit
$ git commit -m "Correct typo"
[INFO] Initializing environment for https://github.com/lorenzwalthert/precommit.
[INFO] Initializing environment for https://github.com/lorenzwalthert/precommit:Rcpp,readr,Rfast,stats,stringi.
[INFO] Initializing environment for https://github.com/pre-commit/pre-commit-hooks.
[INFO] Initializing environment for https://github.com/pre-commit-ci/pre-commit-ci-config.
[INFO] Installing environment for https://github.com/lorenzwalthert/precommit.
[INFO] Once installed this environment will be reused.
[INFO] This may take a few minutes...
[INFO] Installing environment for https://github.com/lorenzwalthert/precommit.
[INFO] Once installed this environment will be reused.
[INFO] This may take a few minutes...
An unexpected error has occurred: CalledProcessError: command: ('/usr/local/bin/Rscript', '--no-save', '--no-restore', '--no-site-file', '--no-environ', '/var/folders/zk/8t6nr57d6_l_s0hvcc7j2xxw0000gr/T/tmp9haoalu6/script.R', 'Rcpp', 'readr', 'Rfast', 'stats', 'stringi')
return code: 1
stdout:
    - The project is out-of-sync -- use `renv::status()` for details.
    - The project is out-of-sync -- use `renv::status()` for details.
    # Downloading packages -------------------------------------------------------
    - Downloading readr from RSPM ...               OK [file is up to date]
    - Downloading clipr from RSPM ...               OK [file is up to date]
    - Downloading hms from RSPM ...                 OK [file is up to date]
    - Downloading pkgconfig from RSPM ...           OK [file is up to date]
    - Downloading tibble from RSPM ...              OK [file is up to date]
    - Downloading fansi from RSPM ...               OK [file is up to date]
    - Downloading pillar from RSPM ...              OK [file is up to date]
    - Downloading utf8 from RSPM ...                OK [file is up to date]
    - Downloading vroom from RSPM ...               OK [file is up to date]
    - Downloading bit64 from RSPM ...               OK [file is up to date]
    - Downloading bit from RSPM ...                 OK [file is up to date]
    - Downloading tidyselect from RSPM ...          OK [file is up to date]
    - Downloading tzdb from RSPM ...                OK [file is up to date]
    - Downloading progress from RSPM ...            OK [file is up to date]
    - Downloading prettyunits from RSPM ...         OK [file is up to date]
    Traceback (most recent calls last):
    15: renv::install(commandArgs(trailingOnly = TRUE))
    14: retrieve(packages)
    13: handler(package, renv_retrieve_impl(package))
    12: renv_retrieve_impl(package)
    11: withCallingHandlers(renv_available_packages_latest(package), 
            error = function(err) stopf("package '%s' is not available", 
                package))
    10: renv_available_packages_latest(package)
     9: map(errors$data(), warning)
     8: lapply(x, f, ...)
     7: FUN(X[[i]], ...)
     6: withRestarts({
            .Internal(.signalCondition(cond, message, call))
            .Internal(.dfltWarn(message, call))
        }, muffleWarning = function() NULL)
     5: withOneRestart(expr, restarts[[1L]])
     4: doWithOneRestart(return(expr), restart)
     3: <condition-handler>(...)
     2: stopf("package '%s' is not available", package)
     1: stop(sprintf(fmt, ...), call. = call.)
stderr:
    Error: package 'Rfast' is not available
    Execution halted
Check the log at /Users/

- [ ] pschloss

/.cache/pre-commit/pre-commit.log

@lorenzwalthert
Copy link
Owner

lorenzwalthert commented Sep 15, 2024

I might have good news for you. With #594, I prepare to allow source installations again. This change needs to happen in the python pre-commit package. I pushed some changes to my fork that you can try. I suggest to install that version in a virtual environment and use the absolute path to reference it to be sure you use the right installation.

mkdir pre-commit.no-binary.python
cd pre-commit.no-binary.python   
python3 -m venv .venv
source .venv/bin/activate 
pip install git+https://github.com/lorenzwalthert/pre-commit.git@allow-source-fallback  

Then use the executable at .venv/bin/pre-commit, I suggest to first /path/to/new/pre-commit clean and then /path/to/new/pre-commit install --install-hooks in your repo. If this works, you should be able to commit, as --install-hooks already tries to install the hooks. Let me know if that works or not. Thanks for your help.

@lorenzwalthert
Copy link
Owner

@pschloss did you have a chance to try this out?

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

No branches or pull requests

2 participants