tinytex icon indicating copy to clipboard operation
tinytex copied to clipboard

Feature request: provide `.ps1` install script for Windows

Open ducaale opened this issue 3 years ago • 3 comments

TinyTeX currently provides the Windows installer as a batch file which requires more steps to use than its Linux/macOS counterpart. It would be nice if there was a powershell version that could be downloaded and executed in a single command, e.g iwr -useb https://deno.land/install.ps1 | iex.

For context, I would like to add one-liner instructions for how to install TinyTeX in https://github.com/saadq/resumake.io

# Shell (Mac, Linux)
$ curl -sL https://yihui.org/tinytex/install-bin-unix.sh | sh

# PowerShell (Windows)
$ iwr -useb https://yihui.org/tinytex/install-bin-windows.ps1 | iex

By filing an issue to this repo, I promise that

  • [x] I have fully read the issue guide at https://yihui.org/issue/.
  • [x] I have provided the necessary information about my issue.
    • If I'm asking a question, I have already asked it on Stack Overflow or RStudio Community, waited for at least 24 hours, and included a link to my question there.
    • If I'm filing a bug report, I have included a minimal, self-contained, and reproducible example, and have also included xfun::session_info('tinytex'). I have upgraded all my packages to their latest versions (e.g., R, RStudio, and R packages), and also tried the development version: remotes::install_github('rstudio/tinytex').
    • If I have posted the same issue elsewhere, I have also mentioned it in this issue.
  • [x] I have learned the Github Markdown syntax, and formatted my issue correctly.

I understand that my issue may be closed if I don't fulfill my promises.

ducaale avatar Aug 21 '22 11:08 ducaale

Hi,

For reference, know that there are several ways to install TinyTeX on Windows:

  • Using choco install tinytex from Chocolatey community repo
  • Using scoop install tinytex from https://github.com/cderv/r-bucket#tinytex---tex-live-distribution
  • Using quarto install tool tinytex for Quarto user (https://quarto.org/)
  • Downloading and unzipping from the release page of https://github.com/rstudio/tinytex-releases/

Making a powershell script for installation would mean doing the 4th solution. I can see if we can convert the script to powershell. .bat is used because it works on more Windows version (historically) and it is easy enough to run from powershell too. The script is also there since a long time and properly tested through time as used in some other project out there.

If you already have done such script for powershell, please do share. Thank you !

cderv avatar Aug 21 '22 13:08 cderv

Thanks, I have the following script based on https://deno.land/x/[email protected]/install.ps1?code=

#!/usr/bin/env pwsh

$ErrorActionPreference = 'Stop'

if (Get-Command "tlmgr" -ErrorAction SilentlyContinue) {
  $InstalledPkgs = tlmgr info --list --only-installed --data name
  if ($InstalledPkgs) {
    $InstalledPkgs = $InstalledPkgs -replace ("`n", " ")
    Write-Output "If you want to reinstall currently installed packages, use this command after the TinyTeX installation is done:"
    Write-Output ""
    Write-Output "tlmgr install ${InstalledPkgs}`n"
  }
}

$Version = $env:TINYTEX_VERSION
$Installer = if ($env:TINYTEX_INSTALLER) {
  $env:TINYTEX_INSTALLER
} else {
  "TinyTeX-1"
}

$DestDir = $env:APPDATA
$TinyTeXZip = "$env:TEMP\TinyTeX.zip"

# GitHub requires TLS 1.2
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12

$TinyTeXUri = if (!$Version) {
  "https://github.com/rstudio/tinytex-releases/releases/download/daily/${Installer}.zip"
} else {
  "https://github.com/rstudio/tinytex-releases/releases/download/v${Version}/${Installer}-v${Version}.zip"
}

curl.exe -Lo $TinyTeXZip $TinyTeXUri
Expand-Archive -Force -Path $TinyTeXZip -DestinationPath $DestDir
Remove-Item $TinyTeXZip

Write-Output "add tlmgr to PATH"

$Tlmgr = "${DestDir}\TinyTeX\bin\win32\tlmgr.bat"
Invoke-Expression "${Tlmgr} path add"
if (!$env:CI) {
  Invoke-Expression "${Tlmgr} option repository ctan"
}
# GH issue #313
Invoke-Expression "${Tlmgr} postaction install script xetex"

ducaale avatar Aug 21 '22 15:08 ducaale

Awesome thank you !

cderv avatar Aug 21 '22 15:08 cderv