Comments (26)
> renv::purge("[email protected]")
* The requested package is not installed in the cache -- nothing to do.
from precommit.
-
I don't know if switching R version is the problem here. Does it work with R 4.2? I.e. maybe the binary for {assertr} for R 4.2 is not compatible with R 4.3 and renv can
-
Can you try to install the required version of assertr with {renv} in a fresh renv and see if that works? And then retry pre-commit? Maybe once it's cached, it works.
from precommit.
- I don't know if switching R version is the problem here. Does it work with R 4.2? I.e. maybe the binary for {assertr} for R 4.2 is not compatible with R 4.3
I tried with R 4.2 and precommit still fails. However, when I try install.packages("assertr")
in R 4.2.3, I get an error:
tcltk DLL is linked to '/usr/local/lib/libtk8.6.dylib'
Error: .onLoad failed in loadNamespace() for 'tcltk', details:
call: fun(libname, pkgname)
error: Tcl/Tk libraries are missing: install the Tcl/Tk component from the R installer
But I don't see this error in v4.3.0 - {assertr} can be installed successfully. So I think it is as you say: the binary for {assertr} for R 4.2 is not compatible with R 4.3.
- Can you try to install the required version of assertr with {renv} in a fresh renv and see if that works? And then retry pre-commit? Maybe once it's cached, it works.
I'm unclear on what renv.lock
file {precommit} is using. I thought it always uses https://github.com/lorenzwalthert/precommit/blob/main/renv.lock, so there is no point in me trying to create my own renv.lock?
If indeed the problem is that the current renv.lock
in {precommit} is no longer compatible with R 4.3.0 for some packages, could it be updated?
from precommit.
With additional_dependencies
, pre-commit just installs into the renv that you have, without updating any lockfile. So maybe you can clone the {precommit} package, run renv::restore()
, and then renv::install('yourpkg@version')
and see if that also fails? If it does, maybe renv::purge()
the package and retry?
If this already fails at restore()
, we know the problem is not related to {assertr}.
from precommit.
Thanks for the explanation.
After cloning {precommit}, I am able to run renv::restore()
then renv::install("[email protected]")
.
I did see a warning that the lockfile was out of date before restoring, but ignored it.
FYI I frequently encounter warnings like this:
> renv::snapshot()
WARNING: One or more problems were discovered while enumerating dependencies.
/Users/joelnitta/repos/precommit/tests/testthat/in/parsable-R-fail.R
--------------------------------------------------------------------
ERROR 1: /Users/joelnitta/repos/precommit/tests/testthat/in/parsable-R-fail.R:1:3: unexpected numeric constant
1: 1 1
^
/Users/joelnitta/repos/precommit/tests/testthat/in/parsable-R-fail.Rmd
----------------------------------------------------------------------
ERROR 1: <text>:7:3: unexpected numeric constant
6:
7: 1 1
^
/Users/joelnitta/repos/precommit/tests/testthat/in/parsable-R-success.Rmd
-------------------------------------------------------------------------
ERROR 1: <text>:16:11: unexpected numeric constant
15:
16: fas / fk 12
^
/Users/joelnitta/repos/precommit/tests/testthat/in/style-files-fail-parse.R
---------------------------------------------------------------------------
ERROR 1: /Users/joelnitta/repos/precommit/tests/testthat/in/style-files-fail-parse.R:1:4: unexpected ')'
1: 1+ )
^
Please see `?renv::dependencies` for more information.
Do you want to proceed? [y/N]: y
from precommit.
Ok. Yes, these warnings were expected. Some test files are not parsable on purpose (to test functions). I suggest you pre-commit clean
in the repo where you want to use the hooks and purge the assertr package with {renv} from anywhere and try again to run pre-commit.
from precommit.
Sorry, can you clarify what you mean by "purge the assertr package with {renv} from anywhere"?
The package where I want to use precommit does not have a renv.lock file (does not use renv) so I can't "purge" it.
from precommit.
renv::purge("[email protected]")
seems a global operation independent of an activated renv, so can you run this from any directory? Otherwise from where you have installed the package in (cloned {precommit}).
from precommit.
I have the same behavior with 4.3.0
$ pre-commit
[INFO] Initializing environment for https://github.com/compilerla/conventional-pre-commit.
[INFO] Initializing environment for https://github.com/lorenzwalthert/precommit.
[INFO] Initializing environment for https://github.com/lorenzwalthert/precommit:ggplot2,scales,sf,dplyr,lwgeom,cowplot,purrr,git2r.
[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: ('/Library/Frameworks/R.framework/Resources/bin/Rscript', '--no-save', '--no-restore', '--no-site-file', '--no-environ', '-e', ' options(install.packages.compile.from.source = "never", pkgType = "binary")\n renv::install(commandArgs(trailingOnly = TRUE))\n ', 'ggplot2', 'scales', 'sf', 'dplyr', 'lwgeom', 'cowplot', 'purrr', 'git2r')
return code: 1
stdout:
ℹ Using R 4.3.0 (lockfile was generated with R 4.2.1)
ℹ Using R 4.3.0 (lockfile was generated with R 4.2.1)
stderr:
Error: package 'ggplot2' is not available
In addition: Warning message:
no MRAN records available from repository URL '/bin/macosx/big-sur-x86_64/contrib/4.3'
Traceback (most recent calls last):
7: renv::install(commandArgs(trailingOnly = TRUE))
6: retrieve(names(remotes))
5: handler(package, renv_retrieve_impl(package))
4: renv_retrieve_impl(package)
3: renv_available_packages_latest(package)
2: stopf("package '%s' is not available", package)
1: stop(sprintf(fmt, ...), call. = call.)
Execution halted
Check the log at /Users/maikol/.cache/pre-commit/pre-commit.log
This is the log file.
from precommit.
The problem in my config is this chunk, generated by precommit::snippet_generate('additional-deps-roxygenize')
.
- id: roxygenize
# roxygen requires loading pkg -> add dependencies from DESCRIPTION
additional_dependencies:
- ggplot2
- scales
- sf
- dplyr
- lwgeom
- cowplot
- purrr
I removed it, and precommit is working again.
from precommit.
I can confirm that removing the id: roxygenize
chunk allows precommit to work, and putting it back results in the error again.
@lorenzwalthert do you mind explaining why you need to install all of the package dependencies in the precommit renv environment?
from precommit.
they need to be installed because running roxygen requires pkgload::load_all()
as mentioned in #243 and r-lib/roxygen2#771. Hence, we'll probably create a new hook with language: script
in the future to rely on the global R library for roxygenise.
from precommit.
no MRAN records available from repository URL '/bin/macosx/big-sur-x86_64/contrib/4.3'
I don't know if the problem is alwo that MRAN has no binaries built for 4.3 and since it will retire soon, maybe they don't plan to do so in the future at all. May be an issue for {renv} in general, see rstudio/renv#1179.
from precommit.
So I guess a reasonable work-around for now is to turn off the roxygenize
pre-commit check (so I won't be checking for .Rd files rendered after changes to the source). Better than running git commit --no-verify
everytime I suppose.
from precommit.
My above suggestions:
- purge offending package with version from {renv} cache.
pre-commit clean
to delete pre-commit cache.
attempt to commit. If does not work, yes, then you can de-activate the hook by commenting the id of the hook out in .pre-commit-config.yaml
.
from precommit.
I appear to be having a similar issue, albeit not related to the package assertr
, but other packages required in the installation of the pre-commit renv. The issue started after I upgraded from R 4.2.1 to 4.3.
I've attached the pre-commit log below:
The precommit yaml I am using 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.3.2.9007
hooks:
- id: style-files
args: [--style_pkg=styler, --style_fun=tidyverse_style]
- 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-debug-statement
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
hooks:
- id: check-added-large-files
args: ['--maxkb=200']
- id: end-of-file-fixer
exclude: '\.Rd'
- repo: https://github.com/pre-commit-ci/pre-commit-ci-config
rev: v1.5.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
To reproduce
- In RStudio, open new blank project.
- In RStudio, run
precommit::use_precommit()
- Run
pre-commit
on command line within project directory
Additional context
- I have installed the latest dev version of {
precommit
} withremotes::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-commit using
brew update pre-commit
- My operating system is: Mac OS Ventura 13.3.1
- My project uses {
renv
}: No - The output of
packageVersion('renv')
: 0.17.3
from precommit.
Related Issues (20)
- Feature: allow package-loading prior to lint hook HOT 17
- Rscript not found HOT 35
- File editing suggestions presumably points to a wrong filename HOT 2
- The defaults are seemingly different in different format checkers HOT 4
- New hook: cff HOT 15
- FR: Run `urlchecker::url_update()` to fix link rot? HOT 5
- FR: Add a pre-commit hook for YAML formatting HOT 2
- Catch up with pre-commit.ci lite HOT 6
- Update to lintr needed? HOT 4
- consider using other cran mirror HOT 7
- Child Rmd documents pose problems for parsable-R hook? HOT 2
- Typo in available-hooks.Rmd for lintr warn arg HOT 1
- Error during environment installation. HOT 11
- Roxygenize hook only looks at MRAN; alternative CRAN repos are not specifiable HOT 1
- Error: object 'never' not found on git commit HOT 10
- Different CRAN repositories for different platforms HOT 1
- CI fails for miniconda on Windows HOT 1
- precommit deps-in-desc hook failing after upgrade to R 4.3.0 in renv locked package HOT 12
- Don't rely on any GitHub Packages due to credential issues
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.