GitHub Actions执行make报错exit code 2:找不到test1.cpp文件
问题分析:GitHub Actions中make命令执行失败的原因
工作流代码
name: Makefile CI on: push: branches: [ "main" ] pull_request: branches: [ "main" ] jobs: build: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - name: Install openmp run: sudo apt update && sudo apt install libomp-dev - name: Install dependencies run: make - name: test run: ./test.o
执行报错信息
g++ -std=c++17 -pthread test1.cpp -o test.o g++: error: test1.cpp: No such file or directory g++: fatal error: no input files compilation terminated. make: *** [Makefile:4: all] Error 1 Error: Process completed with exit code 2.
原因总结
- 仓库里不存在
test1.cpp文件,或者文件路径和Makefile中指定的不一致。GitHub Actions通过actions/checkout拉取代码后,工作目录找不到该文件,导致g++编译时无输入文件。 - 检查Makefile第4行的编译规则,确认其中的源文件名和仓库实际文件名完全匹配,Linux环境下文件名区分大小写,注意不要写错大小写。
- 也有可能
test1.cpp被加入了.gitignore规则,没有被推送到GitHub仓库,因此checkout后工作目录中不存在该文件。
内容的提问来源于stack exchange,提问作者Mark Mylabris
相关产品推荐
相关产品推荐

