Comments (12)
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.
thanks for the support @yogat3ch, just to make sure we are on the same page: You selected a monthly donation now.
from precommit.
Indeed @lorenzwalthert , I decided to donate over time!
from precommit.
Thanks, I apprecaite that.
from precommit.
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.
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.
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.
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.
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::restore
d 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.
questions welcome π
pre-commit install --install-hooks
does:
- clone lorenzwalthert/precommit into its cache and give it a name starting with
repo...
. On macOS, thatrepo...
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 torenv::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.
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.
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:
from precommit.
Related Issues (20)
- Make updating `inst/WORDLIST` optional HOT 1
- Roxygen hook does not work with manually running (and no staging) as well as in CI HOT 1
- Automate GitHub releases
- Submit to ropensci?
- grkstyle transformer styling error HOT 7
- Allow alternative spellcheck dictionary files HOT 9
- xfun-0.40 fails to build under Windows HOT 3
- Use frozen PPM snapshots
- specific package not available from MRAN - what would be the next step? HOT 4
- Failure with dev (now CRAN) roxygen2 HOT 1
- Executable `Rscript` not found in VS Code HOT 11
- Convoluted hook testing infra
- Failure with dev pkgdown HOT 5
- New hook: parsable-roxygen HOT 2
- Integration test hook dependency test fails on R 4.4
- `pip install pre-commit --user` gives error in CI on macOS
- Changing the R version breaks the pre-commit cache
- Add `.qmd` files to lintr hook
- Parallel execution of `style-files` hook causes race condition in styler `.onLoad` function HOT 1
- Use `spelling::update_wordlist()` instead of custom logic to update the wordlist for spell check
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from precommit.