【问题标题】:How to fix error “The filename, directory name, or volume label syntax is incorrect”?如何修复错误“文件名、目录名或卷标语法不正确”?
【发布时间】:2020-01-27 15:37:53
【问题描述】:

我在 Windows 上的 python 项目中使用 codecov,但是当我尝试将覆盖率报告上传到 codecove 服务器时,我收到以下错误:

文件名、目录名或卷标语法不正确。

D:\foo>codecov -t ***

      _____          _
     / ____|        | |
    | |     ___   __| | ___  ___ _____   __
    | |    / _ \ / _  |/ _ \/ __/ _ \ \ / /
    | |___| (_) | (_| |  __/ (_| (_) \ V /
     \_____\___/ \____|\___|\___\___/ \_/
                                    v2.0.15

[90m==>[0m Detecting CI provider
  -> Got branch from git/hg
  -> Got sha from git/hg
[90m==>[0m Preparing upload
The filename, directory name, or volume label syntax is incorrect.
    Error running `cd 'D:\foo' && git ls-files`: None
[41mError:[0m[91m Missing repository upload token[0m

[42mTip:[0m[32m See all example repositories: https://github.com/codecov?query=example[0m
[92mSupport channels:[0m
  Email:   hello@codecov.io
  IRC:     #codecov
  Gitter:  https://gitter.im/codecov/support
  Twitter: @codecov

但是

如果我运行 codecov 表单 WSL (Linux)(来自同一个 repo,具有相同的报告),一切都很好。


更新

codecov 2.0.10可以上传成功,从2.0.11我得到这个文件名、目录名或卷标语法不正确。错误。

【问题讨论】:

  • cd 'D:\foo' 中路径周围的单引号是 CMD 中的无效语法。它只支持正常引用的双引号。 (单引号在for /f 循环语句中有特殊用途。)CMD 最终会尝试解析相对于工作目录的名称,例如D:\foo\'D:\ 。我不知道为什么它不会以D:\foo\'D:\foo' 结尾,但无论如何它都不是有效的文件路径。

标签: python windows code-coverage codecov


【解决方案1】:

使用--file 开关提供覆盖报告文件(默认为coverage.xml)。在这种情况下,codecov 不会搜索文件,也不会崩溃。

codecov --no-color -X gcov --file coverage.xml

(我建议禁用 --no-color 和 gcov -X gcov 着色,以减少不必要的错误。)

更新

有一个解决这个问题的方法: https://github.com/codecov/codecov-python/issues/167

【讨论】:

    猜你喜欢
    • 2019-11-20
    • 2020-07-30
    • 2018-11-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-06-30
    • 1970-01-01
    相关资源
    最近更新 更多