Search code examples
pythongitcontinuous-integrationbuildbot

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


I'm a new beginner on buildbot. I setup the master.cfg according to the guild of Buildbot 1.5.0 documentation. I’ve setup master by the guild of Tutorial. The master.cfg is master.cfg.sample. It can be forced to build and the result is success. But there was an error in twistd.log.

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

Please see following for more details.

Could any tell me what happened? I'm sure git is well installed because it can be forced to build successfully.

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

Solution

  • You can see the kind of code producing the 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)
    

    So apparently, when executing git (as extracted from a shebang), the process does not find git in the path, and fails.

    Using /c/path/to/git.exe as a shebang might be more productive.