最近电脑硬盘出了问题,重装了一次系统。又去搭建了一次环境,记录下搭建环境的问题
在执行 repo 初始化的时候遇到了这个问题:
Traceback (most recent call last):
File "/sd2/cc/.repo/repo/main.py", line 531, in <module>
_Main(sys.argv[1:])
File "/sd2/cc/.repo/repo/main.py", line 507, in _Main
result = repo._Run(argv) or 0
File "/sd2/cc/.repo/repo/main.py", line 180, in _Run
result = cmd.Execute(copts, cargs)
File "/sd2/cc/.repo/repo/subcmds/init.py", line 399, in Execute
self._SyncManifest(opt)
File "/sd2/cc/.repo/repo/subcmds/init.py", line 171, in _SyncManifest
m._InitGitDir(mirror_git=mirrored_manifest_git)
File "/sd2/cc/.repo/repo/project.py", line 2271, in _InitGitDir
ref_dir = mp.config.GetString('repo.reference') or ''
File "/sd2/cc/.repo/repo/git_config.py", line 131, in GetString
v = self._cache[_key(name)]
File "/sd2/cc/.repo/repo/git_config.py", line 248, in _cache
self._cache_dict = self._Read()
File "/sd2/cc/.repo/repo/git_config.py", line 254, in _Read
d = self._ReadGit()
File "/sd2/cc/.repo/repo/git_config.py", line 299, in _ReadGit
for line in d.decode('utf-8').rstrip('\0').split('\0'): # pylint: disable=W1401
AttributeError: 'str' object has no attribute 'decode'
vi /sd2/cc/.repo/repo/git_config.py + 299
/*注意看报错*/
for line in d.rstrip('\0').split('\0'):
改为
for line in d.decode('utf-8').rstrip('\0').split('\0'):
后面就可以了。我再后面再次下载代码的时候又出现了同样的错误。进去查看后发现已经修改了,于是我又把他重新改回来就ok了。我以前配置的时候没有出现这种情况,不知到是不是repo的版本适配问题