在我设置的新 CentOS VM 上运行 github linter 工作流程时,出现以下错误:
Run ansible-lint --parseable ./ansible
Traceback (most recent call last):
File "/usr/local/bin/ansible-lint", line 8, in <module>
sys.exit(_run_cli_entrypoint())
File "/usr/local/lib/python3.9/site-packages/ansiblelint/__main__.py", line 344, in _run_cli_entrypoint
sys.exit(main(sys.argv))
File "/usr/local/lib/python3.9/site-packages/ansiblelint/__main__.py", line 197, in main
initialize_options(argv[1:])
File "/usr/local/lib/python3.9/site-packages/ansiblelint/__main__.py", line 110, in initialize_options
options.cache_dir = get_cache_dir(options.project_dir)
File "/usr/local/lib/python3.9/site-packages/ansible_compat/prerun.py", line 13, in get_cache_dir
basename = project_dir.resolve().name.encode(encoding="utf-8")
AttributeError: 'str' object has no attribute 'resolve'
Error: Process completed with exit code 1.
我尝试了以下软件包版本,但均因上述错误而失败:
- python3:3.9.16
- ansible:8.0.0 或 6.6.0
- ansible-compat:4.1.2 或 2.2.7
- ansible-core:2.15.0 或 2.13.9
- ansible-lint:6.17.0 或 6.10.2
使用 pip,还安装了以下依赖项:
- 薄片8
- yamlint==1.28.0
- 密码拼写
- comment_parser
是否存在一些 linter 依赖项或我缺少的其他内容?
linter 作业中的步骤是:
- name: 'Lint yaml - ansible, GH actions and GH workflows'
run: yamllint -f parsable ./
if: always()
最佳答案
在我的环境中,使用 pip install 将 ansible_compat 降级到 v3.0.1 解决了问题。从 v4 开始,prerun.py 包含给出错误的行。
关于python - ansible-lint 失败并显示 : AttributeError: 'str' object has no attribute 'resolve' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/76465558/