[GRASS-dev] [GRASS GIS] #2869: Default locale not found

#2869: Default locale not found
-------------------------+-------------------------
Reporter: pmav99 | Owner: grass-dev@…
     Type: defect | Status: new
Priority: normal | Milestone: 7.1.0
Component: Default | Version: svn-trunk
Keywords: | CPU: Unspecified
Platform: Unspecified |
-------------------------+-------------------------
I compiled GRASS on a docker container running Ubuntu 14.04.3. I am using
trunk [67593] and I get the following traceback:
{{{#!python
grassuser@c4219210d562:/usr/local/src$ grass
WARNING: Default locale settings are missing. GRASS running with C locale.
WARNING: Searched for a web browser, but none found
Starting GRASS GIS...
Traceback (most recent call last):
   File "/usr/bin/grass", line 1937, in <module>
     main()
   File "/usr/bin/grass", line 1834, in main
     grass_gui = check_gui(expected_gui=grass_gui)
   File "/usr/bin/grass", line 721, in check_gui
     p.stdin.write("variable=True".encode(ENCODING))
TypeError: encode() argument 1 must be string, not None
}}}
This is easily fixed by setting one of the relevant env variables, e.g.:
{{{#!bash
grassuser@c4219210d562:/usr/local/src$ echo $LC_ALL

grassuser@c4219210d562:/usr/local/src$ export LC_ALL=en_GB.UTF-8
grassuser@c4219210d562:/usr/local/src$ grass
WARNING: Searched for a web browser, but none found
Starting GRASS GIS...
}}}
But since the documentation states that `getdefaultlocale()` may return
none, it might make sense to fallback to a default locale before giving
up.
{{{#!python
ENCODING = locale.getdefaultlocale()[1] or "utf-8"
}}}
If this is not desirable, then adding an explicit error message would
certainly be more user friendly:
{{{#!python
if ENCODING is None:
     sys.exit("Default locale not found ... ")
}}}

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/2869&gt;
GRASS GIS <https://grass.osgeo.org>

#2869: Default locale not found
--------------------------+-------------------------
  Reporter: pmav99 | Owner: grass-dev@…
      Type: defect | Status: new
  Priority: normal | Milestone: 7.1.0
Component: Default | Version: svn-trunk
Resolution: | Keywords:
       CPU: Unspecified | Platform: Unspecified
--------------------------+-------------------------

Comment (by annakrat):

Could you try r67607? It should fallback to UTF-8 and print a message.

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/2869#comment:1&gt;
GRASS GIS <https://grass.osgeo.org>

#2869: Default locale not found
--------------------------+-------------------------
  Reporter: pmav99 | Owner: grass-dev@…
      Type: defect | Status: new
  Priority: normal | Milestone: 7.1.0
Component: Default | Version: svn-trunk
Resolution: | Keywords:
       CPU: Unspecified | Platform: Unspecified
--------------------------+-------------------------

Comment (by pmav99):

Just tested this and it works.

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/2869#comment:2&gt;
GRASS GIS <https://grass.osgeo.org>

#2869: Default locale not found
--------------------------+-------------------------
  Reporter: pmav99 | Owner: grass-dev@…
      Type: defect | Status: closed
  Priority: normal | Milestone: 7.1.0
Component: Default | Version: svn-trunk
Resolution: fixed | Keywords:
       CPU: Unspecified | Platform: Unspecified
--------------------------+-------------------------
Changes (by annakrat):

* status: new => closed
* resolution: => fixed

Comment:

grass.py looks way different in release branch, so I won't backport.

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/2869#comment:3&gt;
GRASS GIS <https://grass.osgeo.org>