Skip to content

refactor: install_tinytex() calls install-bin-unix.sh and install-bin-windows.ps1 directly#495

Draft
Copilot wants to merge 2 commits intomainfrom
copilot/refactor-install-tinytex-function
Draft

refactor: install_tinytex() calls install-bin-unix.sh and install-bin-windows.ps1 directly#495
Copilot wants to merge 2 commits intomainfrom
copilot/refactor-install-tinytex-function

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 27, 2026

Summary

This PR refactors install_tinytex() so that the binary install path delegates to the official installer scripts (install-bin-unix.sh and install-bin-windows.ps1, downloaded from https://tinytex.yihui.org/) instead of re-implementing the same logic in R. The source install path (via install_tinytex_source()) already used install-unx.sh and is unchanged.

Changes

tools/install-bin-unix.sh

  • Added TINYTEX_PREVENT_INSTALL env var check (abort if set to true)
  • Added TINYTEX_TEXDIR env var: lets callers specify the full installation path directly (e.g., the R package passes this for custom dir= installs); falls back to the traditional TINYTEX_DIR-based default. For prebuilt bundles, the extracted archive is renamed to the custom path if needed.
  • Added ./tlmgr conf texmf max_print_line 10000 post-install (matches post_install_config() in R, fixes log line-wrapping — issue Automatically install hyphenation patterns when using polyglossia #322)
  • Fixed $1/--no-path argument conflict: $1 was used to save the installer to an output dir (for build scripts), but R passes --no-path as $1. Now checks that $1 doesn't start with -- before treating it as a save directory.
  • Quoted $(dirname "$TEXDIR") to handle paths with spaces correctly.

tools/install-bin-windows.ps1

  • Added TINYTEX_PREVENT_INSTALL env var check
  • Added --no-path argument support (skips & $tlmgr path add when passed)
  • Added TINYTEX_TEXDIR env var for full-path installs (with move+rename support for custom leaf names)
  • Added & $tlmgr conf texmf max_print_line 10000 post-install
  • Fixed $args[0]/--no-path conflict for the installer save-path feature
  • Removed the double rd $env:TINYTEX_DIR\TinyTeX (now handled cleanly via $TargetDir)

R/install.R

  • Added install_via_script(): downloads and runs the appropriate OS installer script, then does R-specific post-install steps (r_texmf(), repo config, extra_packages). Sets env vars TINYTEX_INSTALLER, TINYTEX_VERSION, and (for custom dirs) TINYTEX_TEXDIR before calling the script.
  • install_tinytex() now routes binary installs through install_via_script() instead of install_prebuilt().
  • install_prebuilt() is kept intact for any direct callers (it is mentioned in NEWS.md as accessible via tinytex:::install_prebuilt()).

Differences handled outside scripts (cannot be eliminated)

The following install_tinytex() behaviors remain in R and are not replicated in the scripts:

Feature Reason
r_texmf() R-specific: registers R's texmf tree with TinyTeX
extra_packages Requires R package discovery (tl_pkgs())
tlgpg installation for HTTPS repos Complex R logic with Windows/macOS check
Repository accessibility check + fallback to CTAN R's tlmgr() integration
Interactive prompts for force / existing LaTeX Requires readline() / interactive()
TEXINPUT env var warning Informational, R-only
version='latest' → GitHub release lookup Requires xfun::github_releases()
Bundle→extra_packages mapping for source installs R-only (source install path unchanged)

@CLAassistant
Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants