Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion posit-bakery/posit_bakery/config/templating/macros/quarto.j2
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,20 @@ 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.

When `home_path` is set, TinyTeX is a shared, root-owned installation. The
TinyTeX bundle points `TEXMFVAR` at the shared `TEXMFSYSVAR`, which other users
cannot write, so LuaLaTeX fails with "no writeable cache path". `TEXMFVAR` is
reset to a per-user directory; the quoted `~` is stored literally in
`texmf.cnf` and expanded by kpathsea from each user's HOME at runtime.
See https://github.com/posit-dev/images-shared/issues/855.

: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.
:param home_path: An optional path to set the HOME environment variable for the command, which controls where TinyTeX is installed. If provided, TEXMFVAR is also set to a per-user directory. 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 %}CI=true {{ quarto_binary }} install tinytex --no-prompt{% if update_path %} --update-path{% endif %}
{%- if home_path %} && "{{ home_path }}"/.TinyTeX/bin/*/tlmgr conf texmf TEXMFVAR '~/.texlive/texmf-var'{% endif %}
{%- endmacro %}

{# Command to install a specific version of Quarto from the Posit Open
Expand Down
12 changes: 6 additions & 6 deletions posit-bakery/test/config/templating/test_macros.py
Original file line number Diff line number Diff line change
Expand Up @@ -2049,13 +2049,13 @@ def test_github_token_secret_mount(self, environment_with_macros):
pytest.param(
False,
"/root",
'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',
'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 && "/root"/.TinyTeX/bin/*/tlmgr conf texmf TEXMFVAR \'~/.texlive/texmf-var\'',
id="with-home-path",
),
pytest.param(
True,
"/root",
'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',
'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 && "/root"/.TinyTeX/bin/*/tlmgr conf texmf TEXMFVAR \'~/.texlive/texmf-var\'',
id="with-home-path-and-update-path",
),
],
Expand Down Expand Up @@ -2149,7 +2149,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" CI=true /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 && "/root"/.TinyTeX/bin/*/tlmgr conf texmf TEXMFVAR '~/.texlive/texmf-var'"""
),
id="with-tinytex-home-path",
),
Expand All @@ -2166,7 +2166,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" CI=true /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 && "/root"/.TinyTeX/bin/*/tlmgr conf texmf TEXMFVAR '~/.texlive/texmf-var'"""
),
id="with-tinytex-home-path-update-path",
),
Expand Down Expand Up @@ -2288,7 +2288,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" CI=true /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 && "/root"/.TinyTeX/bin/*/tlmgr conf texmf TEXMFVAR '~/.texlive/texmf-var'"""
),
id="single-version-with-tinytex-home-path",
),
Expand All @@ -2303,7 +2303,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" CI=true /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 && "/root"/.TinyTeX/bin/*/tlmgr conf texmf TEXMFVAR '~/.texlive/texmf-var'"""
),
id="single-version-with-tinytex-home-path-update-path",
),
Expand Down
Loading