Virtual-environments: Ubuntu 20 Powershell execution permission bug

Created on 13 Nov 2020  Â·  6Comments  Â·  Source: actions/virtual-environments

Description
Powershell script execution is not working in Ubuntu 20.04 environment:

Run .\scripts\test.ps1
mkdir: cannot create directory ‘/run/user/1001’: Permission denied
checking

Virtual environments affected

  • [ ] Ubuntu 16.04
  • [ ] Ubuntu 18.04
  • [x] Ubuntu 20.04
  • [ ] macOS 10.15
  • [ ] macOS 11.0
  • [ ] Windows Server 2016 R2
  • [ ] Windows Server 2019

Expected behavior
Powershell script should be run and executed without problems

Actual behavior
Script is not executed and will terminate to an error: mkdir: cannot create directory ‘/run/user/1001’: Permission denied

Repro steps

  1. Create a Powershell script in repo
  2. Try to run the Powershell script from GitHub actions in pwsh shell

Example

runs-on: ubuntu-20.04
    steps:
      - uses: actions/checkout@v2
      - name: Run Powershell
        shell: pwsh
        run: ./scripts/test.ps1
Ubuntu

All 6 comments

Hello, @Satak
The bug was fixed in scope of this https://github.com/actions/virtual-environments/pull/2053 PR.

Temporary workaround:

-name : update pwsh
 run: |
    sudo apt-get update
    sudo snap remove powershell
    sudo apt-get install powershell

Workaround doesn't help:

Run .\scripts\test.ps1
test.ps1: /home/runner/work/_temp/679f6144-4c8c-4643-82d3-6a7ed6fe1e95.ps1:2
Line |
   2 |  .\scripts\test.ps1
     |  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     | You cannot call a method on a null-valued expression.

Error: Process completed with exit code 1.

@Satakm, you should call with pwsh:
pwsh -f .\scripts\test.ps1

Looks like the .\scripts\test.ps1 script contains errors.

You are right. Had problem in the script also which fixed this. Script works either with shell: pwsh or bash shell with pwsh -f ./scripts/test.ps1

Hello, @Satak
Has this issue been fixed ?
Can we close this ticket ?

Yes working now!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ethomson picture ethomson  Â·  4Comments

adamsiembida picture adamsiembida  Â·  3Comments

orj picture orj  Â·  4Comments

motss picture motss  Â·  3Comments

raulpopadineti picture raulpopadineti  Â·  3Comments