Skip to content

Commit 1132e6e

Browse files
try to use right installation location for newer miniconda / Python
1 parent 064c769 commit 1132e6e

File tree

2 files changed

+21
-6
lines changed

2 files changed

+21
-6
lines changed

R/exec.R

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,9 @@ path_derive_precommit_exec_conda_impl <- function(conda_env) {
208208
ls <- reticulate::conda_list()
209209
path_reticulate <- fs::path_dir(ls[ls$name == conda_env, "python"][1])
210210
derived <- fs::path(
211-
path_reticulate,
211+
# if windows, remove bin/ and use just base directory
212+
ifelse(is_windows(), fs::path_dir(path_reticulate), path_reticulate),
213+
# if windows, append Scripts/
212214
ifelse(is_windows(), "Scripts", ""),
213215
precommit_executable_file()
214216
)

R/install.R

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,24 @@ install_impl <- function() {
5959
}
6060
reticulate::conda_install("r-precommit", packages = "pre-commit")
6161
# C:\Users\runneradmin\AppData\Local\r-miniconda\envs\r-precommit/python.exe
62-
63-
stop(
64-
"For debugging: these are files next to python executable ",
65-
list.files("C:\\Users\\RUNNER~1\\AppData\\Local\\R-MINI~1\\envs\\r-precommit", pattern = 'pre-commit.exe', recursive = TRUE)
66-
)
62+
# C:\\Users\\RUNNER~1\\AppData\\Local\\R-MINI~1\\envs\\r-precommit\\Scripts\\pre-commit.exe
63+
# stop(
64+
# "For debugging: these are files next to python executable ",
65+
# list.files("C:\\Users\\RUNNER~1\\AppData\\Local\\R-MINI~1\\envs\\r-precommit", pattern = 'pre-commit', recursive = TRUE)
66+
# )
67+
if (path_derive_precommit_exec_conda() == "") {
68+
base_dir <- grep("r-precommit", gsub("r-precommit.*", "r-precommit", reticulate::conda_list()$python, ), value = TRUE)[1]
69+
rlang::abort(c(
70+
paste0(
71+
"Please open an issue on https://github.com/lorenzwalthert/precommit and ",
72+
"report the below:\nFailed to install pre-commit in a location known to R ",
73+
"precommit. Here are candidates from the conda root (",
74+
base_dir,
75+
"):"
76+
),
77+
list.files(base_dir, pattern = "pre-commit", recursive = TRUE)
78+
))
79+
}
6780
}
6881

6982
#' Updates pre-commit on your system with conda

0 commit comments

Comments
 (0)