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

Error: object 'never' not found on git commit #473

Closed
5 tasks done
sempwn opened this issue Mar 9, 2023 · 10 comments
Closed
5 tasks done

Error: object 'never' not found on git commit #473

sempwn opened this issue Mar 9, 2023 · 10 comments

Comments

@sempwn
Copy link

sempwn commented Mar 9, 2023

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 encounter the following error when running a git commit

[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] Restored changes from C:\Users\USER\.cache\pre-commit\patch1678401203-36472.
An unexpected error has occurred: CalledProcessError: command: ('C:/PROGRA~1/R/R-41~1.0\\bin\\Rscript.exe', '--vanilla', '-e', '    options(install.packages.compile.from.source = "never", pkgType = "binary")\n            prefix_dir <- \'C:\\\\Users\\\\USER\\\\.cache\\\\pre-commit\\\\repovawmpj_r\'\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
stdout: (none)
stderr:
    During startup - Warning messages:
    1: Setting LC_COLLATE=en_US.UTF-8 failed 
    2: Setting LC_CTYPE=en_US.UTF-8 failed 
    3: Setting LC_MONETARY=en_US.UTF-8 failed 
    4: Setting LC_TIME=en_US.UTF-8 failed 
    Error in options(install.packages.compile.from.source = never, pkgType = binary) : 
      object 'never' not found
    Execution halted
Check the log at C:\Users\USER\.cache\pre-commit\pre-commit.log

To Reproduce
I have installed Python in Windows 10 using reticulate to install miniconda as described in the README. I started with a minimal .pre-commit-config.yaml file that reproduces the above error:

repos:
-   repo: https://github.com/lorenzwalthert/precommit
    rev: v0.3.2.9007
    hooks:
    -   id: style-files

Additional context

  • My operating system is: windows 10
  • My project uses {renv}.
  • the output of packageVersion('renv') "0.14.0"
@lorenzwalthert
Copy link
Owner

This is basically what @EzicJ already found in #441 (comment). My reply then:

Ok I don't get that. Because clearly, in the source code, the word never is in quotes. Maybe still some problem with the slashes in the executable ('C:/PROGRA~1/R/R-41~1.0\\bin\\Rscript.exe')? Like can you try

C:/PROGRA~1/R/R-41~1.0\\bin\\Rscript.exe -e "print('this')"
# vs 
C:/PROGRA~1/R/R-41~1.0/bin/Rscript.exe -e "print('this')"
# vs 
C:\\PROGRA~1\\R\\R-41~1.0\\bin\\Rscript.exe -e "print('this')"

Just to see if it's worth re-raising that in the upstream repo?

If we don't find a solution here, we need to go upstream, basically it's anyways a python pre-commit issue, not an R {precommit} issue.

@sempwn
Copy link
Author

sempwn commented Mar 11, 2023

Thanks for the help and suggestion. All of the above examples you describe provided the expected output

[1] "this"

Thanks for pointing to the previous comments. I suspect it may be a PATH issue, but following comments in #441 have so far not resolved the error, I'll open an issue in the upstream repo.

@lorenzwalthert
Copy link
Owner

Ok. Great. Please link it back to here.

@lorenzwalthert
Copy link
Owner

@asottile after #441 it's the second windows issue where there is a problem with the R executable and I think that's a pre-commit issue. Any ideas?

@asottile
Copy link
Contributor

this looks like the cygwin weirdness with msys2 executables -- I haven't found a solution to it though :/ -- maybe we need to write out the little scripts into temporary directories and execute them instead of as Rscript -e ?

@lorenzwalthert
Copy link
Owner

ok, I am now more lost than before 😢. You mean for the installation of the hook, around the complicated string r_code_inst_environment ? Note that r_code_inst_environment itself contains code that writes the string to a file (activate.R) and is partly dynamic. E.g. getwd() is an R command to get the current working directory.

@asottile
Copy link
Contributor

asottile commented Apr 17, 2023

yeah right now it's running Rscript -e 'bunch of code' but if we switched it to Rscript /some/tmp/file/containing/code then we wouldn't have to deal with the weirdnesses with windows and msys unquoting

@lorenzwalthert
Copy link
Owner

@sempwn the issue should be fixed with the latest pre-commit release. Can you install that release, pre-commit clean and pre-commit install again and see if it works now?

@lorenzwalthert
Copy link
Owner

Assume this is resolved, re-open otherwise.

@sempwn
Copy link
Author

sempwn commented Aug 14, 2023

@lorenzwalthert Sorry taken me a while to follow up on this. Had to do a fresh install of Rstudio and R, but is now working for me. Thank you!

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

3 participants