Skip to content

Commit 0ea6f7d

Browse files
authored
Merge pull request #1285 from minrk/rmmran
Microsoft killed MRAN, stop relying on it
2 parents e8eab15 + 18e76f9 commit 0ea6f7d

File tree

12 files changed

+32
-84
lines changed

12 files changed

+32
-84
lines changed

docs/source/config_files.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ with ``REQUIRE`` and ``environment.yml``, visit
118118
================================================
119119

120120
This is used to install R libraries pinned to a specific snapshot on
121-
`MRAN <https://mran.microsoft.com/documents/rro/reproducibility>`_.
121+
`Posit Package Manager <https://packagemanager.posit.co/>`_.
122122
To set the date of the snapshot add a runtime.txt_.
123123
For an example ``install.R`` file, visit our `example install.R file <https://github.com/binder-examples/r/blob/HEAD/install.R>`_.
124124

@@ -207,7 +207,7 @@ For these cases, we have a special file, ``runtime.txt``.
207207
Have ``python-x.y`` in ``runtime.txt`` to run the repository with Python version x.y.
208208
See our `Python2 example repository <https://github.com/binder-examples/python2_runtime/blob/HEAD/runtime.txt>`_.
209209

210-
Have ``r-<RVERSION>-<YYYY>-<MM>-<DD>`` in ``runtime.txt`` to run the repository with R version RVERSION and libraries from a YYYY-MM-DD snapshot of `MRAN <https://mran.microsoft.com/documents/rro/reproducibility>`_.
210+
Have ``r-<RVERSION>-<YYYY>-<MM>-<DD>`` in ``runtime.txt`` to run the repository with R version RVERSION and libraries from a YYYY-MM-DD snapshot of `Posit Package Manager <https://packagemanager.posit.co/client/#/repos/2/overview>`__.
211211
RVERSION can be set to 3.4, 3.5, 3.6, or to patch releases for the 3.5 and 3.6 series.
212212
If you do not specify a version, the latest release will be used (currently R 3.6).
213213
See our `R example repository <https://github.com/binder-examples/r/blob/HEAD/runtime.txt>`_.

docs/source/howto/languages.rst

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,17 +65,14 @@ to install libraries from on the given date. You can install more R packages fro
6565
by adding a :ref:`install.R<install.R>` file to your repo. RStudio and IRKernel are
6666
installed by default for all R versions.
6767

68-
If you request R 4.1 or later, or specify a snapshot date newer than
69-
``2022-01-01``, `packagemanager.posit.co <https://packagemanager.posit.co/client/#/>`_
68+
`packagemanager.posit.co <https://packagemanager.posit.co/client/#/>`_
7069
will be used to provide much faster installations via `binary packages <https://www.rstudio.com/blog/package-manager-v1-1-no-interruptions/>`_.
7170
For *some* packages, this might require you install underlying system libraries
7271
using :ref:`apt.txt` - look at the page for the CRAN package you are interested in at
7372
`packagemanager.posit.co <https://packagemanager.posit.co/client/#/>`_ to find
7473
a list.
7574

76-
For older R versions with an older snapshot date, `MRAN <https://mran.microsoft.com/>`_
77-
is used as source of packages. This purely provides source packages, and you should
78-
migrate away from this if possible.
75+
repo2docker stopped using the Microsoft mirror MRAN for older R versions after its shutdown in July, 2023.
7976

8077

8178
Julia

repo2docker/buildpacks/r.py

Lines changed: 12 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@
99
from ._r_base import rstudio_base_scripts
1010
from .python import PythonBuildPack
1111

12+
# Aproximately the first snapshot on RSPM (Posit package manager)
13+
# that seems to have a working IRKernel.
14+
RSPM_CUTOFF_DATE = datetime.date(2018, 12, 7)
15+
1216

1317
class RBuildPack(PythonBuildPack):
1418
"""
@@ -22,8 +26,7 @@ class RBuildPack(PythonBuildPack):
2226
2327
Where 'year', 'month' and 'date' refer to a specific
2428
date whose CRAN snapshot we will use to fetch packages.
25-
Uses https://packagemanager.posit.co, or MRAN if no snapshot
26-
is found on packagemanager.posit.co
29+
Uses https://packagemanager.posit.co.
2730
2831
2. A `DESCRIPTION` file signaling an R package
2932
@@ -229,31 +232,6 @@ def get_rspm_snapshot_url(self, snapshot_date, max_days_prior=7):
229232
)
230233
)
231234

232-
@lru_cache()
233-
def get_mran_snapshot_url(self, snapshot_date, max_days_prior=7):
234-
for i in range(max_days_prior):
235-
try_date = snapshot_date - datetime.timedelta(days=i)
236-
# Fall back to MRAN if packagemanager.posit.co doesn't have it
237-
url = f"https://mran.microsoft.com/snapshot/{try_date.isoformat()}"
238-
r = requests.head(url)
239-
if r.ok:
240-
return url
241-
raise ValueError(
242-
"No snapshot found for {} or {} days prior in mran.microsoft.com".format(
243-
snapshot_date.strftime("%Y-%m-%d"), max_days_prior
244-
)
245-
)
246-
247-
@lru_cache()
248-
def get_cran_mirror_url(self, snapshot_date):
249-
# Date after which we will use rspm + binary packages instead of MRAN + source packages
250-
rspm_cutoff_date = datetime.date(2022, 1, 1)
251-
252-
if snapshot_date >= rspm_cutoff_date or self.r_version >= V("4.1"):
253-
return self.get_rspm_snapshot_url(snapshot_date)
254-
else:
255-
return self.get_mran_snapshot_url(snapshot_date)
256-
257235
@lru_cache()
258236
def get_devtools_snapshot_url(self):
259237
"""
@@ -291,8 +269,14 @@ def get_build_scripts(self):
291269
We set the snapshot date used to install R libraries from based on the
292270
contents of runtime.txt.
293271
"""
272+
if self.checkpoint_date < RSPM_CUTOFF_DATE:
273+
raise RuntimeError(
274+
f'Microsoft killed MRAN, the source of R package snapshots before {RSPM_CUTOFF_DATE.strftime("%Y-%m-%d")}. '
275+
f'This repo has a snapshot date of {self.checkpoint_date.strftime("%Y-%m-%d")} specified in runtime.txt. '
276+
"Please use a newer snapshot date"
277+
)
294278

295-
cran_mirror_url = self.get_cran_mirror_url(self.checkpoint_date)
279+
cran_mirror_url = self.get_rspm_snapshot_url(self.checkpoint_date)
296280

297281
if self.platform != "linux/amd64":
298282
raise RuntimeError(

tests/r/README.md

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -24,18 +24,6 @@
2424
`runtime.txt` is omitted and a recent enough snapshot date is assumed a RSPM
2525
snapshot of CRAN to be used.
2626

27-
### r3.6-mran
28-
29-
- Test setup of a R 3.6 environment by specifying `r-3.6-...` in `runtime.txt`,
30-
where the date provided in `runtime.txt` is old enough for a MRAN snapshot of
31-
CRAN to be used.
32-
33-
### r4.0-mran
34-
35-
- Test setup of a R 4.0 environment by specifying `r-4.0-...` in `runtime.txt`,
36-
where the date provided in `runtime.txt` is old enough for a MRAN snapshot of
37-
CRAN to be used.
38-
3927
### r4.0-rspm
4028

4129
- Test setup of a R 4.0 environment by specifying `r-4.0-...` in `runtime.txt`,

tests/r/r3.6-mran/runtime.txt

Lines changed: 0 additions & 1 deletion
This file was deleted.
File renamed without changes.

tests/r/r3.6-rspm/runtime.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
r-3.6-2018-12-07

tests/r/r3.6-mran/verify renamed to tests/r/r3.6-rspm/verify

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ if (!(version$major == "3" && as.double(version$minor) >= 6 && as.double(version
77
quit("yes", 1)
88
}
99

10-
# Fail if MRAN isn't the configured CRAN mirror
11-
if (!(startsWith(options()$repos["CRAN"], "https://mran.microsoft.com"))) {
10+
# Fail if RSPM isn't the configured CRAN mirror
11+
if (!(startsWith(options()$repos["CRAN"], "https://packagemanager.posit.co"))) {
1212
quit("yes", 1)
1313
}

tests/r/r4.0-mran/install.R

Lines changed: 0 additions & 1 deletion
This file was deleted.

tests/r/r4.0-mran/runtime.txt

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)