Giter VIP home page Giter VIP logo

Comments (12)

yogat3ch avatar yogat3ch commented on July 27, 2024 1

Thank you @lorenzwalthert for elaborating that process, the troubleshooting process is making more sense now!
I installed styler and also had to do the same for pkgload but it appears that pre-commit install --install-hooks is now going to work (still going, but it's been going for much longer this time).

Thanks for your work on this package! Do you have a means of taking one-off donations?

from precommit.

lorenzwalthert avatar lorenzwalthert commented on July 27, 2024 1

thanks for the support @yogat3ch, just to make sure we are on the same page: You selected a monthly donation now.

from precommit.

yogat3ch avatar yogat3ch commented on July 27, 2024 1

Indeed @lorenzwalthert , I decided to donate over time!

from precommit.

lorenzwalthert avatar lorenzwalthert commented on July 27, 2024 1

Thanks, I apprecaite that.

from precommit.

lorenzwalthert avatar lorenzwalthert commented on July 27, 2024

This seems similar to some problems in #476. I just created a wiki page for this problem: https://github.com/lorenzwalthert/precommit/wiki/Packages-are-not-found-after-R-upgrade. Can you follow these steps and let me know if it helps?

from precommit.

yogat3ch avatar yogat3ch commented on July 27, 2024

Hi @lorenzwalthert,
Thank you for the gist!
I'm trying to work through it now, and when run pre-commit install --install-hooks it errors.

An unexpected error has occurred: CalledProcessError: command: ('/Library/Frameworks/R.framework/Resources/bin/Rscript', '--vanilla', '-e', '    options(install.packages.compile.from.source = "never", pkgType = "binary")\n            prefix_dir <- \'/Users/stephenholsenbeck/.cache/pre-commit/repo6fq9kgbf\'\n        options(\n            repos = c(CRAN = "https://cran.rstudio.com"),\n            renv.consent = TRUE\n        )\n        source("renv/activate.R")\n        renv::restore()\n        activate_statement <- paste0(\n          \'suppressWarnings({\',\n          \'old <- setwd("\', getwd(), \'"); \',\n          \'source("renv/activate.R"); \',\n          \'setwd(old); \',\n          \'renv::load("\', getwd(), \'");})\'\n        )\n        writeLines(activate_statement, \'activate.R\')\n        is_package <- tryCatch(\n          {\n              path_desc <- file.path(prefix_dir, \'DESCRIPTION\')\n              suppressWarnings(desc <- read.dcf(path_desc))\n              "Package" %in% colnames(desc)\n          },\n          error = function(...) FALSE\n        )\n        if (is_package) {\n            renv::install(prefix_dir)\n        }\n        \n    ')
return code: 1
...
Error: failed to retrieve 'https://api.github.com/repos/r-lib/styler/tarball/96f859daf39f5973851c06506d7827808eea28a8' [cannot open URL 'https://api.github.com/repos/r-lib/styler/tarball/96f859daf39f5973851c06506d7827808eea28a8']
    In addition: Warning messages:
    1: In (function (url, destfile, method, quiet = FALSE, mode = "w",  :
      downloaded length 0 != reported length 0
    2: In (function (url, destfile, method, quiet = FALSE, mode = "w",  :
      cannot open URL 'https://packagemanager.rstudio.com/all/latest/': HTTP status was '404 Not Found'
    3: In (function (url, destfile, method, quiet = FALSE, mode = "w",  :
      downloaded length 0 != reported length 0
    4: In (function (url, destfile, method, quiet = FALSE, mode = "w",  :
      cannot open URL 'https://api.github.com/repos/r-lib/styler/tarball/96f859daf39f5973851c06506d7827808eea28a8': HTTP status was '401 Unauthorized'
    Traceback (most recent calls last):
    8: renv::restore()
    7: renv_restore_run_actions(project, diff, current, lockfile, rebuild)
    6: retrieve(packages)
    5: handler(package, renv_retrieve_impl(package))
    4: renv_retrieve_impl(package)
    3: renv_retrieve_github(record)
    2: renv_retrieve_package(record, url, path)
    1: stop(status)
    Execution halted

I'm seeing that the command appears to be trying to run renv::restore or something based on the stdout I see. It's using an outdated version of renv: 0.16.0, when my repo is running 0.17.2.

  # Bootstrapping renv 0.16.0 --------------------------------------------------
    * Downloading renv 0.16.0 ... OK
    * Installing renv 0.16.0 ... Done!
    * Successfully installed and loaded renv 0.16.0.
    The following package(s) will be updated:


I've attached the log here:
pre-commit.log

from precommit.

lorenzwalthert avatar lorenzwalthert commented on July 27, 2024

The renv.lock file was snapshotted using R 4.3.0, so those warnings are puzzling.

as per the docs, we don’t touch your renv for the project. It’s a different virtual environment installed in a different directory.

I'm seeing that the command appears to be trying to run renv::restore or something based on the stdout I see. It's using an outdated version of renv: 0.16.0, when my repo is running 0.17.2.

same reason.

from precommit.

lorenzwalthert avatar lorenzwalthert commented on July 27, 2024

Your next problem seems to relate to your GitHub credentials. If you exceeded the rate limit, then you can try again after some time. Can you try to install that styler package also directly with renv::install(β€œr-lib/styler@96f859daf39f5973851c06506d7827808eea28a8") anywhere (even in a repo withour renv) to add the package to the cache? If that works successfully, I think you should be able to pre-commit install --install-hooks without problems.

from precommit.

yogat3ch avatar yogat3ch commented on July 27, 2024

Im sorry, but I'm not following the reasoning here. Where is pre-commit install --install-hooks running from that it's running renv 0.16.0 and for some reason needs the styler package, and my GITHUB_PAT isn't available to it?

The repo from which I'm running the pre-commit install --install-hooks does not use the styler package, and my github credentials worked fine when I recently renv::restored for this repo.

From the log file error it looks like it's running from a random temp directory?
removing β€˜/Users/stephenholsenbeck/.cache/pre-commit/repo6fq9kgbf/renv-default/renv/staging/1/pkgload’

from precommit.

lorenzwalthert avatar lorenzwalthert commented on July 27, 2024

questions welcome πŸ˜„

pre-commit install --install-hooks does:

  • clone lorenzwalthert/precommit into its cache and give it a name starting with repo.... On macOS, that repo... lives in ~/.cache/pre-commit/.
  • Then, it places an installation script in that repo.
  • Then, it runs that script with the working directory being where the script is located, roughly it runs renv::restore().
  • As part of running the installation script, it also writes an activation script, that will be executed from your project's working directly, which roughly is 1) change working directory to repo..., 2) renv::load() (which is similar to renv::activate()) and 3) change back to your projects working directory.

When you then run a hook, it sets that activate script as your .Rprofile through an environment variable and executes the hook scripts.

from precommit.

lorenzwalthert avatar lorenzwalthert commented on July 27, 2024

I don't think your GITHUB_PAT is available now that I think about it because your .Rprofile is not used for running the hooks or isntalling them. That's why I created #486 to avoid depending on GitHub packages in future hook releases.

from precommit.

lorenzwalthert avatar lorenzwalthert commented on July 27, 2024

Welcome @yogat3ch πŸ˜„ . I hope it worked out this time?

I also want to find the source of the problem and improve the user experience, so thanks for helping out. On my GitHub Sponsors page, you can make either recurring or one-off donations:
image

from precommit.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.