-
Notifications
You must be signed in to change notification settings - Fork 147
GitError: config: environment can only contain strings #82
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
How do I fix this?? |
Same issue. Waiting for the answer. |
UPDATE: Caused by windows encoding. try:
# ADD START: clean the encoding
env_clean = {}
for k in env:
key = k
if isinstance(key, unicode):
key = key.encode('utf-8')
env_clean[key] = env[k]
if isinstance(env_clean[key], unicode):
env_clean[key] = env_clean[key].encode('utf-8')
env = env_clean
# ADD END
p = subprocess.Popen(command,
cwd=cwd,
env=env,
stdin=stdin,
stdout=stdout,
stderr=stderr) |
Above solution is not working for me on windows with python 3.8 version. Observing the same failure (modified unicode to str in above snippet to make it work for py3) Any other solutions are appreciated. Thanks |
I think on Windows, somehow the env is stored as utf-8 encoded bytes/bytearray. So instead of encoding, we need decoding bytes to str I modified above solution as following. Then it works on Windows py3
|
I was using repo init:
repo init -u git://github.com/MiCode/patchrom.git -b marshmallow
then i got
Traceback (most recent call last):
File "C:\Users\admin.repo\repo\git_command.py", line 311, in init
p = subprocess.Popen(command,
File "C:\Users\admin\AppData\Local\Programs\Python\Python38\lib\subprocess.py", line 854, in init
self._execute_child(args, executable, preexec_fn, close_fds,
File "C:\Users\admin\AppData\Local\Programs\Python\Python38\lib\subprocess.py", line 1307, in _execute_child
hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
TypeError: environment can only contain strings
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\admin.repo\repo/main.py", line 568, in
_Main(sys.argv[1:])
File "C:\Users\admin.repo\repo/main.py", line 542, in _Main
result = run()
File "C:\Users\admin.repo\repo/main.py", line 535, in
run = lambda: repo._Run(name, gopts, argv) or 0
File "C:\Users\admin.repo\repo/main.py", line 213, in _Run
result = cmd.Execute(copts, cargs)
File "C:\Users\admin.repo\repo\subcmds\init.py", line 462, in Execute
self._SyncManifest(opt)
File "C:\Users\admin.repo\repo\subcmds\init.py", line 187, in _SyncManifest
print('Get %s' % GitConfig.ForUser().UrlInsteadOf(opt.manifest_url),
File "C:\Users\admin.repo\repo\git_config.py", line 237, in UrlInsteadOf
for new_url in self.GetSubSections('url'):
File "C:\Users\admin.repo\repo\git_config.py", line 224, in GetSubSections
return self._sections.get(section, set())
File "C:\Users\admin.repo\repo\git_config.py", line 248, in _sections
for name in self._cache.keys():
File "C:\Users\admin.repo\repo\git_config.py", line 265, in _cache
self._cache_dict = self._Read()
File "C:\Users\admin.repo\repo\git_config.py", line 271, in _Read
d = self._ReadGit()
File "C:\Users\admin.repo\repo\git_config.py", line 306, in _ReadGit
d = self._do('--null', '--list')
File "C:\Users\admin.repo\repo\git_config.py", line 329, in _do
p = GitCommand(None,
File "C:\Users\admin.repo\repo\git_command.py", line 318, in init
raise GitError('%s: %s' % (command[1], e))
error.GitError: config: environment can only contain strings
The text was updated successfully, but these errors were encountered: