Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run actions runner on FreeBSD Linux compatibility layer #3144

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

ChanTsune
Copy link

@ChanTsune ChanTsune commented Feb 10, 2024

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.
#385

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

@ChanTsune ChanTsune requested a review from a team as a code owner February 10, 2024 07:46
thresheek added a commit to thresheek/runner that referenced this pull request May 3, 2024
@thresheek
Copy link

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 5107c5e. 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 added a commit to thresheek/runner that referenced this pull request Aug 9, 2024
thresheek added a commit to thresheek/runner that referenced this pull request Sep 20, 2024
On FreeBSD's Linux compatibility layer, `Directory.GetFiles` does not work properly and always returns an empty array, so the equivalent functionality is achieved using `File.Exists`.
@ChanTsune ChanTsune force-pushed the run-actions-runner-on-freebsd-with-linux-compat-layer branch from 7ed876f to d51ed53 Compare October 21, 2024 08:28
thresheek added a commit to thresheek/runner that referenced this pull request Nov 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants