Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request: provide .ps1 install script for Windows #381

Open
3 tasks done
ducaale opened this issue Aug 21, 2022 · 3 comments
Open
3 tasks done

Feature request: provide .ps1 install script for Windows #381

ducaale opened this issue Aug 21, 2022 · 3 comments

Comments

@ducaale
Copy link

ducaale commented Aug 21, 2022

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

  • I have fully read the issue guide at https://yihui.org/issue/.
  • 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.
  • 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 ducaale changed the title Feature request: provide .ps1 install script for windows Feature request: provide .ps1 install script for Windows Aug 21, 2022
@cderv
Copy link
Contributor

cderv commented Aug 21, 2022

Hi,

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

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 !

@ducaale
Copy link
Author

ducaale commented Aug 21, 2022

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"

@cderv
Copy link
Contributor

cderv commented Aug 21, 2022

Awesome thank you !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Backlog
Development

No branches or pull requests

2 participants