Help
cancel
Showing results for 
Search instead for 
Did you mean: 
Pilot Lvl 1
Message 1 of 11

Windows - multi-line step run:

Recently a repo I work with ran the following step:

 

- name: bundle install
run: |
gem update --system --no-document --conservative
bundle install --jobs 4 --retry 3

The step ran both lines of script in Ubuntu & macOS, but only the first line ran in Windows.

 

See starter-workflows/ci/ruby.yml

10 Replies
Highlighted
GitHub Staff
Message 2 of 11

Re: Windows - multi-line step run:

Hi there MSP-Greg,

 

That's interesting behavior to report! That's not expected and while we're not sure why that is -- we've forwarded this internally for our Actions engineers to review further.

Highlighted
Copilot Lvl 3
Message 3 of 11

Re: Windows - multi-line step run:

I can also confirm that I've run into the issue with the following step:

    - name: Package
      run: |
        mkdir build/package
        node ./ci/packager.js


It only executed the mkdir part and not the node.js script. The node.js script is to work around another issue in which parameters starting with / or containing . are treated as options to powershell.

 

Edit: For the time being, I've simply moved the mkdir into the packager script.

Highlighted
GitHub Staff
Message 4 of 11

Re: Windows - multi-line step run:

@MSP-Greg 

 

Can you try the following on Windows and see if that gets past the issue?  

 

- name: bundle install
run: |
call gem update --system --no-document --conservative
bundle install --jobs 4 --retry 3
Highlighted
Pilot Lvl 1
Message 5 of 11

Re: Windows - multi-line step run:

Adding `shell: powershell` fixed Windows for me, however it breaks ubuntu with `##[error]File not found: 'powershell'`

 

https://github.com/DanTup/github-actions-multiline-issue/runs/226399500

Highlighted
GitHub Staff
Message 6 of 11

Re: Windows - multi-line step run:

You can use `shell: pwsh` on all platforms.  (That's the cross-platform PowerShell Core.  Using `shell: powershell` will give you the older Windows-only PowerShell.)

Highlighted
Pilot Lvl 1
Message 7 of 11

Re: Windows - multi-line step run:

I'll give that a go. Is there any way to set the default shell to avoid having to do this in each step?

 

Also - is this original issue a bug that will be fixed? It seems strange, even if using the original command shell.

 

Edit: pwsh seems to work as a workaround :-)

Highlighted
Copilot Lvl 2
Message 8 of 11

Re: Windows - multi-line step run:

Using CALL solved a similiar problem for me. Thanks @chrispat !

Highlighted
Pilot Lvl 1
Message 9 of 11

Re: Windows - multi-line step run:

With the recent change from 'cmd' to 'PowerShell' as the default Windows script engine/runner, no longer having any problems.

 

A few multi-line scripts are running fine cross-platform, and multi-line PowerShell scripts are running fine in Windows.

 

I'd like to close this, but accepting my own post as a solution seems odd...

Highlighted
Pilot Lvl 1
Message 10 of 11

Re: Windows - multi-line step run:


@MSP-Greg wrote:

With the recent change from 'cmd' to 'PowerShell' as the default Windows script engine/runner, no longer having any problems.

 

I didn't realise this had changed - seems like a great change - however I think it may have introduced a nasty issue when there are failures in multiline steps on Windows, see:

 

https://github.community/t5/GitHub-Actions/Multiline-commands-on-Windows-do-not-fail-if-individual-c...