question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Set custom default shell

See original GitHub issue

Current usage of action setup-msys2 requires commands to be preprended with msys2do, which is a cmd file (d:\a\_tmp\msys\msys2do.cmd). For example:

  - uses: numworks/setup-msys2@v1
  - run: msys2do makepkg-mingw -sCLfc --noconfirm --noprogressbar

On the one hand, it would be more natural if the shell was selectable as the built-in ones (cmd, powershell, bash), as it would allow a more consistent syntax:

  - uses: numworks/setup-msys2@v1
  - shell: msys2
    run: makepkg-mingw -sCLfc --noconfirm --noprogressbar

On the other hand, such a syntax would hopefully allow to use multi-line run fields, which is not possible ATM (numworks/setup-msys2#8):

  - uses: numworks/setup-msys2@v1
  - shell: msys2
    run: |
      uname -a
      makepkg-mingw -sCLfc --noconfirm --noprogressbar

Apart from that, it’d be useful to have a function in the toolkit core which allows to change the default shell for all the following steps in a job. A possible solution is to allow to set shell at job level (as it is supported for env). However, I think that supporting it in the toolkit would still be useful.

For example, until a month ago, the default shell in windows-latest was cmd. Then, it was changed to powershell: https://github.blog/changelog/2019-10-17-github-actions-default-shell-on-windows-runners-is-changing-to-powershell/. As a result, it is/was necessary to explicitly set shell: cmd in all the steps that won’t work with powershell. This is still the case for workflows where certain tests are to be executed on cmd, powershell and/or bash.


Currently, when run: msys2do is used, either with cmd or powershell, msys2do.cmd is found in the path and it is successfully executed. However, it seems that shell: msys2do {0} does not take the PATH set through the toolkit into account,: ##[error]File not found: 'msys2do'

d:\a\_temp\msys\msys2do.cmd {0} is not supported, either: ##[error]Second path fragment must not be a drive or UNC name. (Parameter 'expression')

Using a relative path (..\_temp\msys\msys2do.cmd {0}), shows that the workdir of the parent script is: ##[error]Could not find a part of the path 'C:\hostedtoolcache\windows\Python\3.6.8\_temp\msys'..

Therefore, it seems that a possible solution is to place a dummy file in C:\hostedtoolcache\windows\Python\3.6.8\x64\msys2.cmd, so that a relative path is used. That file will execute d:\a\_temp\msys\msys2do.cmd, which will itself execute bash. Precisely, the following js snippet works:

    fs.writeFileSync('C:/hostedtoolcache/windows/Python/3.6.8/x64/msys2.cmd', [
      `setlocal`,
      `@echo off`,
      `set "args=%*"`,
      `set "args=%args:\\=/%"`,
      cmd + ` %args%`
    ].join('\r\n'));
  - shell: ./msys2.cmd {0}
    run: |
      pacman -Syu --noconfirm
      uname -a

Nonetheless, it feels hackish, specially because of the hardcoded location of msys2.cmd.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:5
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
dakalecommented, Dec 19, 2019

I just made this change in https://github.com/actions/runner/pull/231

(We just open sourced the runner, so transferring this issue there)

This will go out with the 2.164.0 runner which is currently in prerelease but not rolled out to GitHub hosted machines

See: releases https://github.com/actions/runner/releases

You can download the prerelease package if you want to run it self-hosted to test

1reaction
dakalecommented, Jan 21, 2020

@eine Feel free to open an issue in https://github.com/actions/toolkit so we can discuss it, but my gut is that it will need to be preceded by some additional conversation about the product in general, because we likely would want some formalized concept of run or job level defaults or configuration first, followed by expressing those values in .yaml, finally adding a way to dynamically mutate them at runtime (the toolkit function you propose)

So imo the toolkit doesnt feel like the best place to begin that discussion, but I am also not sure what would be better so we can start there and move it around as necessary

Read more comments on GitHub >

github_iconTop Results From Across the Web

3 Ways to Change a Users Default Shell in Linux
3 Ways to Change a Users Default Shell in Linux · 1. usermod Utility · 2. chsh Utility · 3. Change User Shell...
Read more >
Making zsh default shell without root access
You can set zsh as your default shell in the terminal preferences (create a new profile). – lmaooooo. Dec 14, 2017 at 13:42....
Read more >
How do you change the default shell for ALL USERS to ...
I know that to change your own shell to bash, you would use the command "chsh -s /bin/bash", but how do I automatically...
Read more >
Changing default shell in Linux - bash
The detailed command is chsh -s /bin/bash . It will prompt you to enter your password. Your default login shell is /bin/bash now....
Read more >
Shell Launcher
You can use Shell Launcher to replace the default Windows 10 shell with a custom shell. You can use almost any application or...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found