Github Actions Self-Hosted Runner: Cannot Access /usr/local/lib/ Directory #173951
Replies: 5 comments 2 replies
-
|
Self-hosted runner operates in an isolated environment and cannot see the
Recommended SolutionsOption 1: Add Runner User to Group During Runner InstallationWhen you initially set up the self-hosted runner, the installation creates a user. You need to add this user to the group before starting the runner service. # Find the runner user (usually 'runner' or your username)
whoami
# Stop the runner service
sudo ./svc.sh stop
# Add the runner user to the exanic-user group
sudo usermod -a -G exanic-user runner
# Verify the addition
groups runner
# Restart the runner service
sudo ./svc.sh startImportant: Group membership changes only take effect after the user logs out and back in, or the service restarts. Option 2: Modify Linker Search Path in Your WorkflowInstead of changing permissions, tell the linker where to find the library: - name: Build with CMake
run: |
export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH
cmake --build build
env:
LDFLAGS: "-L/usr/local/lib"Or set it in your CMakeLists.txt: link_directories(/usr/local/lib)Option 3: Use Sudo in Workflow (If Runner Has Sudo Access)If your runner user has sudo privileges without password: - name: Build with library access
run: |
sudo -E cmake --build buildThe Option 4: Grant Read-Only Access to Specific FilesInstead of opening up the entire # As root or with sudo
sudo setfacl -m u:runner:rx /usr/local/lib
sudo setfacl -m u:runner:r /usr/local/lib/libexanic.*This uses ACLs to grant only the runner user read/execute permissions without changing the overall directory permissions. Debugging StepsCheck the runner's actual user and group memberships: - name: Debug runner context
run: |
whoami
id
groups
ls -la /usr/local/lib/ | grep exanic || echo "Cannot access library"
getent group exanic-user || echo "Group not visible"Why Your Current Approach Doesn't WorkThe commands in your workflow run inside the runner's process, which already has its groups assigned. Running My RecommendationUse Option 1 + Option 2 combined:
|
Beta Was this translation helpful? Give feedback.
-
✅ Solution for Runner Permission and Group Access (Path #1)You are absolutely correct: the core of the problem is that group membership is assigned to a user/process upon login or service start. Running The recommended solution for Path #1 is to change the runner user's group membership externally and then restart the runner service. Step 1: Add the Runner User to the Group (External to Workflow)These steps must be performed on the self-hosted machine's console where the runner is installed, not in a GitHub Actions workflow
Step 2: Ensure the Linker Can Find the Library (Workflow Configuration)Even after fixing permissions, the linker ( - name: Build with CMake
run: |
# Add the library directory to the linker search path
export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH
# Run your build command
cmake --build build --config Release
# Or use LDFLAGS/CXXFLAGS if your build system honors them
env:
LDFLAGS: "-L/usr/local/lib"
# CXXFLAGS: "-I/usr/local/include" # if you also had include path issuesBy combining the external permission fix (Step 1) with the explicit linker path configuration (Step 2), you ensure the runner has both the necessary access and the correct path information to complete the build successfully. |
Beta Was this translation helpful? Give feedback.
-
|
🕒 Discussion Activity Reminder 🕒 This Discussion has been labeled as dormant by an automated system for having no activity in the last 60 days. Please consider one the following actions: 1️⃣ Close as Out of Date: If the topic is no longer relevant, close the Discussion as 2️⃣ Provide More Information: Share additional details or context — or let the community know if you've found a solution on your own. 3️⃣ Mark a Reply as Answer: If your question has been answered by a reply, mark the most helpful reply as the solution. Note: This dormant notification will only apply to Discussions with the Thank you for helping bring this Discussion to a resolution! 💬 |
Beta Was this translation helpful? Give feedback.
-
|
What's wrong with this ??? Obed.. what is this |
Beta Was this translation helpful? Give feedback.
-
|
🕒 Discussion Activity Reminder 🕒 This Discussion has been labeled as dormant by an automated system for having no activity in the last 60 days. Please consider one the following actions: 1️⃣ Close as Out of Date: If the topic is no longer relevant, close the Discussion as 2️⃣ Provide More Information: Share additional details or context — or let the community know if you've found a solution on your own. 3️⃣ Mark a Reply as Answer: If your question has been answered by a reply, mark the most helpful reply as the solution. Note: This dormant notification will only apply to Discussions with the Thank you for helping bring this Discussion to a resolution! 💬 |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Why are you starting this discussion?
Question
What GitHub Actions topic or product is this about?
Actions Runner
Discussion Details
I am using self-hosted github actions runner and it is trying to access a 3rd party library (libexanic) stored under "/usr/local/lib/".
The exact error I got is
/usr/bin/ld: cannot find -lexanic: No such file or directory collect2: error: ld returned 1 exit status, which after digging, the linker complains about unable to find libexanic stored under /usr/local/lib/ due to permission denied. Running CMake build in my local vscode does trigger this issue, as myself user is added to the group "exanic-user" and have the full access to /usr/local/lib.There are 3 paths I could tackle the problem:
$ whoamirunner
$ ls -l /etc/group || echo "unable to access /etc/group"-rw-r--r-- 1 root root 1010 Sep 7 22:09 /etc/group
$ cat /etc/group | grep exanic-user || echo "unable to access exanic-user group info"unable to access exanic-user group info
$ sudo usermod -a -G exanic-user $(whoami) || echo "unable to add user to exanic-user group"usermod: group 'exanic-user' does not exist
unable to add user to exanic-user group
It seems the runner is created in this github actions sandbox environment, and cannot access the group info outside it. I suppose there are some config file that can pre-load some settings when creating the runner, but could not locate them.
Lots of people (and chatbots) suggest to chmod the /usr/local/lib to allow everyone to access it, but since this is a shared utility folder, which is also used by others with some delicate permission level separations. Allowing everyone to access it might create some unwanted consequences and break this delicate permission design.
Copy over the linked file to the repo, and try to make the build succeed. This just adds extra libraries that should not be tracked in the repo, and creates extra dependencies as any update to exanic code needs to be manually pulled into the repo. Therefore, I am hesitate to do that.
Please suggest how to go from here, especially for the path #1. Any help is appreciated, thank you!
Beta Was this translation helpful? Give feedback.
All reactions