Makefile 的使用还是挺方便的,例如:
在项目的根目录下的 Makefile
文件里添加
run:
@ python main.py
执行 make run
期待的是正确运行 Python 脚本, 而实际上输出为 Makefile:2: *** missing separator. Stop.
并且还可能出现错误 make: run' is up to date.
原因:
Makefile 的缩进语法是一个 tag
, 而我使用的环境是 Pycharm
, 写 Python 设置 tab
为 4 个空格,因此出现了上面 missing separator
错误。
如果在 Makefile
的相同路径下有 run
文件 或者 目录 则会出现 is up to date.
的错误。
解决办法
- 复制粘贴
tab
,哈哈哈哈... 骚操作总有的 - 在项目根目录
touch .editorconfig
, 输入 :
[Makefile]
indent_style = tab
然后在 Makefile
里的 tag
就正常了...
- Makefile 添加一行
.PHONY: run
, 解决is update to date
问题
.PHONY: run
run:
@ python main.py
参考文章:
editorconfig官网
stackoverflow
网友评论