GitHub 操作安装 jinja j2
GitHub Actions install jinja j2
使用 GitHub 操作,我正在尝试安装 j2
:
jobs:
install-packages:
runs-on: ubuntu-latest
steps:
- run: |
sudo apt-get install -y jq
pip3 install --user --upgrade j2cli
j2 --version
这成功安装了 j2cli,但最后一个 j2 --version
生成 Error: Process completed with exit code 127.
(logs)。
为什么会这样?
当您使用 run
步骤执行脚本时,它会在调用 pip3
安装程序之前在 bash
shell by default. The error code 127
is emitted by shell when the given command is not found within your PATH
environment variable and it is not a built-in shell command. In other words, the system doesn't understand your command, because it doesn't know where to find the j2
command you're trying to call. When we know what the error means we can fix it by adding pip3
package installation directory to the PATH
. We can do it manually by locating the path by calling pip3 show j2cli
or we can set up a Python environment to do it automatically using a dedicated setup-python
action 中执行。考虑到这一点,应该调整脚本:
jobs:
install-packages:
runs-on: ubuntu-latest
steps:
- uses: actions/setup-python@v2
with:
python-version: 3.x
- run: |
pip3 install --user --upgrade j2cli
j2 --version
应该可以修复错误。
请注意我们不需要安装 jq
二进制文件,因为它预装在 GitHub 托管的运行器中。这就是为什么你不需要:
sudo apt-get install -y jq
如果我们看log included就可以看得很清楚
jq is already the newest version (1.5+dfsg-2).
您可以找到 GitHub 托管的运行器 here 中包含的软件。
使用 GitHub 操作,我正在尝试安装 j2
:
jobs:
install-packages:
runs-on: ubuntu-latest
steps:
- run: |
sudo apt-get install -y jq
pip3 install --user --upgrade j2cli
j2 --version
这成功安装了 j2cli,但最后一个 j2 --version
生成 Error: Process completed with exit code 127.
(logs)。
为什么会这样?
当您使用 run
步骤执行脚本时,它会在调用 pip3
安装程序之前在 bash
shell by default. The error code 127
is emitted by shell when the given command is not found within your PATH
environment variable and it is not a built-in shell command. In other words, the system doesn't understand your command, because it doesn't know where to find the j2
command you're trying to call. When we know what the error means we can fix it by adding pip3
package installation directory to the PATH
. We can do it manually by locating the path by calling pip3 show j2cli
or we can set up a Python environment to do it automatically using a dedicated setup-python
action 中执行。考虑到这一点,应该调整脚本:
jobs:
install-packages:
runs-on: ubuntu-latest
steps:
- uses: actions/setup-python@v2
with:
python-version: 3.x
- run: |
pip3 install --user --upgrade j2cli
j2 --version
应该可以修复错误。
请注意我们不需要安装 jq
二进制文件,因为它预装在 GitHub 托管的运行器中。这就是为什么你不需要:
sudo apt-get install -y jq
如果我们看log included就可以看得很清楚
jq is already the newest version (1.5+dfsg-2).
您可以找到 GitHub 托管的运行器 here 中包含的软件。