美文网首页
Makefile 的 *** missing separator

Makefile 的 *** missing separator

作者: 七秒钟回忆待续 | 来源:发表于2019-07-16 11:41 被阅读0次

    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

    相关文章

      网友评论

          本文标题:Makefile 的 *** missing separator

          本文链接:https://www.haomeiwen.com/subject/nmvnkctx.html