builtins.OSError: 'git' has an invalid shebang line: 'git' is not a valid executable

builtins.OSError: 'git' has an invalid shebang line: 'git' is not a valid executable

我是 buildbot 的新手。我根据 Buildbot 1.5.0 文档的公会设置 master.cfg。 我已经通过 Tutorial 公会设置了 master。 master.cfg就是master.cfg.sample.可以强制构建,结果成功。但是 twistd.log 中出现错误。

builtins.OSError: 'git' has an invalid shebang line: 'git' is not a valid executable

详情请见下文

谁能告诉我发生了什么事?我确定git已经安装好了,因为它可以被强制构建成功。

It can be forced to build successfully.

2019-03-01 11:45:32+0800 [-] while polling for changes
Traceback (most recent call last):
  File "c:\buildbot\tmp\bb-master\sandbox\lib\site-packages\twisted\internet\defer.py", line 1418, in _inlineCallbacks
    result = g.send(result)
  File "c:\buildbot\tmp\bb-master\sandbox\lib\site-packages\buildbot\changes\gitpoller.py", line 410, in _dovccmd
    stdout = yield self._dovccmdImpl(command, args, path)
  File "c:\buildbot\tmp\bb-master\sandbox\lib\site-packages\twisted\internet\defer.py", line 1613, in unwindGenerator
    return _cancellableInlineCallbacks(gen)
  File "c:\buildbot\tmp\bb-master\sandbox\lib\site-packages\twisted\internet\defer.py", line 1529, in _cancellableInlineCallbacks
    _inlineCallbacks(None, g, status)
--- <exception caught here> ---
  File "c:\buildbot\tmp\bb-master\sandbox\lib\site-packages\buildbot\changes\gitpoller.py", line 192, in poll
    yield self._checkGitFeatures()
  File "c:\buildbot\tmp\bb-master\sandbox\lib\site-packages\buildbot\changes\gitpoller.py", line 122, in _checkGitFeatures
    stdout = yield self._dovccmd('--version', [])
  File "c:\buildbot\tmp\bb-master\sandbox\lib\site-packages\buildbot\changes\gitpoller.py", line 410, in _dovccmd
    stdout = yield self._dovccmdImpl(command, args, path)
  File "c:\buildbot\tmp\bb-master\sandbox\lib\site-packages\twisted\internet\defer.py", line 1418, in _inlineCallbacks
    result = g.send(result)
  File "c:\buildbot\tmp\bb-master\sandbox\lib\site-packages\buildbot\changes\gitpoller.py", line 434, in _dovccmdImpl
    full_args, path=path, env=full_env)
  File "c:\buildbot\tmp\bb-master\sandbox\lib\site-packages\twisted\internet\utils.py", line 174, in getProcessOutputAndValue
    reactor)
  File "c:\buildbot\tmp\bb-master\sandbox\lib\site-packages\twisted\internet\utils.py", line 28, in _callProtocolWithDeferred
    reactor.spawnProcess(p, executable, (executable,)+tuple(args), env, path)
  File "c:\buildbot\tmp\bb-master\sandbox\lib\site-packages\twisted\internet\posixbase.py", line 353, in spawnProcess
    return Process(self, processProtocol, executable, args, env, path)
  File "c:\buildbot\tmp\bb-master\sandbox\lib\site-packages\twisted\internet\_dumbwin32proc.py", line 240, in __init__
    command, command))
builtins.OSError: 'git' has an invalid shebang line: 'git' is not a valid executable

您可以看到生成 error message here:

的代码类型
            # look for a shebang line.  Insert the original 'command'
            # (actually a script) into the new arguments list.
            sheb = _findShebang(command)
            if sheb is None:
                raise OSError(
                    "%r is neither a Windows executable, "
                    "nor a script with a shebang line" % command)
            else:
                args = list(args)
                args.insert(0, command)
                cmdline = quoteArguments(args)
                origcmd = command
                command = sheb
                try:
                    # Let's try again.
                    doCreate()
                except pywintypes.error, pwte2:
                    # d'oh, failed again!
                    if _invalidWin32App(pwte2):
                        raise OSError(
                            "%r has an invalid shebang line: "
                            "%r is not a valid executable" % (
                                origcmd, sheb))
                    raise OSError(pwte2)

显然,在执行 git 时(从 shebang 中提取),进程在路径中找不到 git,因此失败。

使用 /c/path/to/git.exe 作为 shebang 可能会更有效率。