Opened 11 years ago

Closed 11 years ago

#2210 closed defect (fixed)

unable to start GRASS GIS 7

Reported by: turek Owned by: grass-dev@…
Priority: normal Milestone: 7.0.0
Component: Python Version: svn-trunk
Keywords: Cc:
CPU: x86-64 Platform: Linux

Description

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...

Change History (10)

comment:1 by marisn, 11 years ago

Please, provide output of following commands:

locale (outside of GRASS and inside GRASS session)
locale -a
grep language ~/.grass7/wx

comment:2 by turek, 11 years ago

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

comment:3 by marisn, 11 years ago

Resolution: fixed
Status: newclosed

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.

comment:4 by turek, 11 years ago

Resolution: fixed
Status: closedreopened

Hi,

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

in reply to:  4 comment:5 by marisn, 11 years ago

Replying to 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).

comment:6 by turek, 11 years ago

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.

comment:7 by marisn, 11 years ago

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.

comment:8 by turek, 11 years ago

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...

comment:9 by marisn, 11 years ago

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.

comment:10 by turek, 11 years ago

Resolution: fixed
Status: reopenedclosed

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

Note: See TracTickets for help on using tickets.