akinomyoga / ble.sh

Bash Line Editor―a line editor written in pure Bash with syntax highlighting, auto suggestions, vim modes, etc. for Bash interactive sessions.
BSD 3-Clause "New" or "Revised" License
2.56k stars 82 forks source link

'en_US.UTF-8' locale error in Termux #507

Open matte22ladde opened 3 days ago

matte22ladde commented 3 days ago

ble version: 0.4.0-devel4+32f290d Bash version: 5.2.32(1)-release (aarch64-unknown-linux-android)

ble.sh: The locale 'en_US.UTF-8' (LC_CTYPE) seems broken. Please check that the locale exists in the system.

akinomyoga commented 3 days ago

Please check that the locale exists in the system. What are the results of the following commands?

$ locale
$ locale -a | grep en_US

I started to check the locale in commit 537c6504aac637d5408d999eb0299738a4b47d3b since broken system locales turned out to cause problems.

matte22ladde commented 3 days ago
No command locale found, did you mean:
 Command locate in package mlocate
akinomyoga commented 3 days ago

No, I didn't mean locate. locale is one of the standard utilities required by POSIX.

matte22ladde commented 3 days ago
pkg list-all | grep locale

WARNING: apt does not have a stable CLI interface. Use with caution in scripts.

[ble: exit 1]
akinomyoga commented 3 days ago

If you want to search the package that provides the command locale, pkg list-all is not the right command. It only prints the names of packages. Since it is a part of the basic utilities, I don't think the package that contains locale would have the name locale. After some searching, pkg doesn't seem to provide a way to search for a file in packages that haven't been installed. Instead, it seems one can install and use apt-file. The correct way seems this:

$ pkg install apt-file
$ apt-file search /locale | grep 'locale$'

However, it turned out no package provides the command locale in the Termux repository. The above command only lists a file that is not a command.


I confirmed the problem in my Android using Termux. Surprisingly, it seems the C locale doesn't work in Termux while LANG=en_US.UTF-8 works. The following discussion says that Termux actually doesn't support C locale:

I found another thread that seems to imply that one can set up a locale in a Termux environment:

The first thread talked about dpkg-reconfigure and /etc/envrionment, but I don't find them in my Termux environment. The second thread seems to imply that those locales are only available with proot-distro, which doesn't seem to be the default package management of Termux.

ble.sh haven't been assuming the environments that don't support the most basic locale C, (though it assumes the opposite case where only the C locale is available). This implies that many places in the codebase can be potentially broken in Termux. I need to investigate the impact.

akinomyoga commented 1 day ago

I'll later investigate the impact and fix the relevant parts, which can be affected by the non-working C locale.