【发布时间】:2022-12-04 03:04:35
【问题描述】:
我习惯于使用 virtualenvs。但是由于某种原因,我无法在 github 操作作业中激活环境。
为了调试我添加了这一步:
- name: Activate virtualenv
run: |
echo $PATH
. .venv/bin/activate
ls /home/runner/work/<APP>/<APP>/.venv/bin
echo $PATH
在操作日志上我可以看到
/opt/hostedtoolcache/Python/3.9.13/x64/bin:/opt/hostedtoolcache/Python/3.9.13/x64:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
[...] # Cut here because a lot of lines are displayed. My executables are present including the one I'm trying to execute : pre-commit.
/home/runner/work/<APP>/<APP>/.venv/bin:/opt/hostedtoolcache/Python/3.9.13/x64/bin:/opt/hostedtoolcache/Python/3.9.13/x64:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
所以它应该工作...
但接下来的步骤是
- name: Linters
run: pre-commit
生成那些错误日志
Run pre-commit
pre-commit
shell: /usr/bin/bash -e {0}
env:
[...] # private
/home/runner/work/_temp/8e893c8d-5032-4dbb-8a15-59be68cb0f5d.sh: line 1: pre-commit: command not found
Error: Process completed with exit code 127.
如果我以这种方式转换上面的步骤,我没有问题:
- name: Linters
run: .venv/bin/pre-commit
出于某种原因,bash 无法找到我的可执行文件,而包含它的文件夹在 $PATH 中被引用。
【问题讨论】:
标签: bash virtualenv github-actions