Fail earlier when user try to install future version of R

Closes https://github.com/jupyterhub/repo2docker/issues/1455
pull/1456/head
Raniere Gaia Costa da Silva 2025-08-22 12:58:30 +02:00
rodzic 724ac1749e
commit 88d489de52
1 zmienionych plików z 13 dodań i 3 usunięć

Wyświetl plik

@ -1,6 +1,7 @@
import datetime
import os
import re
import warnings
from functools import lru_cache
import requests
@ -99,9 +100,18 @@ class RBuildPack(PythonBuildPack):
# available. Users can however explicitly specify the full version to get something specific
if r_version in version_map:
r_version = version_map[r_version]
elif len(r_version.split(".")) == 2:
# must have x.y.z version, add .0 for unrecognized (future) R versions
r_version += ".0"
else:
# Instead of appending ".0" to future R versions,
# repo2docker fails earlier with a meaningful message to the user.
# If repo2docker doesn't fail here, repo2docker might fail later
# without a meaningul message to the user.
raise RuntimeError(
f"R version {r_version} is not supported. Please open an issue using https://github.com/jupyterhub/repo2docker/issues/new?template=BLANK_ISSUE.",
)
else:
warnings.warn(
f"Using R version {r_version} instead of full version, i.e. MAJOR.MINOR.PATCH."
)
# translate to the full version string
self._r_version = r_version