[GRASS-dev] [GRASS GIS] #2210: unable to start GRASS GIS 7

#2210: unable to start GRASS GIS 7
--------------------+-------------------------------------------------------
Reporter: turek | Owner: grass-dev@…
     Type: defect | Status: new
Priority: normal | Milestone: 7.0.0
Component: Python | Version: svn-trunk
Keywords: | Platform: Linux
      Cpu: x86-64 |
--------------------+-------------------------------------------------------
Hi,

since r59163 I am getting following error when GRASS 7 is started. I am
getting same error also in recent revisions (r59205):

{{{
ostepok@ostepok-pc:~/Dev/GRASS/grass_wms/grass_trunk$ ./bin.x86_64
-unknown-linux-gnu/grass70
Cleaning up temporary files...
Starting GRASS GIS...
Traceback (most recent call last):
   File "/home/ostepok/Dev/GRASS/grass_wms/grass_trunk/dist.x86_64-unknown-
linux-gnu/etc/gui/wxpython/gis_set.py", line 37, in <module>
     from core.utils import _
   File "/home/ostepok/Dev/GRASS/grass_wms/grass_trunk/dist.x86_64-unknown-
linux-gnu/etc/gui/wxpython/core/utils.py", line 36, in <module>
     from core.gcmd import RunCommand
   File "/home/ostepok/Dev/GRASS/grass_wms/grass_trunk/dist.x86_64-unknown-
linux-gnu/etc/gui/wxpython/core/gcmd.py", line 744, in <module>
     _enc = GetDefaultEncoding() # define as global variable
   File "/home/ostepok/Dev/GRASS/grass_wms/grass_trunk/dist.x86_64-unknown-
linux-gnu/etc/gui/wxpython/core/gcmd.py", line 737, in GetDefaultEncoding
     enc = locale.getdefaultlocale()[1]
   File "/usr/lib/python2.7/locale.py", line 511, in getdefaultlocale
     return _parse_localename(localename)
   File "/usr/lib/python2.7/locale.py", line 443, in _parse_localename
     raise ValueError, 'unknown locale: %s' % localename
ValueError: unknown locale: None
Error in GUI startup. If necessary, please report this error to the GRASS
developers.
Switching to text mode now.

Hit RETURN to continue...
}}}

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

#2210: unable to start GRASS GIS 7
--------------------+-------------------------------------------------------
Reporter: turek | Owner: grass-dev@…
     Type: defect | Status: new
Priority: normal | Milestone: 7.0.0
Component: Python | Version: svn-trunk
Keywords: | Platform: Linux
      Cpu: x86-64 |
--------------------+-------------------------------------------------------

Comment(by marisn):

Please, provide output of following commands:
{{{
locale (outside of GRASS and inside GRASS session)
locale -a
grep language ~/.grass7/wx
}}}

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

#2210: unable to start GRASS GIS 7
--------------------+-------------------------------------------------------
Reporter: turek | Owner: grass-dev@…
     Type: defect | Status: new
Priority: normal | Milestone: 7.0.0
Component: Python | Version: svn-trunk
Keywords: | Platform: Linux
      Cpu: x86-64 |
--------------------+-------------------------------------------------------

Comment(by turek):

Hi,

locale outside GRASS session:

{{{
LANG=en_US.UTF-8
LANGUAGE=
LC_CTYPE="en_US.UTF-8"
LC_NUMERIC="en_US.UTF-8"
LC_TIME="en_US.UTF-8"
LC_COLLATE="en_US.UTF-8"
LC_MONETARY="en_US.UTF-8"
LC_MESSAGES="en_US.UTF-8"
LC_PAPER="en_US.UTF-8"
LC_NAME="en_US.UTF-8"
LC_ADDRESS="en_US.UTF-8"
LC_TELEPHONE="en_US.UTF-8"
LC_MEASUREMENT="en_US.UTF-8"
LC_IDENTIFICATION="en_US.UTF-8"
LC_ALL=
}}}

locale inside GRASS session:
{{{
LANG=None
LANGUAGE=None
LC_CTYPE=C
LC_NUMERIC=C
LC_TIME=C
LC_COLLATE=C
LC_MONETARY=C
LC_MESSAGES=C
LC_PAPER=C
LC_NAME=C
LC_ADDRESS=C
LC_TELEPHONE=C
LC_MEASUREMENT=C
LC_IDENTIFICATION=C
LC_ALL=
}}}

locale -a:
{{{
C
C.UTF-8
POSIX
en_AG
en_AG.utf8
en_AU.utf8
en_BW.utf8
en_CA.utf8
en_DK.utf8
en_GB.utf8
en_HK.utf8
en_IE.utf8
en_IN
en_IN.utf8
en_NG
en_NG.utf8
en_NZ.utf8
en_PH.utf8
en_SG.utf8
en_US.utf8
en_ZA.utf8
en_ZM
en_ZM.utf8
en_ZW.utf8
}}}

grep language ~/.grass7/wx:
{{{
language;locale;lc_all;None
}}}

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

#2210: unable to start GRASS GIS 7
---------------------+------------------------------------------------------
  Reporter: turek | Owner: grass-dev@…
      Type: defect | Status: closed
  Priority: normal | Milestone: 7.0.0
Component: Python | Version: svn-trunk
Resolution: fixed | Keywords:
  Platform: Linux | Cpu: x86-64
---------------------+------------------------------------------------------
Changes (by marisn):

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

Comment:

Ahh. I see. The new language override code is too tolerant - if no
override is specified, it doesn't call setlocale() at all and thus process
ends running with C locale.

Should be fixed in r59211. Reopen this bug if needed.

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

#2210: unable to start GRASS GIS 7
---------------------+------------------------------------------------------
  Reporter: turek | Owner: grass-dev@…
      Type: defect | Status: reopened
  Priority: normal | Milestone: 7.0.0
Component: Python | Version: svn-trunk
Resolution: | Keywords:
  Platform: Linux | Cpu: x86-64
---------------------+------------------------------------------------------
Changes (by turek):

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

Comment:

Hi,

I tried r59211, unfortunately, I stil get the same error.

--
Ticket URL: <http://trac.osgeo.org/grass/ticket/2210#comment:4&gt;
GRASS GIS <http://grass.osgeo.org>

#2210: unable to start GRASS GIS 7
---------------------+------------------------------------------------------
  Reporter: turek | Owner: grass-dev@…
      Type: defect | Status: reopened
  Priority: normal | Milestone: 7.0.0
Component: Python | Version: svn-trunk
Resolution: | Keywords:
  Platform: Linux | Cpu: x86-64
---------------------+------------------------------------------------------

Comment(by marisn):

Replying to [comment:4 turek]:
> Hi,
>
> I tried r59211, unfortunately, I stil get the same error.
Try r59215. I changed a bit enforcing of locale on GRASS process and also
worked-around gettext on Windows issue (it fails to load default locale
translations as Windows doesn't set LANG by default).

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

#2210: unable to start GRASS GIS 7
---------------------+------------------------------------------------------
  Reporter: turek | Owner: grass-dev@…
      Type: defect | Status: reopened
  Priority: normal | Milestone: 7.0.0
Component: Python | Version: svn-trunk
Resolution: | Keywords:
  Platform: Linux | Cpu: x86-64
---------------------+------------------------------------------------------

Comment(by turek):

Hi,
I still get the same error. Maybe I am doing something wrong however
r59162 works for me:

{{{
ostepok@ostepok-pc:~/Dev/GRASS/grass_wms/grass_trunk/lib/init$ svn up
grass.py
Updating 'grass.py':
U grass.py
Updated to revision 59220.
ostepok@ostepok-pc:~/Dev/GRASS/grass_wms/grass_trunk/lib/init$ make
rm -f /home/ostepok/Dev/GRASS/grass_wms/grass_trunk/bin.x86_64-unknown-
linux-gnu/grass70
sed \
         -e
's#@GISBASE@#/home/ostepok/Dev/GRASS/grass_wms/grass_trunk/dist.x86_64
-unknown-linux-gnu#' \
         -e 's#@GRASS_VERSION_NUMBER@#7.0.svn#' \
         -e 's#@LD_LIBRARY_PATH_VAR@#LD_LIBRARY_PATH#' \
         -e 's#@START_UP@#grass70#' \
         -e 's#@CONFIG_PROJSHARE@#/usr/share/proj/#' \
         grass.py >
/home/ostepok/Dev/GRASS/grass_wms/grass_trunk/bin.x86_64-unknown-linux-
gnu/grass70
chmod +x /home/ostepok/Dev/GRASS/grass_wms/grass_trunk/bin.x86_64-unknown-
linux-gnu/grass70
rm -f /home/ostepok/Dev/GRASS/grass_wms/grass_trunk/dist.x86_64-unknown-
linux-gnu/grass70.tmp
sed \
         -e 's#@GRASS_VERSION_NUMBER@#7.0.svn#' \
         -e 's#@START_UP@#grass70#' \
         -e 's#@GRASS_CONFIG_DIR@##' \
         -e 's#@LD_LIBRARY_PATH_VAR@#LD_LIBRARY_PATH#' \
         -e 's#@CONFIG_PROJSHARE@#/usr/share/proj/#' \
         grass.py >
/home/ostepok/Dev/GRASS/grass_wms/grass_trunk/dist.x86_64-unknown-linux-
gnu/grass70.tmp
ostepok@ostepok-pc:~/Dev/GRASS/grass_wms/grass_trunk/lib/init$
../../bin.x86_64-unknown-linux-gnu/grass70
Cleaning up temporary files...
Starting GRASS GIS...
Traceback (most recent call last):
   File "/home/ostepok/Dev/GRASS/grass_wms/grass_trunk/dist.x86_64-unknown-
linux-gnu/etc/gui/wxpython/gis_set.py", line 37, in <module>
     from core.utils import _
   File "/home/ostepok/Dev/GRASS/grass_wms/grass_trunk/dist.x86_64-unknown-
linux-gnu/etc/gui/wxpython/core/utils.py", line 42, in <module>
     from core.gcmd import RunCommand
   File "/home/ostepok/Dev/GRASS/grass_wms/grass_trunk/dist.x86_64-unknown-
linux-gnu/etc/gui/wxpython/core/gcmd.py", line 744, in <module>
     _enc = GetDefaultEncoding() # define as global variable
   File "/home/ostepok/Dev/GRASS/grass_wms/grass_trunk/dist.x86_64-unknown-
linux-gnu/etc/gui/wxpython/core/gcmd.py", line 737, in GetDefaultEncoding
     enc = locale.getdefaultlocale()[1]
   File "/usr/lib/python2.7/locale.py", line 511, in getdefaultlocale
     return _parse_localename(localename)
   File "/usr/lib/python2.7/locale.py", line 443, in _parse_localename
     raise ValueError, 'unknown locale: %s' % localename
ValueError: unknown locale: None
Error in GUI startup. If necessary, please report this error to the GRASS
developers.
Switching to text mode now.

Hit RETURN to continue...

Unable to create temporary directory </tmp/grass7-ostepok-7579>! Exiting.
ostepok@ostepok-pc:~/Dev/GRASS/grass_wms/grass_trunk/lib/init$ svn up -r
59162 grass.py
Updating 'grass.py':
U grass.py
Updated to revision 59162.
ostepok@ostepok-pc:~/Dev/GRASS/grass_wms/grass_trunk/lib/init$ make
rm -f /home/ostepok/Dev/GRASS/grass_wms/grass_trunk/bin.x86_64-unknown-
linux-gnu/grass70
sed \
         -e
's#@GISBASE@#/home/ostepok/Dev/GRASS/grass_wms/grass_trunk/dist.x86_64
-unknown-linux-gnu#' \
         -e 's#@GRASS_VERSION_NUMBER@#7.0.svn#' \
         -e 's#@LD_LIBRARY_PATH_VAR@#LD_LIBRARY_PATH#' \
         -e 's#@START_UP@#grass70#' \
         -e 's#@CONFIG_PROJSHARE@#/usr/share/proj/#' \
         grass.py >
/home/ostepok/Dev/GRASS/grass_wms/grass_trunk/bin.x86_64-unknown-linux-
gnu/grass70
chmod +x /home/ostepok/Dev/GRASS/grass_wms/grass_trunk/bin.x86_64-unknown-
linux-gnu/grass70
rm -f /home/ostepok/Dev/GRASS/grass_wms/grass_trunk/dist.x86_64-unknown-
linux-gnu/grass70.tmp
sed \
         -e 's#@GRASS_VERSION_NUMBER@#7.0.svn#' \
         -e 's#@START_UP@#grass70#' \
         -e 's#@GRASS_CONFIG_DIR@##' \
         -e 's#@LD_LIBRARY_PATH_VAR@#LD_LIBRARY_PATH#' \
         -e 's#@CONFIG_PROJSHARE@#/usr/share/proj/#' \
         grass.py >
/home/ostepok/Dev/GRASS/grass_wms/grass_trunk/dist.x86_64-unknown-linux-
gnu/grass70.tmp
ostepok@ostepok-pc:~/Dev/GRASS/grass_wms/grass_trunk/lib/init$
../../bin.x86_64-unknown-linux-gnu/grass70
Cleaning up temporary files...
Starting GRASS GIS...
Failed to set LC_ALL to None.UTF-8 (unsupported locale setting)

           __________ ___ __________ _______________
          / ____/ __ \/ | / ___/ ___/ / ____/ _/ ___/
         / / __/ /_/ / /| | \__ \\_ \ / / __ / / \__ \
        / /_/ / _, _/ ___ |___/ /__/ / / /_/ // / ___/ /
        \____/_/ |_/_/ |_/____/____/ \____/___//____/
}}}

Note that I get this warning in r59162:

{{{
Failed to set LC_ALL to None.UTF-8 (unsupported locale setting)
}}}

Rest of source code is in r59220.

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

#2210: unable to start GRASS GIS 7
---------------------+------------------------------------------------------
  Reporter: turek | Owner: grass-dev@…
      Type: defect | Status: reopened
  Priority: normal | Milestone: 7.0.0
Component: Python | Version: svn-trunk
Resolution: | Keywords:
  Platform: Linux | Cpu: x86-64
---------------------+------------------------------------------------------

Comment(by marisn):

I'm not able to reproduce the issue on my system no matter how hard I try.

Still the issue seems to be twofold - there was not robust enough code to
set language/locale in startup script. It is fixed and from r59215 it
should work just fine* The second problem is that now some problems with
other wxgui code have popped-up. I.e. getdefaultlocale shouldn't be used
to get encoding.

Can you, please, apply this patch and give me back output?
{{{
Index: lib/init/grass.py

--- lib/init/grass.py (revision 59254)
+++ lib/init/grass.py (working copy)
@@ -784,7 +784,10 @@
          # Language override is disabled (system language specified)
          # As by default program runs with C locale, but users expect to
          # have their default locale, we'll just set default locale
- locale.setlocale(locale.LC_ALL, '')
+ try:
+ locale.setlocale(locale.LC_ALL, '')
+ except:
+ warning("Setting default locale failed. It indicates
misconfigured system. Check systems locale settings.")
          if windows and os.getenv('LANG') is None:
              language, encoding = locale.getdefaultlocale()
              os.environ['LANG'] = language
@@ -1296,6 +1299,14 @@
  # Subsequent functions are using _() calls and
  # thus must be called only after Language has been set.
  set_language()
+for lc in ('LC_CTYPE', 'LC_MESSAGES', 'LC_TIME', 'LC_COLLATE',
+ 'LC_MONETARY', 'LC_PAPER', 'LC_NAME', 'LC_ADDRESS',
+ 'LC_TELEPHONE', 'LC_MEASUREMENT', 'LC_IDENTIFICATION',
+ 'LANG', 'LANGUAGE', 'LC_ALL'):
+ if lc in os.environ:
+ print "%s = ' %s '" % (lc, os.environ[lc])
+ else:
+ print "%s = unset" % lc

  # Create the temporary directory and session grassrc file
  create_tmp()
}}}

* one of most common misconceptions of all programmers.

--
Ticket URL: <http://trac.osgeo.org/grass/ticket/2210#comment:7&gt;
GRASS GIS <http://grass.osgeo.org>

#2210: unable to start GRASS GIS 7
---------------------+------------------------------------------------------
  Reporter: turek | Owner: grass-dev@…
      Type: defect | Status: reopened
  Priority: normal | Milestone: 7.0.0
Component: Python | Version: svn-trunk
Resolution: | Keywords:
  Platform: Linux | Cpu: x86-64
---------------------+------------------------------------------------------

Comment(by turek):

Hi,

this is the output after the patch was applied:

{{{
ostepok@ostepok-pc:~/Dev/GRASS/grass_wms/grass_trunk$ ./bin.x86_64
-unknown-linux-gnu/grass70
LC_CTYPE = unset
LC_MESSAGES = unset
LC_TIME = unset
LC_COLLATE = unset
LC_MONETARY = unset
LC_PAPER = unset
LC_NAME = unset
LC_ADDRESS = unset
LC_TELEPHONE = unset
LC_MEASUREMENT = unset
LC_IDENTIFICATION = unset
LANG = ' en_US.UTF-8 '
LANGUAGE = unset
LC_ALL = unset
Cleaning up temporary files...
Starting GRASS GIS...
Traceback (most recent call last):
   File "/home/ostepok/Dev/GRASS/grass_wms/grass_trunk/dist.x86_64-unknown-
linux-gnu/etc/gui/wxpython/gis_set.py", line 37, in <module>
     from core.utils import _
   File "/home/ostepok/Dev/GRASS/grass_wms/grass_trunk/dist.x86_64-unknown-
linux-gnu/etc/gui/wxpython/core/utils.py", line 42, in <module>
     from core.gcmd import RunCommand
   File "/home/ostepok/Dev/GRASS/grass_wms/grass_trunk/dist.x86_64-unknown-
linux-gnu/etc/gui/wxpython/core/gcmd.py", line 744, in <module>
     _enc = GetDefaultEncoding() # define as global variable
   File "/home/ostepok/Dev/GRASS/grass_wms/grass_trunk/dist.x86_64-unknown-
linux-gnu/etc/gui/wxpython/core/gcmd.py", line 737, in GetDefaultEncoding
     enc = locale.getdefaultlocale()[1]
   File "/usr/lib/python2.7/locale.py", line 511, in getdefaultlocale
     return _parse_localename(localename)
   File "/usr/lib/python2.7/locale.py", line 443, in _parse_localename
     raise ValueError, 'unknown locale: %s' % localename
ValueError: unknown locale: None
Error in GUI startup. If necessary, please report this error to the GRASS
developers.
Switching to text mode now.

Hit RETURN to continue...

}}}

--
Ticket URL: <http://trac.osgeo.org/grass/ticket/2210#comment:8&gt;
GRASS GIS <http://grass.osgeo.org>

#2210: unable to start GRASS GIS 7
---------------------+------------------------------------------------------
  Reporter: turek | Owner: grass-dev@…
      Type: defect | Status: reopened
  Priority: normal | Milestone: 7.0.0
Component: Python | Version: svn-trunk
Resolution: | Keywords:
  Platform: Linux | Cpu: x86-64
---------------------+------------------------------------------------------

Comment(by marisn):

Can you, please, test after r59652? I added some extra care to the cases
when Python fails to detect default locale. Generally it indicates on some
kind of problem with system's locale.

--
Ticket URL: <http://trac.osgeo.org/grass/ticket/2210#comment:9&gt;
GRASS GIS <http://grass.osgeo.org>

#2210: unable to start GRASS GIS 7
---------------------+------------------------------------------------------
  Reporter: turek | Owner: grass-dev@…
      Type: defect | Status: closed
  Priority: normal | Milestone: 7.0.0
Component: Python | Version: svn-trunk
Resolution: fixed | Keywords:
  Platform: Linux | Cpu: x86-64
---------------------+------------------------------------------------------
Changes (by turek):

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

Comment:

Thanks Maris, great work! It works now. Closing the ticket.

--
Ticket URL: <http://trac.osgeo.org/grass/ticket/2210#comment:10&gt;
GRASS GIS <http://grass.osgeo.org>