From 546ca0d3876eeb2630b35c81c892b63531b1d5a1 Mon Sep 17 00:00:00 2001 From: "Benjamin R. J. Schwedler" Date: Thu, 18 Jun 2026 12:50:21 -0500 Subject: [PATCH] Set CI=true for Quarto TinyTeX install command MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Quarto renders an animated TinyTeX download progress bar unless its `runningInCI()` check passes. That check only reads environment variables (CI, GITHUB_ACTIONS, etc.), none of which propagate into a `docker build` RUN step, so inside container builds Quarto thinks it is interactive and redraws the progress bar on every download tick. Written to a non-TTY build log, each redraw becomes a separate line — a single observed build emitted ~26k of them, ~5MB of redundant output that slows the build and bloats CI logs. Set `CI=true` inline on the install command so `runningInCI()` passes and Quarto collapses the progress bar to one line. Unlike re-adding `--quiet` (removed so install errors stay visible), this keeps all error output. The variable is scoped to the command and does not leak into the built image. --- .../config/templating/macros/quarto.j2 | 9 ++++++- .../test/config/templating/test_macros.py | 26 +++++++++---------- posit-bakery/test/config/test_config.py | 2 +- .../matrix/Containerfile.ubuntu2404 | 2 +- .../1.0.0/Containerfile.ubuntu2204.std | 2 +- 5 files changed, 24 insertions(+), 17 deletions(-) diff --git a/posit-bakery/posit_bakery/config/templating/macros/quarto.j2 b/posit-bakery/posit_bakery/config/templating/macros/quarto.j2 index 669574ef8..00c2af96e 100644 --- a/posit-bakery/posit_bakery/config/templating/macros/quarto.j2 +++ b/posit-bakery/posit_bakery/config/templating/macros/quarto.j2 @@ -48,12 +48,19 @@ backward compatibility but is ignored. {# Command to install TinyTeX using the Quarto CLI +`CI=true` is set inline so Quarto's `runningInCI()` check passes inside +container builds. When it passes, Quarto collapses its TinyTeX download +progress bar to a single line; otherwise it renders an animated progress bar +that, written to a non-TTY build log, emits tens of thousands of redundant +lines (one per download tick). The variable is scoped to this command only, so +it does not leak into the built image. + :param quarto_binary: The path to the Quarto binary. :param update_path: Adds --update-path to the command to add TinyTeX binaries to the PATH. Defaults to False. :param home_path: An optional path to set the HOME environment variable for the command, which controls where TinyTeX is installed. If not provided, TinyTeX will be installed to the default location under the current user's home directory. #} {% macro install_tinytex_command(quarto_binary, update_path = False, home_path = None) -%} -GH_TOKEN="$([ -s /run/secrets/github_token ] && cat /run/secrets/github_token)" {% if home_path %}HOME="{{ home_path }}" {% endif %}{{ quarto_binary }} install tinytex --no-prompt{% if update_path %} --update-path{% endif %} +GH_TOKEN="$([ -s /run/secrets/github_token ] && cat /run/secrets/github_token)" {% if home_path %}HOME="{{ home_path }}" {% endif %}CI=true {{ quarto_binary }} install tinytex --no-prompt{% if update_path %} --update-path{% endif %} {%- endmacro %} {# Command to install a specific version of Quarto from the Posit Open diff --git a/posit-bakery/test/config/templating/test_macros.py b/posit-bakery/test/config/templating/test_macros.py index ce71d07c5..e3d1f801f 100644 --- a/posit-bakery/test/config/templating/test_macros.py +++ b/posit-bakery/test/config/templating/test_macros.py @@ -1940,25 +1940,25 @@ def test_github_token_secret_mount(self, environment_with_macros): pytest.param( True, None, - 'GH_TOKEN="$([ -s /run/secrets/github_token ] && cat /run/secrets/github_token)" /opt/quarto/1.8.24/bin/quarto install tinytex --no-prompt --update-path', + 'GH_TOKEN="$([ -s /run/secrets/github_token ] && cat /run/secrets/github_token)" CI=true /opt/quarto/1.8.24/bin/quarto install tinytex --no-prompt --update-path', id="with-update-path", ), pytest.param( False, None, - 'GH_TOKEN="$([ -s /run/secrets/github_token ] && cat /run/secrets/github_token)" /opt/quarto/1.8.24/bin/quarto install tinytex --no-prompt', + 'GH_TOKEN="$([ -s /run/secrets/github_token ] && cat /run/secrets/github_token)" CI=true /opt/quarto/1.8.24/bin/quarto install tinytex --no-prompt', id="without-update-path", ), pytest.param( False, "/root", - 'GH_TOKEN="$([ -s /run/secrets/github_token ] && cat /run/secrets/github_token)" HOME="/root" /opt/quarto/1.8.24/bin/quarto install tinytex --no-prompt', + 'GH_TOKEN="$([ -s /run/secrets/github_token ] && cat /run/secrets/github_token)" HOME="/root" CI=true /opt/quarto/1.8.24/bin/quarto install tinytex --no-prompt', id="with-home-path", ), pytest.param( True, "/root", - 'GH_TOKEN="$([ -s /run/secrets/github_token ] && cat /run/secrets/github_token)" HOME="/root" /opt/quarto/1.8.24/bin/quarto install tinytex --no-prompt --update-path', + 'GH_TOKEN="$([ -s /run/secrets/github_token ] && cat /run/secrets/github_token)" HOME="/root" CI=true /opt/quarto/1.8.24/bin/quarto install tinytex --no-prompt --update-path', id="with-home-path-and-update-path", ), ], @@ -2018,7 +2018,7 @@ def test_install_tinytex_command(self, environment_with_macros, update_path, hom apt-mark hold quarto && \\ apt-get clean -yqq && \\ rm -rf /var/lib/apt/lists/* && \\ - GH_TOKEN="$([ -s /run/secrets/github_token ] && cat /run/secrets/github_token)" /opt/quarto/bin/quarto install tinytex --no-prompt""" + GH_TOKEN="$([ -s /run/secrets/github_token ] && cat /run/secrets/github_token)" CI=true /opt/quarto/bin/quarto install tinytex --no-prompt""" ), id="with-tinytex", ), @@ -2035,7 +2035,7 @@ def test_install_tinytex_command(self, environment_with_macros, update_path, hom apt-mark hold quarto && \\ apt-get clean -yqq && \\ rm -rf /var/lib/apt/lists/* && \\ - GH_TOKEN="$([ -s /run/secrets/github_token ] && cat /run/secrets/github_token)" /opt/quarto/bin/quarto install tinytex --no-prompt --update-path""" + GH_TOKEN="$([ -s /run/secrets/github_token ] && cat /run/secrets/github_token)" CI=true /opt/quarto/bin/quarto install tinytex --no-prompt --update-path""" ), id="with-tinytex-update-path", ), @@ -2052,7 +2052,7 @@ def test_install_tinytex_command(self, environment_with_macros, update_path, hom apt-mark hold quarto && \\ apt-get clean -yqq && \\ rm -rf /var/lib/apt/lists/* && \\ - GH_TOKEN="$([ -s /run/secrets/github_token ] && cat /run/secrets/github_token)" HOME="/root" /opt/quarto/bin/quarto install tinytex --no-prompt""" + GH_TOKEN="$([ -s /run/secrets/github_token ] && cat /run/secrets/github_token)" HOME="/root" CI=true /opt/quarto/bin/quarto install tinytex --no-prompt""" ), id="with-tinytex-home-path", ), @@ -2069,7 +2069,7 @@ def test_install_tinytex_command(self, environment_with_macros, update_path, hom apt-mark hold quarto && \\ apt-get clean -yqq && \\ rm -rf /var/lib/apt/lists/* && \\ - GH_TOKEN="$([ -s /run/secrets/github_token ] && cat /run/secrets/github_token)" HOME="/root" /opt/quarto/bin/quarto install tinytex --no-prompt --update-path""" + GH_TOKEN="$([ -s /run/secrets/github_token ] && cat /run/secrets/github_token)" HOME="/root" CI=true /opt/quarto/bin/quarto install tinytex --no-prompt --update-path""" ), id="with-tinytex-home-path-update-path", ), @@ -2122,7 +2122,7 @@ def test_install_rhel_with_tinytex(self, environment_with_macros): xz && \\ dnf versionlock add quarto && \\ dnf clean all -yq && \\ - GH_TOKEN="$([ -s /run/secrets/github_token ] && cat /run/secrets/github_token)" /opt/quarto/bin/quarto install tinytex --no-prompt""" + GH_TOKEN="$([ -s /run/secrets/github_token ] && cat /run/secrets/github_token)" CI=true /opt/quarto/bin/quarto install tinytex --no-prompt""" ) rendered = environment_with_macros.from_string(template).render() assert rendered == expected @@ -2163,7 +2163,7 @@ def test_install_rejects_invalid_os_family(self, environment_with_macros): apt-mark hold quarto && \\ apt-get clean -yqq && \\ rm -rf /var/lib/apt/lists/* && \\ - GH_TOKEN="$([ -s /run/secrets/github_token ] && cat /run/secrets/github_token)" /opt/quarto/bin/quarto install tinytex --no-prompt""" + GH_TOKEN="$([ -s /run/secrets/github_token ] && cat /run/secrets/github_token)" CI=true /opt/quarto/bin/quarto install tinytex --no-prompt""" ), id="single-version-with-tinytex", ), @@ -2178,7 +2178,7 @@ def test_install_rejects_invalid_os_family(self, environment_with_macros): apt-mark hold quarto && \\ apt-get clean -yqq && \\ rm -rf /var/lib/apt/lists/* && \\ - GH_TOKEN="$([ -s /run/secrets/github_token ] && cat /run/secrets/github_token)" /opt/quarto/bin/quarto install tinytex --no-prompt --update-path""" + GH_TOKEN="$([ -s /run/secrets/github_token ] && cat /run/secrets/github_token)" CI=true /opt/quarto/bin/quarto install tinytex --no-prompt --update-path""" ), id="single-version-with-tinytex-update-path", ), @@ -2193,7 +2193,7 @@ def test_install_rejects_invalid_os_family(self, environment_with_macros): apt-mark hold quarto && \\ apt-get clean -yqq && \\ rm -rf /var/lib/apt/lists/* && \\ - GH_TOKEN="$([ -s /run/secrets/github_token ] && cat /run/secrets/github_token)" HOME="/root" /opt/quarto/bin/quarto install tinytex --no-prompt""" + GH_TOKEN="$([ -s /run/secrets/github_token ] && cat /run/secrets/github_token)" HOME="/root" CI=true /opt/quarto/bin/quarto install tinytex --no-prompt""" ), id="single-version-with-tinytex-home-path", ), @@ -2208,7 +2208,7 @@ def test_install_rejects_invalid_os_family(self, environment_with_macros): apt-mark hold quarto && \\ apt-get clean -yqq && \\ rm -rf /var/lib/apt/lists/* && \\ - GH_TOKEN="$([ -s /run/secrets/github_token ] && cat /run/secrets/github_token)" HOME="/root" /opt/quarto/bin/quarto install tinytex --no-prompt --update-path""" + GH_TOKEN="$([ -s /run/secrets/github_token ] && cat /run/secrets/github_token)" HOME="/root" CI=true /opt/quarto/bin/quarto install tinytex --no-prompt --update-path""" ), id="single-version-with-tinytex-home-path-update-path", ), diff --git a/posit-bakery/test/config/test_config.py b/posit-bakery/test/config/test_config.py index e0553c915..5d2375bab 100644 --- a/posit-bakery/test/config/test_config.py +++ b/posit-bakery/test/config/test_config.py @@ -1406,7 +1406,7 @@ def test_patch_version_with_dependencies_macros(self, get_tmpcontext): apt-mark hold quarto && \\ apt-get clean -yqq && \\ rm -rf /var/lib/apt/lists/* && \\ - GH_TOKEN="$([ -s /run/secrets/github_token ] && cat /run/secrets/github_token)" /opt/quarto/bin/quarto install tinytex --no-prompt + GH_TOKEN="$([ -s /run/secrets/github_token ] && cat /run/secrets/github_token)" CI=true /opt/quarto/bin/quarto install tinytex --no-prompt """) assert ( expected_std_containerfile diff --git a/posit-bakery/test/resources/matrix/test-matrix/matrix/Containerfile.ubuntu2404 b/posit-bakery/test/resources/matrix/test-matrix/matrix/Containerfile.ubuntu2404 index 7637e6b65..816ce6d4d 100644 --- a/posit-bakery/test/resources/matrix/test-matrix/matrix/Containerfile.ubuntu2404 +++ b/posit-bakery/test/resources/matrix/test-matrix/matrix/Containerfile.ubuntu2404 @@ -57,4 +57,4 @@ RUN --mount=type=secret,id=github_token,required=false bash -c "$(curl -1fsSL 'h apt-mark hold quarto && \ apt-get clean -yqq && \ rm -rf /var/lib/apt/lists/* && \ - GH_TOKEN="$([ -s /run/secrets/github_token ] && cat /run/secrets/github_token)" /opt/quarto/bin/quarto install tinytex --no-prompt + GH_TOKEN="$([ -s /run/secrets/github_token ] && cat /run/secrets/github_token)" CI=true /opt/quarto/bin/quarto install tinytex --no-prompt diff --git a/posit-bakery/test/resources/with-macros/test-image/1.0.0/Containerfile.ubuntu2204.std b/posit-bakery/test/resources/with-macros/test-image/1.0.0/Containerfile.ubuntu2204.std index 25d0f5817..b205ad7ca 100644 --- a/posit-bakery/test/resources/with-macros/test-image/1.0.0/Containerfile.ubuntu2204.std +++ b/posit-bakery/test/resources/with-macros/test-image/1.0.0/Containerfile.ubuntu2204.std @@ -59,4 +59,4 @@ RUN --mount=type=secret,id=github_token,required=false bash -c "$(curl -1fsSL 'h apt-mark hold quarto && \ apt-get clean -yqq && \ rm -rf /var/lib/apt/lists/* && \ - GH_TOKEN="$([ -s /run/secrets/github_token ] && cat /run/secrets/github_token)" /opt/quarto/bin/quarto install tinytex --no-prompt + GH_TOKEN="$([ -s /run/secrets/github_token ] && cat /run/secrets/github_token)" CI=true /opt/quarto/bin/quarto install tinytex --no-prompt