无法在Linux上安装GitHub actions runner

10

我正在尝试在我的Linux机器(Ubuntu 20.04.1 LTS)上安装GitHub runner,按照repo>settings>Actions>add runner中描述的步骤操作。前几步都很顺利,但是当我运行config:

./config.sh --url <repo URL> --token <token>

我收到了以下失败消息:

ldd: ./bin/libSystem.Security.Cryptography.Native.OpenSsl.so: No such file or directory
ldd: ./bin/libSystem.IO.Compression.Native.so: No such file or directory
touch: cannot touch '.env': Permission denied
./env.sh: line 37: .path: Permission denied
./env.sh: line 32: .env: Permission denied
Unhandled exception. System.UnauthorizedAccessException: Access to the path '/actions-runner/_diag' is denied.
 ---> System.IO.IOException: Permission denied
   --- End of inner exception stack trace ---
   at System.IO.FileSystem.CreateDirectory(String fullPath)
   at System.IO.Directory.CreateDirectory(String path)
   at GitHub.Runner.Common.HostTraceListener..ctor(String logFileDirectory, String logFilePrefix, Int32 pageSizeLimit, Int32 retentionDays)
   at GitHub.Runner.Common.HostContext..ctor(String hostType, String logFile)
   at GitHub.Runner.Listener.Program.Main(String[] args)
./config.sh: line 76: 10405 Aborted                 (core dumped) ./bin/Runner.Listener configure "$@"

config.sh不允许用户以sudo身份执行它,因此我已经修改了脚本,以允许这样做,但是权限的问题仍然存在。有什么想法吗?

更新:我还在/actions-runner目录中运行了下面的命令安装依赖项,但没有任何改变,错误消息仍然相同。

sudo ./bin/installdependencies.sh

7个回答

16

选择runner时,请确保使用正确的镜像以便在执行时发挥作用。

输入图像描述


5
我不敢相信我犯了这个错误。 - Tristan Diependael

3

以上解决方案对我无效,我安装了一个旧版 2.276.1。对于64位Linux操作系统,curl命令如下:

curl -O -L https://github.com/actions/runner/releases/download/v2.276.1/actions-runner-linux-x64-2.276.1.tar.gz

3

以下命令在我的情况下有所帮助:

sudo chown -R $(id -u):$(id -g) $PWD

2
这个问题与.NET依赖关系有关。GitHub runner使用的是3.x版本,而最新版本(我已经安装的版本)是5。在更新的版本中,这些库被重新命名,没有以前缀“lib”开头。更多细节请参见此处

.NET 3.x:

libSystem.Security.Cryptography.Native.OpenSsl.so
libSystem.IO.Compression.Native.so

.NET 5.x

System.Security.Cryptography.Native.OpenSsl.so
System.IO.Compression.Native.so

解决方案:

1 - 安装.NET 3.x 安装指南

2 - 创建符号链接以通过旧版本访问新版本:

ln -s /usr/share/dotnet/shared/Microsoft.NETCore.App/5.0.1/libSystem.Security.Cryptography.Native.OpenSsl.so /usr/share/dotnet/shared/Microsoft.NETCore.App/3.1.10/libSystem.Security.Cryptography.Native.OpenSsl.so

ln -s /usr/share/dotnet/shared/Microsoft.NETCore.App/5.0.1/libSystem.Security.Cryptography.Native.OpenSsl.a /usr/share/dotnet/shared/Microsoft.NETCore.App/3.1.10/libSystem.Security.Cryptography.Native.OpenSsl.a

2
扩展@someone的回答,我创建了一个快速循环来为在github操作运行程序的bin目录中存在的这些重命名库创建符号链接。运行installdependencies.sh脚本后,它会为每个以"System."开头并将"lib"附加到原始文件名的文件创建符号链接。
sudo ./bin/installdependencies.sh \
   && cd ./bin \
   && for lib in $(find . -name 'System.*'); do \
     toFile=$(echo "$lib" | sed -e 's/\.\/System\./.\/libSystem./g'); \
     if ! [ -f $toFile ]; then sudo ln -s $lib $toFile; fi; \
  done && cd ..

1
我会让它更简单,并仅适用于.so文件:cd bin && for i in System.*.so; do [ -e lib$i ] || sudo ln -s $i lib$i; done - chickenkiller
有一些被重命名的文件没有使用扩展名 .so,但我喜欢你做的其他优化。谢谢! - draxiom

0

这个错误不是在安装时出现的,而是当我尝试将action-runner作为服务启动时出现了相同的错误。

在我的情况下,action-runner必须由root运行,因此它被安装在一个属于root的文件夹中。 经过一些调试后,我发现svc.sh脚本会将服务安装为以SUDO_USER用户运行,即使安装是以root身份运行的。

所以,如果你希望服务以root身份运行,你需要明确告诉安装程序:

./svc.sh install root

docs.github.com中描述的可选user参数。

-1

如下所示:

screenshot

如果您使用sudo命令创建了操作运行程序,则权限将不同。我在action-runner1中遇到了与上述相同的错误,但在action-runner2中没有错误。在创建文件夹action-runner时,请勿使用sudo

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接