From 7793691b88be98729f7262891e8d4e2e3242d17f Mon Sep 17 00:00:00 2001 From: yacchin1205 <968739+yacchin1205@users.noreply.github.com> Date: Fri, 10 Jul 2026 19:21:02 +0900 Subject: [PATCH] Fix build failure for wildcard R version pins like r-base=4.4.* --- repo2docker/buildpacks/_rstudio.py | 7 ++++++- tests/unit/test_rstudio.py | 4 ++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/repo2docker/buildpacks/_rstudio.py b/repo2docker/buildpacks/_rstudio.py index d0ba10f7..e0e59b56 100644 --- a/repo2docker/buildpacks/_rstudio.py +++ b/repo2docker/buildpacks/_rstudio.py @@ -77,6 +77,11 @@ def load_rstudio_yaml(path): return YAML().load(f) +def parse_r_version(r_version): + """Parse an R version pin; conda pins like "r-base=4.4.*" leave a trailing dot.""" + return V(r_version.rstrip(".")) + + def rstudio_server_installer(r_version, rstudio_config): """Return (url, sha256) of the RStudio Server .deb to install. @@ -103,6 +108,6 @@ def rstudio_server_installer(r_version, rstudio_config): f"does not exist: {url} returned {resp.status_code}" ) return url, sha256 - if r_version and V(r_version) < V(RSTUDIO_MIN_R_VERSION): + if r_version and parse_r_version(r_version) < V(RSTUDIO_MIN_R_VERSION): return LEGACY_RSTUDIO_URL, LEGACY_RSTUDIO_SHA256 return fetch_latest_rstudio_server() diff --git a/tests/unit/test_rstudio.py b/tests/unit/test_rstudio.py index 0ca205f7..54791363 100644 --- a/tests/unit/test_rstudio.py +++ b/tests/unit/test_rstudio.py @@ -50,7 +50,7 @@ def clear_fetch_cache(): fetch_latest_rstudio_server.cache_clear() -@pytest.mark.parametrize("r_version", ["3.3.3", "3.5.3"]) +@pytest.mark.parametrize("r_version", ["3.3.3", "3.5.3", "3.5."]) def test_legacy_rstudio_for_old_r(r_version): assert rstudio_server_installer(r_version, None) == ( LEGACY_RSTUDIO_URL, @@ -58,7 +58,7 @@ def test_legacy_rstudio_for_old_r(r_version): ) -@pytest.mark.parametrize("r_version", ["", "3.6", "4.2.1"]) +@pytest.mark.parametrize("r_version", ["", "3.6", "4.2.1", "4.4."]) def test_latest_rstudio(r_version): with patch("repo2docker.buildpacks._rstudio.requests.get") as mock_get: mock_get.return_value.json.return_value = DOWNLOADS_JSON