set USER root after each directive block
matches expectations in the directive sequences
not strictly required after preassemble because we have no root steps between preassemble and assemble,
so we could remove the `last_user = "root"` there instead
includes regression test
MODIFY
repo2docker/buildpacks/base.py
repo2docker/buildpacks/base.py
@@ -100,6 +100,8 @@ COPY --chown={{ user }}:{{ user }} {{ src }} {{ dst }}
{% for sd in build_script_directives -%}
{{ sd }}
{% endfor %}
+# ensure root user after build scripts
+USER root
# Allow target path repo is cloned to be configurable
ARG REPO_DIR=${HOME}
@@ -138,6 +140,8 @@ COPY --chown={{ user }}:{{ user }} src/{{ src }} ${REPO_DIR}/{{ dst }}
{% for sd in preassemble_script_directives -%}
{{ sd }}
{% endfor %}
+# ensure root user after preassemble scripts
+USER root
# Copy stuff.
COPY --chown={{ user }}:{{ user }} src/ ${REPO_DIR}

ADD
tests/r/apt/apt.txt
+libsodium-dev

ADD
tests/r/apt/install.R
+install.packages("viridisLite")

ADD
tests/r/apt/runtime.txt
+r-4.1-2021-10-22

ADD
tests/r/apt/verify
+#!/usr/bin/env bash
+set -euo pipefail
+apt list
+apt list | grep libsodium-dev
+# make sure we got R
+which R

set USER root after each directive block

matches expectations in the directive sequences

not strictly required after preassemble because we have no root steps between preassemble and assemble,
so we could remove the `last_user = "root"` there instead

includes regression test