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

Windows: tlmgr: command not found #671

Closed
bschilder opened this issue Dec 18, 2022 · 17 comments
Closed

Windows: tlmgr: command not found #671

bschilder opened this issue Dec 18, 2022 · 17 comments

Comments

@bschilder
Copy link

Describe the bug

Following the instructions here do not seem to work on Windows. I don't see any notes on Windows behaving any differently either.
https://github.com/r-lib/actions/tree/v2-branch/setup-tinytex#ctan-packages

See GHA report here:
https://github.com/neurogenomics/rworkflows/actions/runs/3725655507/jobs/6318599061#step:2:502

To Reproduce

Run the example code given in the documentation within any GHA workflow that uses the windows-latest runner.

steps:
  - uses: actions/checkout@v3
  - uses: r-lib/actions/setup-tinytex@v2
  - run: tlmgr --version

  - name: Install additional LaTeX packages
    run: |
      tlmgr install titlesec
      tlmgr list --only-installed

Expected behavior

Instructions should work on all major platforms.

Additional context

Originally identified here #670

Thanks,
Brian

@bschilder bschilder added the bug an unexpected problem or unintended behavior label Dec 18, 2022
@gaborcsardi
Copy link
Member

See GHA report here:

That workflow does not use the setup-tinytex action at all.

Here is a working example:
https://github.com/r-lib/actions/actions/runs/3726614443/jobs/6320179744

@gaborcsardi gaborcsardi removed the bug an unexpected problem or unintended behavior label Dec 18, 2022
@bschilder
Copy link
Author

Hi @gaborcsardi, I'm afraid you may be mistaken. It does indeed use the setup-tinytex action, albeit via the rworkflows action.
Please see here:
https://github.com/neurogenomics/rworkflows/blob/master/action.yml#L183

Could you please reopen this until we can both confirm it's resolved?

Thanks,
Brian

@gaborcsardi gaborcsardi reopened this Dec 19, 2022
@gaborcsardi
Copy link
Member

I can't reproduce this without extra actions, so if you had a an example build where it fails, that would be great. Thanks!

@bschilder
Copy link
Author

@bschilder
Copy link
Author

@gaborcsardi
Copy link
Member

Works if I run it in the default shell, instead of bash: https://github.com/gaborcsardi/rworkflows/actions/runs/3733006773

@bschilder
Copy link
Author

I see, interesting!

Actions requires that I provide the interpreter, but if I can figure out to to explicitly define whatever the default is, it will hopefully work. Let me give that a go and I'll let you know what happens.

@bschilder
Copy link
Author

bschilder commented Dec 19, 2022

Ok, so here's what I've learned:

Trying different shells

pwsh

pwsh is supposedly the default shell for Windows on GHA (according to the official GitHub documentation), and yet it does not seem to work.

You'll notice in your workflow that the following warning occurs in the r-lib/actions/setup-tinytex@v2 step:

D:\a\rworkflows\rworkflows>where /q powershell   || echo powershell not found   && exit /b 

https://github.com/gaborcsardi/rworkflows/actions/runs/3733006773/jobs/6333212360#step:3:8

Yet, in this case it's somehow able to recover and complete the step (seemingly successfully).
The next step with tlmgr install bera also seems to run fine (without specifying the shell).

However, when you specify pwsh as the shell explicitly in the next step, it fails:

    - name: Install additional LaTeX packages (Windows)
      if: inputs.runner_os == 'Windows'
      run: |
        tlmgr install bera
        tlmgr list --only-installed
      shell: pwsh {0}

https://github.com/neurogenomics/rworkflows/actions/runs/3733195840/jobs/6333659645#step:4:26

cmd

I also tried out using cmd. This only works for Windows, so I added a conditional step here:

- name: Install additional LaTeX packages (non-Windows)
      if: inputs.runner_os != 'Windows'
      run: |
        tlmgr install bera
        tlmgr list --only-installed
      shell: bash {0} 
      
    - name: Install additional LaTeX packages (Windows)
      if: inputs.runner_os == 'Windows'
      run: |
        tlmgr install bera
        tlmgr list --only-installed
      shell: cmd {0} 

This seems to work!
https://github.com/neurogenomics/rworkflows/actions/runs/3733419412/jobs/6334189325

Summary

Taken together, it doesn't really seem like pwsh is actually the default shell for Windows on GHA. So either there's some extra shell interpreter handling that occurs when you leave the defaults (as you did), and not when you specify the shell (as I did with pwsh), or the GitHub Actions documentation is out of date.

Either way, I think this solution should work. It would probably be worth added a note about this behaviour in the setup-tinytex documentation, as it's likely to come up again for anyone trying to use this action when creating other actions (which again require you to be explicit about shell interpreters)
https://github.com/r-lib/actions/tree/v2-branch/setup-tinytex#ctan-packages

@gaborcsardi
Copy link
Member

bash does not work, otoh, which is not surprising, as it has a PATH that is separate from the system path: https://github.com/gaborcsardi/rworkflows/actions/runs/3733745463/workflow

So you'd need to add tlmgr to the (Git) bash path as well to make it work.

@bschilder
Copy link
Author

bschilder commented Dec 19, 2022

bash does not work, otoh, which is not surprising, as it has a PATH that is separate from the system path: https://github.com/gaborcsardi/rworkflows/actions/runs/3733745463/workflow

So you'd need to add tlmgr to the (Git) bash path as well to make it work.

I thought that was the purpose of setup-tinytex? Should it not make it available to all relevant paths? Or at least the default shell paths (e.g. bash, pwsh).

@gaborcsardi
Copy link
Member

We call the GitHub Action API to set the PATH, I think that's the right thing to do:

@bschilder
Copy link
Author

bschilder commented Dec 19, 2022

We call the GitHub Action API to set the PATH, I think that's the right thing to do:

ok, but it still stands that pwsh is unable to find tlmgr. So if this strategy isn't sufficient to make tlmgr usable by pwsh (without additional troubleshooting to export the path in another step), shouldn't something be added to the action to make it so? sorry if im missing something here

@gaborcsardi
Copy link
Member

ok, but it still stands that pwsh is unable to find tlmgr

No, it works with pwsh, see above: #671 (comment)

@bschilder
Copy link
Author

bschilder commented Dec 19, 2022

I see, so comparing our workflows, it seems omitting {0} in pwsh {0} makes a difference (the latter fails in my case).

Not sure I fully understand what this syntax means, but I think it might be specifying a different shell than the one that setup-tinytex

https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#exit-codes-and-error-action-preference

Thanks for clarifying!

@bschilder
Copy link
Author

I think this can be safely closed @gaborcsardi . I'll leave it up to you whether you'd like to add a note about shells in the documentation.

Thanks for all your help!

@github-actions
Copy link

github-actions bot commented Jan 4, 2023

This issue has been automatically locked. If you believe you have found a related problem, please file a new issue and include a link to this issue

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 4, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants