github-actions - 如何在 GitHub Actions 工作流程中进行 apt-get install?
问题描述
在新的 GitHub Actions 中,我正在尝试安装一个包,以便在后续步骤之一中使用它。
name: CI
on: [push, pull_request]
jobs:
translations:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
with:
fetch-depth: 1
- name: Install xmllint
run: apt-get install libxml2-utils
# ...
然而,这失败了
Run apt-get install libxml2-utils
apt-get install libxml2-utils
shell: /bin/bash -e {0}
E: Could not open lock file /var/lib/dpkg/lock-frontend - open (13: Permission denied)
E: Unable to acquire the dpkg frontend lock (/var/lib/dpkg/lock-frontend), are you root?
##[error]Process completed with exit code 100.
最好的方法是什么?我需要接触 Docker 吗?
解决方案
文档说:
Linux 和 macOS 虚拟机都使用无密码运行
sudo
。当您需要执行命令或安装需要比当前用户更多权限的工具时,您sudo
无需提供密码即可使用。
因此,只需执行以下操作即可:
- name: Install xmllint
run: sudo apt-get install -y libxml2-utils
推荐阅读
- delphi - How to cast with a class reference containing the type of some frame (Delphi)
- python - Converting String to Integer in Azure Cosmos DB Gremlin API
- javascript - Why do Firefox and Chrome return different results for tabs.Tab.favIconUrl? And how can I work around this?
- javascript - How does addEventListener uniquely identify the functions passed to it?
- python - 如何在pygame中给每个圆圈一个随机颜色?
- javascript - 这是一个对象{处理程序,上下文}吗?
- matrix - 使用联合时如何使用矩阵?
- reactjs - 调用处理程序时,在反应导航中使用下拉组件会引发错误
- python - 在 pandas df 中添加缺失的日期,但日期范围有(有效)重复项
- python - 如何正确批处理图像的张量流数据集形状