Skip to content

Commit e3d0a9a

Browse files
authored
Merge pull request #1119 from yuvipanda/delete-tmp
Delete /tmp/downloaded_packages after running install.R
2 parents 813d28b + 6ab41ef commit e3d0a9a

File tree

1 file changed

+6
-2
lines changed
  • repo2docker/buildpacks

1 file changed

+6
-2
lines changed

repo2docker/buildpacks/r.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,10 @@ def get_preassemble_scripts(self):
387387
scripts += [
388388
(
389389
"${NB_USER}",
390-
"Rscript %s && touch /tmp/.preassembled || true" % installR_path,
390+
# Delete /tmp/downloaded_packages only if install.R fails, as the second
391+
# invocation of install.R might be able to reuse them
392+
"Rscript %s && touch /tmp/.preassembled || true && rm -rf /tmp/downloaded_packages"
393+
% installR_path,
391394
)
392395
]
393396

@@ -403,7 +406,8 @@ def get_assemble_scripts(self):
403406
(
404407
"${NB_USER}",
405408
# only run install.R if the pre-assembly failed
406-
"if [ ! -f /tmp/.preassembled ]; then Rscript {}; fi".format(
409+
# Delete any downloaded packages in /tmp, as they aren't reused by R
410+
"""if [ ! -f /tmp/.preassembled ]; then Rscript {}; rm -rf /tmp/downloaded_packages; fi""".format(
407411
installR_path
408412
),
409413
)

0 commit comments

Comments
 (0)