michael-lazar / rtv

Browse Reddit from your terminal
MIT License
4.64k stars 274 forks source link

locale.Error: unsupported locale setting #587

Closed takedawilliam closed 6 years ago

takedawilliam commented 6 years ago

If I set my $LANG to the following:

LANG=ja_JP.UTF-8

the following error will occur

Traceback (most recent call last):
  File "/usr/bin/rtv", line 11, in <module>
    load_entry_point('rtv==1.23.0', 'console_scripts', 'rtv')()
  File "/usr/lib/python3.6/site-packages/pkg_resources/__init__.py", line 476, in load_entry_point
    return get_distribution(dist).load_entry_point(group, name)
  File "/usr/lib/python3.6/site-packages/pkg_resources/__init__.py", line 2700, in load_entry_point
    return ep.load()
  File "/usr/lib/python3.6/site-packages/pkg_resources/__init__.py", line 2318, in load
    return self.resolve()
  File "/usr/lib/python3.6/site-packages/pkg_resources/__init__.py", line 2324, in resolve
    module = __import__(self.module_name, fromlist=['__name__'], level=0)
  File "/usr/lib/python3.6/site-packages/rtv/__main__.py", line 254, in <module>
    sys.exit(main())
  File "/usr/lib/python3.6/site-packages/rtv/__main__.py", line 139, in main
    default_locale = locale.setlocale(locale.LC_ALL, '')
  File "/usr/lib/python3.6/locale.py", line 598, in setlocale
    return _setlocale(category, locale)
locale.Error: unsupported locale setting

If I use LANG=en_US.UTF-8, everything's OK.

michael-lazar commented 6 years ago

Is ja_JP.UTF-8 installed on your computer?

$ locale -a | grep ja_JP

I was able to replicate the error on my Arch laptop and had to go through this process (link) to get it working. We could improve RTV to catch the exception and print a more descriptive error message, but this sounds more like a system configuration issue to me.

takedawilliam commented 6 years ago

You're right. When I do locale -a, ja_JP.UTF-8 is not there. I forgot uncommenting this line in /etc/locale.gen

ja_JP.UTF-8 UTF-8  

After I uncomment it and rerun sudo locale-gen, rtv starts without any error.