Skip to content

Commit

Permalink
Merge pull request #1550 from rstudio/conda-tweaks
Browse files Browse the repository at this point in the history
Improve echoed conda env mngt commands; echo miniconda install commands
  • Loading branch information
t-kalinowski authored Mar 13, 2024
2 parents c616732 + 0622f40 commit 1e00158
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
18 changes: 9 additions & 9 deletions R/conda.R
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ conda_create <- function(envname = NULL,
args <- c(args, "-c", ch)

# invoke conda
result <- system2t(conda, shQuote(args))
result <- system2t(conda, maybe_shQuote(args))
if (result != 0L) {
fmt <- "Error creating conda environment '%s' [exit code %i]"
stopf(fmt, envname, result, call. = FALSE)
Expand All @@ -260,10 +260,10 @@ conda_create_env <- function(envname, environment, conda) {
if (is.null(envname))
c()
else if (grepl("/", envname))
c("--prefix", shQuote(envname))
c("--prefix", maybe_shQuote(envname))
else
c("--name", shQuote(envname)),
"-f", shQuote(environment)
c("--name", maybe_shQuote(envname)),
"-f", maybe_shQuote(environment)
)

result <- system2t(conda, args)
Expand Down Expand Up @@ -302,7 +302,7 @@ conda_clone <- function(envname, ..., clone = "base", conda = "auto") {
args <- c(args, "--clone", clone)

# invoke conda
result <- system2t(conda, shQuote(args))
result <- system2t(conda, maybe_shQuote(args))
if (result != 0L) {
fmt <- "Error creating conda environment '%s' [exit code %i]"
stopf(fmt, envname, result, call. = FALSE)
Expand Down Expand Up @@ -376,7 +376,7 @@ conda_remove <- function(envname,

# remove packages (or the entire environment)
args <- conda_args("remove", envname, packages)
result <- system2t(conda, shQuote(args))
result <- system2t(conda, maybe_shQuote(args))
if (result != 0L) {
stop("Error ", result, " occurred removing conda environment ", envname,
call. = FALSE)
Expand Down Expand Up @@ -457,7 +457,7 @@ conda_install <- function(envname = NULL,
# (should be no-op if that copy of Python already installed)
if (!is.null(python_version)) {
args <- conda_args("install", envname, python_package)
status <- system2t(conda, shQuote(args))
status <- system2t(conda, maybe_shQuote(args))
if (status != 0L) {
fmt <- "installation of '%s' into environment '%s' failed [error code %i]"
msg <- sprintf(fmt, python_package, envname, status)
Expand Down Expand Up @@ -494,7 +494,7 @@ conda_install <- function(envname = NULL,
args <- c(args, "-c", ch)

args <- c(args, python_package, packages)
result <- system2t(conda, shQuote(args))
result <- system2t(conda, maybe_shQuote(args))

# check for errors
if (result != 0L) {
Expand Down Expand Up @@ -581,7 +581,7 @@ conda_update <- function(conda = "auto") {
name <- if ("anaconda" %in% envlist$name) "anaconda" else "conda"

# attempt update
system2t(conda, c("update", "--prefix", shQuote(prefix), "--yes", name))
system2t(conda, c("update", "--prefix", maybe_shQuote(prefix), "--yes", name))
}

numeric_conda_version <- function(conda = "auto", version_string = conda_version(conda)) {
Expand Down
4 changes: 2 additions & 2 deletions R/miniconda.R
Original file line number Diff line number Diff line change
Expand Up @@ -239,14 +239,14 @@ miniconda_installer_run <- function(installer, update, path) {
}
if (is_windows()) {
installer <- normalizePath(installer)
status <- system2(installer, args)
status <- system2t(installer, args)
}
if (is_unix()) {
##check for bash
bash_path <- Sys.which("bash")
if (bash_path[1] == "")
stopf("The miniconda installer requires bash.")
status <- system2(bash_path[1], c(installer, args))
status <- system2t(bash_path[1], c(installer, args))
}
if (status != 0)
stopf("miniconda installation failed [exit code %i]", status)
Expand Down

0 comments on commit 1e00158

Please sign in to comment.