Skip to content

Commit

Permalink
Merge pull request #1455 from rstudio/skip-unusable-system-venv-starter
Browse files Browse the repository at this point in the history
On Ubuntu, don't discover unusable system venv module.
  • Loading branch information
t-kalinowski authored Aug 18, 2023
2 parents 219a87a + 169593b commit ebb5f14
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions R/virtualenv.R
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,6 @@ virtualenv_create <- function(
if (is.null(python))
python <- virtualenv_starter(version)


check_can_be_virtualenv_starter(python, version)

module <- module %||% virtualenv_module(python)
Expand Down Expand Up @@ -409,8 +408,16 @@ virtualenv_module <- function(python) {

# if we have one of these modules available, return it
for (module in modules)
if (python_has_module(python, module))
if (python_has_module(python, module)) {
if(module == "venv" && is_ubuntu() && startsWith(python, "/usr/bin/python")) {
# `apt install python3` makes an importable venv module, but not one
# capable of actually creating a venv unless python3-venv is installed.
# if python3-venv is not installed, move on and maybe discover virtualenv.
if (!any(grepl("^python[0-9.]*-venv$", system("dpkg -l", intern = TRUE))))
next
}
return(module)
}

# virtualenv not available: instruct the user to install
commands <- stack(mode = "character")
Expand Down

0 comments on commit ebb5f14

Please sign in to comment.