官方教程的大坑-Windows下gclient拉取代码错误

按照官方教程,安装好depot_tools之后,执行

gclient sync --patch-ref=https://chromium.googlesource.com/chromium/src/build.git@gitlab

命令,之后,报了一个这样的错误

看报错,是python的模块里出了问题。直接用pycharm打开depot_tools,选中gclient.py运行,添加命令行参数,可以追溯到堆栈里有这个信息

看到这个git.bat 只有恍然大悟,原来我的系统上没有git.bat那个文件,都是直接git.exe运行的。
查找一下这个变量在哪里赋值


就在这里,改成git.exe就可以了

4赞

感谢你的分享,我们会让更多人知道。

感谢楼主分享。我也遇到了这个问题,使用楼主的方法解决了。

kernel32.SetConsoleMode to enable ANSI sequences failed
Running: ‘C:\Users\zhuxiaoguang.vpython-root\11e4d5\Scripts\python.exe’ ‘E:\tools\depot_tools\gclient.py’ sync --nohooks --with_branch_heads
kernel32.SetConsoleMode to enable ANSI sequences failed
Syncing projects: 100% ( 1/ 1) src

src (ERROR)

[0:00:00] Started.
[0:00:00]
Traceback (most recent call last):
File “E:\tools\depot_tools\gclient_scm.py”, line 1043, in _Clone
self._Run(clone_cmd, options, cwd=self._root_dir, retry=True,
File “E:\tools\depot_tools\gclient_scm.py”, line 1411, in _Run
gclient_utils.CheckCallAndFilter(cmd, env=env, **kwargs)
File “E:\tools\depot_tools\gclient_utils.py”, line 634, in CheckCallAndFilter
show_header_if_necessary(needs_header, attempt)
File “E:\tools\depot_tools\gclient_utils.py”, line 567, in show_header_if_necessary
stdout_write(header.encode())
File “E:\tools\depot_tools\third_party\colorama\ansitowin32.py”, line 41, in write
self.__convertor.write(text)
File “E:\tools\depot_tools\third_party\colorama\ansitowin32.py”, line 162, in write
self.write_and_convert(text)
File “E:\tools\depot_tools\third_party\colorama\ansitowin32.py”, line 184, in write_and_convert
text = self.convert_osc(text)
File “E:\tools\depot_tools\third_party\colorama\ansitowin32.py”, line 246, in convert_osc
for match in self.ANSI_OSC_RE.finditer(text):
TypeError: cannot use a string pattern on a bytes-like object
[0:00:01] _____ removing non-empty tmp dir D:\workspace\c++\opensource\other\webrtc-code_gclient_src_nkc08ptb

Traceback (most recent call last):
File “E:\tools\depot_tools\metrics.py”, line 267, in print_notice_and_exit
yield
File “E:\tools\depot_tools\gclient.py”, line 3195, in
sys.exit(main(sys.argv[1:]))
File “E:\tools\depot_tools\gclient.py”, line 3181, in main
return dispatcher.execute(OptionParser(), argv)
File “E:\tools\depot_tools\subcommand.py”, line 252, in execute
return command(parser, args[1:])
File “E:\tools\depot_tools\gclient.py”, line 2737, in CMDsync
ret = client.RunOnDeps(‘update’, args)
File “E:\tools\depot_tools\gclient.py”, line 1779, in RunOnDeps
work_queue.flush(revision_overrides, command, args, options=self._options,
File “E:\tools\depot_tools\gclient_utils.py”, line 965, in flush
reraise(e[0], e[1], e[2])
File “E:\tools\depot_tools\gclient_utils.py”, line 67, in reraise
raise value
File “E:\tools\depot_tools\gclient_utils.py”, line 1042, in run
self.item.run(*self.args, **self.kwargs)
File “E:\tools\depot_tools\gclient.py”, line 925, in run
self._got_revision = self._used_scm.RunCommand(command, options, args,
File “E:\tools\depot_tools\gclient_scm.py”, line 132, in RunCommand
return getattr(self, command)(options, args, file_list)
File “E:\tools\depot_tools\gclient_scm.py”, line 546, in update
self._Clone(revision, url, options)
File “E:\tools\depot_tools\gclient_scm.py”, line 1043, in _Clone
self._Run(clone_cmd, options, cwd=self._root_dir, retry=True,
File “E:\tools\depot_tools\gclient_scm.py”, line 1411, in _Run
gclient_utils.CheckCallAndFilter(cmd, env=env, **kwargs)
File “E:\tools\depot_tools\gclient_utils.py”, line 634, in CheckCallAndFilter
show_header_if_necessary(needs_header, attempt)
File “E:\tools\depot_tools\gclient_utils.py”, line 567, in show_header_if_necessary
stdout_write(header.encode())
File “E:\tools\depot_tools\third_party\colorama\ansitowin32.py”, line 41, in write
self.__convertor.write(text)
File “E:\tools\depot_tools\third_party\colorama\ansitowin32.py”, line 162, in write
self.write_and_convert(text)
File “E:\tools\depot_tools\third_party\colorama\ansitowin32.py”, line 184, in write_and_convert
text = self.convert_osc(text)
File “E:\tools\depot_tools\third_party\colorama\ansitowin32.py”, line 246, in convert_osc
for match in self.ANSI_OSC_RE.finditer(text):
TypeError: cannot use a string pattern on a bytes-like object
Subprocess failed with return code 1.
帮忙看下这是什么问题。

[0:48:16] Still working on:
[0:48:16] src/third_party/catapult
Syncing projects: 100% (41/41), done.
Traceback (most recent call last):
File “E:\tools\depot_tools\metrics.py”, line 267, in print_notice_and_exit
yield
File “E:\tools\depot_tools\gclient.py”, line 3195, in
sys.exit(main(sys.argv[1:]))
File “E:\tools\depot_tools\gclient.py”, line 3181, in main
return dispatcher.execute(OptionParser(), argv)
File “E:\tools\depot_tools\subcommand.py”, line 252, in execute
return command(parser, args[1:])
File “E:\tools\depot_tools\gclient.py”, line 2737, in CMDsync
ret = client.RunOnDeps(‘update’, args)
File “E:\tools\depot_tools\gclient.py”, line 1814, in RunOnDeps
self.RunHooksRecursively(self._options, pm)
File “E:\tools\depot_tools\gclient.py”, line 1084, in RunHooksRecursively
hook.run()
File “E:\tools\depot_tools\gclient.py”, line 250, in run
gclient_utils.CheckCallAndFilter(
File “E:\tools\depot_tools\gclient_utils.py”, line 634, in CheckCallAndFilter
show_header_if_necessary(needs_header, attempt)
File “E:\tools\depot_tools\gclient_utils.py”, line 567, in show_header_if_necessary
stdout_write(header.encode())
File “E:\tools\depot_tools\third_party\colorama\ansitowin32.py”, line 41, in write
self.__convertor.write(text)
File “E:\tools\depot_tools\third_party\colorama\ansitowin32.py”, line 162, in write
self.write_and_convert(text)
File “E:\tools\depot_tools\third_party\colorama\ansitowin32.py”, line 184, in write_and_convert
text = self.convert_osc(text)
File “E:\tools\depot_tools\third_party\colorama\ansitowin32.py”, line 246, in convert_osc
for match in self.ANSI_OSC_RE.finditer(text):
TypeError: cannot use a string pattern on a bytes-like object