Skip to content

Rscript not found #441

Closed
pre-commit/pre-commit
#2605
@jaskozi

Description

@jaskozi

I have a problem when I want to commit after activating precommit with use_precommit()

I have the latest version, did the autoupdate, everything described here: https://lorenzwalthert.github.io/precommit/articles/precommit.html

My .pre-commit-config.yaml is the default one created after executing use_precommit()

The log file is as follows:

pre-commit version: 2.20.0
git --version: git version 2.33.0.windows.2
sys.version:
    3.9.7 | packaged by conda-forge | (default, Sep 23 2021, 07:24:41) [MSC v.1916 64 bit (AMD64)]
sys.executable: C:\Users\username\AppData\Local\MAMBAF~1\python.exe
os.name: nt
sys.platform: win32

### error information

An unexpected error has occurred: CalledProcessError: command: ('C:/PROGRA~1/R/R-41~1.0\\bin\\Rscript', '--vanilla', '-e', '    options(install.packages.compile.from.source = "never")\n                prefix_dir <- \'C:\\\\Users\\\\username\\\\.cache\\\\pre-commit\\\\repoz11tusy_\'\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
expected return code: 0
stdout:
    Executable `C:/PROGRA~1/R/R-41~1.0\bin\Rscript` not found
stderr: (none)


Traceback (most recent call last):
  File "C:\Users\username\AppData\Roaming\Python\Python39\site-packages\pre_commit\error_handler.py", line 73, in error_handler
    yield
  File "C:\Users\username\AppData\Roaming\Python\Python39\site-packages\pre_commit\main.py", line 358, in main
    return hook_impl(
  File "C:\Users\username\AppData\Roaming\Python\Python39\site-packages\pre_commit\commands\hook_impl.py", line 254, in hook_impl
    return retv | run(config, store, ns)
  File "C:\Users\username\AppData\Roaming\Python\Python39\site-packages\pre_commit\commands\run.py", line 424, in run
    install_hook_envs(to_install, store)
  File "C:\Users\username\AppData\Roaming\Python\Python39\site-packages\pre_commit\repository.py", line 223, in install_hook_envs
    _hook_install(hook)
  File "C:\Users\username\AppData\Roaming\Python\Python39\site-packages\pre_commit\repository.py", line 79, in _hook_install
    lang.install_environment(
  File "C:\Users\username\AppData\Roaming\Python\Python39\site-packages\pre_commit\languages\r.py", line 139, in install_environment
    cmd_output_b(
  File "C:\Users\username\AppData\Roaming\Python\Python39\site-packages\pre_commit\util.py", line 146, in cmd_output_b
    raise CalledProcessError(returncode, cmd, retcode, stdout_b, stderr_b)
pre_commit.util.CalledProcessError: command: ('C:/PROGRA~1/R/R-41~1.0\\bin\\Rscript', '--vanilla', '-e', '    options(install.packages.compile.from.source = "never")\n                prefix_dir <- \'C:\\\\Users\\\\username\\\\.cache\\\\pre-commit\\\\repoz11tusy_\'\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
expected return code: 0
stdout:
    Executable `C:/PROGRA~1/R/R-41~1.0\bin\Rscript` not found
stderr: (none)

The executable Rscript in the named folder is present, I checked manually
Thank you for your time!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions