bug: PowerShell refuses to execute the generated script files #910

Closed
opened 2025-08-23 12:41:13 +00:00 by AnsisMalins · 5 comments

Can you reproduce the bug on the Forgejo test instance?

No

Description

Windows PowerShell refuses to execute scripts whose file names do not end with .ps1. The Forgejo runner creates run script files with no extension at all. An impasse.

I would fix this by allowing the name of the generated script file to be configurable somehow.

The workaround I've found is to use this as your shell:
powershell -Command "$a = '{0}'; $b = $a + '.ps1'; Rename-Item -Path $a -NewName $b; . $b"

The issue was encountered when trying to set up the Windows port of the Forgejo runner to run in host mode on a bare metal Windows machine and execute build scripts written for PowerShell 5.1.

Forgejo Version

12.0.1

Runner Version

6.3.1

How are you running Forgejo?

I downloaded the Forgejo binary from your website and followed the Installation from Binary instructions. The only deviations from these instructions is that I have configured it to keep all its data in a mounted volume instead of /var/lib and that I have disabled LFS support.

How are you running the Runner?

I downloaded a Windows binary from Github and configured it to run in host mode and with debug level set to trace. I then launch it myself from Windows command prompt and test it. Once it is all working I intend to create a user for it and run it as a service using WinSW.

Logs

time="2025-08-23T14:39:24+02:00" level=trace msg="Processing -File 'D:/Overmare/workspace/ca684af5e7ebaad1/act/workflow/0' failed because the file does not have a '.ps1' extension. Specify a valid Windows PowerShell script file name, and then try again.\r\n" dryrun=false job=/test1 jobID=test1 matrix="map[]" raw_output=true stage=Main step="Do stuff" stepID="[0]" stepNumber=0
| Processing -File 'D:/Overmare/workspace/ca684af5e7ebaad1/act/workflow/0' failed because the file does not have a '.ps1' extension. Specify a valid Windows PowerShell script file name, and then try again.

Workflow file

on:
  workflow_dispatch:
jobs:
  test1:
    runs-on: windows
    defaults:
      run:
        shell: powershell -File {0}
    steps:
      - name: Do stuff
        run: echo Hello World
### Can you reproduce the bug on the Forgejo test instance? No ### Description Windows PowerShell refuses to execute scripts whose file names do not end with `.ps1`. The Forgejo runner creates `run` script files with no extension at all. An impasse. I would fix this by allowing the name of the generated script file to be configurable somehow. The workaround I've found is to use this as your `shell`: `powershell -Command "$a = '{0}'; $b = $a + '.ps1'; Rename-Item -Path $a -NewName $b; . $b"` The issue was encountered when trying to set up the Windows port of the Forgejo runner to run in host mode on a bare metal Windows machine and execute build scripts written for PowerShell 5.1. ### Forgejo Version 12.0.1 ### Runner Version 6.3.1 ### How are you running Forgejo? I downloaded the Forgejo binary from your website and followed the Installation from Binary instructions. The only deviations from these instructions is that I have configured it to keep all its data in a mounted volume instead of /var/lib and that I have disabled LFS support. ### How are you running the Runner? I downloaded a [Windows binary from Github](https://github.com/Crown0815/forgejo-runner-windows/releases/tag/v6.3.1) and configured it to run in host mode and with debug level set to trace. I then launch it myself from Windows command prompt and test it. Once it is all working I intend to create a user for it and run it as a service using [WinSW](https://github.com/winsw/winsw). ### Logs ``` time="2025-08-23T14:39:24+02:00" level=trace msg="Processing -File 'D:/Overmare/workspace/ca684af5e7ebaad1/act/workflow/0' failed because the file does not have a '.ps1' extension. Specify a valid Windows PowerShell script file name, and then try again.\r\n" dryrun=false job=/test1 jobID=test1 matrix="map[]" raw_output=true stage=Main step="Do stuff" stepID="[0]" stepNumber=0 | Processing -File 'D:/Overmare/workspace/ca684af5e7ebaad1/act/workflow/0' failed because the file does not have a '.ps1' extension. Specify a valid Windows PowerShell script file name, and then try again. ``` ### Workflow file ```YAML on: workflow_dispatch: jobs: test1: runs-on: windows defaults: run: shell: powershell -File {0} steps: - name: Do stuff run: echo Hello World ```
Contributor
@Crown0815 FYI
Owner

@AnsisMalins

Runner Version
6.3.1

Can you please upgrade to the latest runner, v9.1.1, and retest?

As this functionality is covered by automated tests and, on the surface, appears to name all shell files with .ps1 suffix (

name += ".ps1"

), I'm wondering if this may have been addressed already in one of the releases since then.

@AnsisMalins > Runner Version > 6.3.1 Can you please upgrade to the latest runner, v9.1.1, and retest? As this functionality is covered by automated tests and, on the surface, appears to name all shell files with ` .ps1` suffix (https://code.forgejo.org/forgejo/runner/src/commit/8b4bef2454acc9925c3f39e17c22f83096c2241a/act/runner/step_run.go#L143), I'm wondering if this may have been addressed already in one of the releases since then.
Author

6.3.1 is the newest Windows binary that's available, and I was unable to build from source.

6.3.1 is the newest Windows binary that's available, and I was unable to build from source.
Contributor
https://github.com/Crown0815/forgejo-runner-windows/tags indeed
Contributor

It seems @Crown0815 is not currently available. I'm going to close this because this is not the repository where windows support happen. Could you please file an issue at https://github.com/Crown0815/forgejo-runner-windows/issues instead? 🙏

It seems @Crown0815 is not currently available. I'm going to close this because this is not the repository where windows support happen. Could you please file an issue at https://github.com/Crown0815/forgejo-runner-windows/issues instead? 🙏
Sign in to join this conversation.
No milestone
No assignees
3 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
forgejo/runner#910
No description provided.