Recently emerging package =dev-lang/go-1.13.4 under Gentoo failed on one of our virtual servers with:
--- /usr/lib/go/test/fixedbugs/issue27836.dir/ Traceback (most recent call last): File "/usr/lib64/python3.6/site-packages/portage/dbapi/_MergeProcess.py", line 234, in _spawn prev_mtimes=self.prev_mtimes, counter=counter) File "/usr/lib64/python3.6/site-packages/portage/dbapi/vartree.py", line 1788, in wrapper return f(self, *args, **kwargs) File "/usr/lib64/python3.6/site-packages/portage/dbapi/vartree.py", line 5385, in merge counter=counter) File "/usr/lib64/python3.6/site-packages/portage/dbapi/vartree.py", line 4548, in treewalk rval = self._merge_contents(srcroot, destroot, cfgfiledict) File "/usr/lib64/python3.6/site-packages/portage/dbapi/vartree.py", line 4828, in _merge_contents self.settings["EPREFIX"].lstrip(os.sep), cfgfiledict, mymtime): File "/usr/lib64/python3.6/site-packages/portage/dbapi/vartree.py", line 5225, in mergeme encoding=_encodings['merge']) File "/usr/lib64/python3.6/site-packages/portage/util/movefile.py", line 256, in movefile selinux.rename(src, dest) File "/usr/lib64/python3.6/site-packages/portage/__init__.py", line 246, in __call__ rval = self._func(*wrapped_args, **wrapped_kwargs) File "/usr/lib64/python3.6/site-packages/portage/_selinux.py", line 71, in rename os.rename(src, dest) UnicodeEncodeError: 'ascii' codec can't encode character '\xc4' in position 83: ordinal not in range(128) >>> Failed to install dev-lang/go-1.13.4, Log file: >>> '/var/tmp/portage/dev-lang/go-1.13.4/temp/build.log'
The above log shows that the emerge fails in the installation phase when moving the files to the proper path in the system. The problem there is a non-ASCII character in the file name or path, but the environment is set to use ASCII as language.
The solution is to check if the environment LANG is set and what it contains. In this case, we should set the LANG environment to utf8.
Most of the cases this kind of error could occur with virtual servers, docker (or the other kind of containers like lxc, podman and so on) containers and chroot jails or screens with changed user with su or sudo! In our case, the LANG just got missed because of a switch user procedure in a container and the emerge failed with the above error. When the LANG is missing probably the default value is “C”. In fact, check not only LANG but also the “LC_ALL” environment variable (it may have different value, which is wrong!), which also should be “en_US.UTF-8”:
Or try removing it at all with
Note about the locale support
We use here “en_US.UTF-8”, because we have installed our system with this locale support, but you may use other locale support in your environment. You can chech the locale support in your system in the file – /etc/locale.gen or with the command:
[root@logs ~]# locale -a C C.utf8 en_AG en_AU en_AU.utf8 en_BW en_BW.utf8 en_CA en_CA.utf8 en_DK en_DK.utf8 en_GB en_GB.iso885915 en_GB.utf8 en_HK en_HK.utf8 en_IE en_IE@euro en_IE.utf8 en_IL en_IN en_NG en_NZ en_NZ.utf8 en_PH en_PH.utf8 en_SC.utf8 en_SG en_SG.utf8 en_US en_US.iso885915 en_US.utf8 en_ZA en_ZA.utf8 en_ZM en_ZW en_ZW.utf8 POSIX
The above command is executed under CentOS Linux release 8.0.1905 (Core).