Opened 8 years ago

Closed 4 years ago

#3295 closed defect (fixed)

GRASS GIS fails to start without terminal

Reported by: wenzeslaus Owned by: grass-dev@…
Priority: normal Milestone: 8.0.0
Component: Startup Version: unspecified
Keywords: gisset, wxGUI, init, grass.py, nohup, terminal, shell, GUI, CLI, exec, g.gui Cc:
CPU: Unspecified Platform: Linux

Description

On Ubuntu (16.04):

  • Do Ctrl+F2 (window to directly run commands - rather than desktop applications)
  • Type grass
  • Fill the startup screen
  • Start session
  • Start fails

In 7.2 you get error about g.extension (#3253) and trunk you don't get anything (it fails later on).

It is reproducible with nohup:

nohup grass

Using less nohup.out you can get the output which mainly reveals:

ERROR: Variable 'LOCATION_NAME' not set

followed by

Traceback (most recent call last):
  File "/usr/lib/grass72/gui/wxpython/wxgui.py", line 158, in <module>
    sys.exit(main())
  File "/usr/lib/grass72/gui/wxpython/wxgui.py", line 145, in main
    app = GMApp(workspaceFile)
  File "/usr/lib/grass72/gui/wxpython/wxgui.py", line 48, in __init__
...
grass.exceptions.CalledModuleError: [it depends]
Traceback (most recent call last):
  File "/usr/lib/python2.7/atexit.py", line 24, in _run_exitfuncs
    func(*targs, **kargs)
PyAssertionError: C++ assertion "GetEventHandler() == this" failed at ../src/common/wincmn.cpp(478) in ~wxWindowBase(): any pushed event handlers must have been removed
Error in sys.exitfunc:
Traceback (most recent call last):
  File "/usr/lib/python2.7/atexit.py", line 24, in _run_exitfuncs
    func(*targs, **kargs)
wx._core.PyAssertionError: C++ assertion "GetEventHandler() == this" failed at ../src/common/wincmn.cpp(478) in ~wxWindowBase(): any pushed event handlers must have been removed

Workaround which assumes you have some default mapset already:

grass --exec g.gui

Answer to the "What did you expect to happen?" question:

  • GRASS GIS should start using this method as other applications do (e.g. QGIS or Gimp).

Other possible improvements:

  • Message saying that the session is not started instead of "Variable 'LOCATION_NAME' not set"
  • Some temporary location generated for the case where there is not 'last location used' so that grass --exec g.gui (or grass --tmp-loc --exec g.gui) works on a fresh machine (it seems that the demolocation is not part of the Ubuntu distribution)
  • The above point and code packed into just grass. This comes to the discussion about role of location at startup from different side. However, it is pretty far from the core of this ticket which deals with GRASS GIS running without terminal.

Change History (5)

comment:1 by wenzeslaus, 8 years ago

From the nohup case I get the following in the output (as expected, I suppose):

/bin/bash: error reading input file: Bad file descriptor
WARNING: Failed to start shell '/bin/bash'

With the following patch, nohup case actually runs.

  • grass.py

     
    13861386   
    13871387    # Check for gui interface
    13881388    if grass_gui == "wxpython":
    1389         Popen([os.getenv('GRASS_PYTHON'), wxpath("wxgui.py")])
     1389        return Popen([os.getenv('GRASS_PYTHON'), wxpath("wxgui.py")])
     1390    return None
    13901391
    13911392
    13921393def close_gui():
     
    19611962                                            mapset_settings.location)
    19621963
    19631964        # start GUI and register shell PID in rc file
    1964         start_gui(grass_gui)
     1965        gui_process = start_gui(grass_gui)
    19651966        kv = read_gisrc(gisrc)
    19661967        kv['PID'] = str(shell_process.pid)
    19671968        write_gisrc(kv, gisrc)
     
    19681969        exit_val = shell_process.wait()
    19691970        if exit_val != 0:
    19701971            warning(_("Failed to start shell '%s'") % os.getenv('SHELL'))
     1972            # remove shell PID because GUI should not kill it
     1973            kv = read_gisrc(gisrc)
     1974            del kv['PID']
     1975            write_gisrc(kv, gisrc)
     1976            # if there is no shell but GUI is set, wait for that
     1977            if grass_gui != "text":
     1978                gui_process.wait()
    19711979
    19721980        # close GUI if running
    19731981        close_gui()

However, with Ctrl+F2 I still get the same behavior. I don't see anything helpful in the sudo strace -p... -s9999 -e write output (using PID of grass and gis_set.py).

comment:2 by neteler, 7 years ago

Milestone: 7.4.07.4.1

Ticket retargeted after milestone closed

comment:3 by neteler, 6 years ago

Milestone: 7.4.17.4.2

comment:4 by wenzeslaus, 6 years ago

Milestone: 7.4.28.0.0

comment:5 by wenzeslaus, 4 years ago

Resolution: fixed
Status: newclosed

Both cases, Ctrl+F2 and nohup, fixed by PR:768. Open new issues on GitHub in case there are follow up problems.

Note: See TracTickets for help on using tickets.