Skip to content
This repository has been archived by the owner on Jul 14, 2023. It is now read-only.

Unknown locale error "ValueError: unknown locale: UTF-8” with default locale set in MacOSX and Ubuntu #63

Open
yokawasa opened this issue Apr 11, 2017 · 0 comments

Comments

@yokawasa
Copy link
Contributor

Got unknown locale error "ValueError: unknown locale: UTF-8” with default locale set in MacOSX and Ubuntu (15.10, 16.10, at least):

 $ az-shell
Traceback (most recent call last):
  File "/Users/yoichika/.pyenv/versions/3.5.1/lib/python3.5/runpy.py", line 170, in _run_module_as_main
    "__main__", mod_spec)
  File "/Users/yoichika/.pyenv/versions/3.5.1/lib/python3.5/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/Users/yoichika/.local/lib/python3.5/site-packages/azclishell/__main__.py", line 18, in <module>
    from azclishell.app import Shell
  File "/Users/yoichika/.local/lib/python3.5/site-packages/azclishell/app.py", line 20, in <module>
    from azclishell.key_bindings import registry, get_section, sub_section
  File "/Users/yoichika/.local/lib/python3.5/site-packages/azclishell/key_bindings.py", line 9, in <module>
    from azclishell.telemetry import TC as telemetry
  File "/Users/yoichika/.local/lib/python3.5/site-packages/azclishell/telemetry.py", line 69, in <module>
    TC = Telemetry(INSTRUMENTATION_KEY)
  File "/Users/yoichika/.local/lib/python3.5/site-packages/applicationinsights/TelemetryClient.py", line 27, in __init__
    self._context = channel.TelemetryContext()
  File "/Users/yoichika/.local/lib/python3.5/site-packages/applicationinsights/channel/TelemetryContext.py", line 39, in __init__
    self.device = contracts.Device()
  File "/Users/yoichika/.local/lib/python3.5/site-packages/applicationinsights/channel/contracts/Device.py", line 30, in __init__
    self._initialize()
  File "/Users/yoichika/.local/lib/python3.5/site-packages/applicationinsights/channel/TelemetryContext.py", line 14, in device_initialize
    self.locale = locale.getdefaultlocale()[0]
  File "/Users/yoichika/.pyenv/versions/3.5.1/lib/python3.5/locale.py", line 559, in getdefaultlocale
    return _parse_localename(localename)
  File "/Users/yoichika/.pyenv/versions/3.5.1/lib/python3.5/locale.py", line 487, in _parse_localename
    raise ValueError('unknown locale: %s' % localename)
ValueError: unknown locale: UTF-8

This is actually an error from ApplicationInsight package, NOT from azure-cli-shell. However there should be some error handling placed in azure-cli-shell as long as it depends on ApplicationInsight package.

Default locale set on MacOS and Ubuntu is UTF-8:

$ locale
 LC_CTYPE=UTF-8

This issue must be related to this bug report and this can be resolved by adding locale configuration like this:

export LC_ALL=en_US.UTF-8
export LANG=en_US.UTF-8

My suggestion for the issue is:

  • To add some error handling to azure-cli-shell so as not to have the error with default locale set
  • To display warning message if locale set configuration isn't good enough in order to lead users to configure their locale set
@oakeyc oakeyc added this to the Release 0.3 milestone Apr 11, 2017
@oakeyc oakeyc added the size/S label Apr 11, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants