runner icon indicating copy to clipboard operation
runner copied to clipboard

Run actions runner on FreeBSD Linux compatibility layer

Open ChanTsune opened this issue 1 year ago • 1 comments

Hi! actions runner developers!

I tried to run a self-hosted runner on the FreeBSD Linux compatibility layer. When I attempted to run it, I encountered an error stating that the 'tar' command does not exist. After investigating the cause, I discovered that Directory.GetFiles was not functioning as expected in WhichUtil.Which. On FreeBSD's Linux compatibility layer, Directory.GetFiles does not work properly and consistently returns an empty array. Therefore, I implemented the equivalent functionality using File.Exists.

After overcoming this issue, the runner functions more or less as expected on FreeBSD Linux compatibility layer. https://github.com/actions/runner/issues/385

I am actually using a self-hosted runner in this repository with this change applied.

ChanTsune avatar Feb 10 '24 07:02 ChanTsune

Hi @ChanTsune !

While I'm not an actions developer, I am also interested in this merged for similar reasons. The problem is that it no longer applies since https://github.com/actions/runner/commit/5107c5efb2b122903d95f59d492dfc9438419230. I've adapted the patch and now my freebsd-based worker seems to be ok:

diff --git a/src/Runner.Sdk/Util/WhichUtil.cs b/src/Runner.Sdk/Util/WhichUtil.cs
index ef7683a..653d00b 100644
--- a/src/Runner.Sdk/Util/WhichUtil.cs
+++ b/src/Runner.Sdk/Util/WhichUtil.cs
@@ -95,13 +95,11 @@ namespace GitHub.Runner.Sdk
 #else
                     try
                     {
-                        foreach (var file in Directory.EnumerateFiles(pathSegment, command))
+                        string commandPath = Path.Join(pathSegment, command);
+                        if (File.Exists(commandPath) && IsPathValid(commandPath, trace))
                         {
-                            if (IsPathValid(file, trace))
-                            {
-                                trace?.Info($"Location: '{file}'");
-                                return file;
-                            }
+                            trace?.Info($"Location: '{commandPath}'");
+                            return commandPath;
                         }
                     }
                     catch (UnauthorizedAccessException ex)

Hope this helps

thresheek avatar May 03 '24 21:05 thresheek