Skip to content

Commit 25c9c30

Browse files
authored
Merge pull request #1456 from rgaiacs/1455-fail-earlier
Fail earlier when user try to install future version of R
2 parents 703a864 + b650d28 commit 25c9c30

File tree

1 file changed

+20
-5
lines changed
  • repo2docker/buildpacks

1 file changed

+20
-5
lines changed

repo2docker/buildpacks/r.py

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import datetime
22
import os
3+
import re
34
import warnings
45
from functools import lru_cache
56

@@ -77,17 +78,31 @@ def r_version(self):
7778

7879
if not hasattr(self, "_r_version"):
7980
_, version, date = self.runtime
80-
# If runtime.txt is not set, or if it isn't of the form r-<version>-<yyyy>-<mm>-<dd>,
81+
# If runtime.txt is not set, or if it isn't of the form r-<version>-*,
8182
# we don't use any of it in determining r version and just use the default
82-
if version and date:
83+
if version:
8384
r_version = version
8485
# For versions of form x.y, we want to explicitly provide x.y.z - latest patchlevel
8586
# available. Users can however explicitly specify the full version to get something specific
8687
if r_version in version_map:
8788
r_version = version_map[r_version]
88-
elif len(r_version.split(".")) == 2:
89-
# must have x.y.z version, add .0 for unrecognized (future) R versions
90-
r_version += ".0"
89+
else:
90+
r_version_parts = r_version.split(".")
91+
if len(r_version_parts) == 3:
92+
self.log.info(
93+
f"Using R full version, {r_version}, provided by user."
94+
)
95+
else:
96+
# repo2docker fails earlier with a meaningful message to the user.
97+
# If repo2docker doesn't fail here, repo2docker might fail later
98+
# without a meaningful message to the user.
99+
raise RuntimeError(
100+
f"R version {r_version} is not supported. Please open an issue at https://github.com/jupyterhub/repo2docker/issues/new/choose.",
101+
)
102+
else:
103+
self.log.warning(
104+
f"R version unspecified, using default R version {r_version}. You can specify the R version in runtime.txt."
105+
)
91106

92107
# translate to the full version string
93108
self._r_version = r_version

0 commit comments

Comments
 (0)