ulfalizer / Kconfiglib

A flexible Python 2/3 Kconfig implementation and library
ISC License
456 stars 161 forks source link

menuconfig cannot startup #64

Closed swordligit closed 5 years ago

swordligit commented 5 years ago

When start up the menuconfig, something goes wrong.Here is the trace-back:

Using existing configuration './.config' as base Traceback (most recent call last): File "/usr/lib/python3.6/curses/init.py", line 78, in wrapper cbreak() _curses.error: cbreak() returned ERR

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "../../scripts/kconfig/menuconfig.py", line 3038, in _main() File "../../scripts/kconfig/menuconfig.py", line 601, in _main menuconfig(standard_kconfig()) File "../../scripts/kconfig/menuconfig.py", line 680, in menuconfig print(curses.wrapper(_menuconfig)) File "/usr/lib/python3.6/curses/init.py", line 100, in wrapper nocbreak() _curses.error: nocbreak() returned ERR make[2]: [menuconfig] Error 1 make[1]: [menuconfig] Error 2

Some hints: 1,if just input "make menuconfig", it works, if add any other words in the command line, like "make menuconfig V=1", it went wrong, very strange. 2, have tried some terminal, like xterm, sakura, the problem is the same. So I upgrade the Ubuntu from 1604 to 1804(not reinstalled 1804, just upgraded the system from ubuntu's app). the problem still exists. There maybe something wrong with my terminal, but don't know the real cause;

ulfalizer commented 5 years ago

It's some problem with how menuconfig.py is run. Check that the Makefile isn't running it in the background or with stdin/stdout connected to some weird place.

Could try running this test program instead of menuconfig.py. Might help narrow the problem down.

import curses

def fn(stdscr):
    stdscr.clear()
    stdscr.addstr(0, 0, "curses test")
    stdscr.refresh()
    curses.napms(1000)

curses.wrapper(fn)
swordligit commented 5 years ago

Seems the test scripts run ok, it wil prompt a window says 'curse test', and then exit the window to the shell normally.

ulfalizer commented 5 years ago

@swordligit What does the Make recipe that runs menuconfig.py look like?

swordligit commented 5 years ago

Here it is:

` menuconfig:$(HV_OBJDIR)/$(HV_CONFIG)

     @echo "menuconfig"

     python3 $(KCONFIG_DIR)/menuconfig.py Kconfig

`

$(HV_OBJDIR)/$(HV_CONFIG) is .config

I think there maybe something wrong with the environment, if just run the "make menuconfig", it is ok, if add any other words(like make menuconfig V=1), it fails. seem some thing was dumped into the curse.

ulfalizer commented 5 years ago

Could add an env > environ to the Makefile before running menuconfig.py, and then run it manually with env - $(cat environ) python3 menuconfig.py and see if you get the same error.

If you still get the same error, remove environment variables from environ until it starts working. That'll help narrow it down.

swordligit commented 5 years ago

Reinstall the Ubuntu and the issue has gone. so close the ticket, if there are other issues I will let you know, thanks a lot.

karlp commented 9 months ago

FIX/Workaround: Ninja is getting in the way.... somehow...

Broken

export CMAKE_GENERATOR=Ninja && make menuconfig

Working

export CMAKE_GENERATOR="Unix Makefiles" && make menuconfig

I'm still getting this on fedora 38.

The invocation is... not my choice, I'm seeing if it can be unwound, but it works for some people, not for others.

cmake --preset release
cmake --build --preset-release --target menuconfig

which in turn is coming from...

    add_custom_target(
        menuconfig
        COMMENT "Run menuconfig"
        COMMAND ${CMAKE_COMMAND} -E env KCONFIG_CONFIG=${KCONFIG_CONFIG}
                ${PYTHON} ${MENUCONFIG_TOOL}
        WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
    )

yes, this is... more convoluted than one would think necessary... MENUCONFIG_TOOL above is Kconfiglib/menuconfig.py

Now, unfortunately, I can run this by hand quite happily...

cmake -E env KCONFIG_CONFIG=.config python Kconfiglib/menuconfig.py

So... I've tried the trick above, saving the environ, and running it by hand that way..

$ env - $(cat kenviron) python ../tools/Kconfiglib/menuconfig.py
env: ‘--no-print-directory’: No such file or directory

ok.. that actually seems to be a problem with "env" loading, but that's ok, I can remove the MAKEFLAGS= --no-print-directory (with an extra space) and run it again, and ... it works still.

So... Something, somewhere is still giving some sort of extra environment, or something.

Reference: my particular error:

Loaded configuration '.config'
Traceback (most recent call last):
  File "/usr/lib64/python3.11/curses/__init__.py", line 78, in wrapper
    cbreak()
_curses.error: cbreak() returned ERR

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/karlp/src/ceres/tools/Kconfiglib/menuconfig.py", line 3278, in <module>
    _main()
  File "/home/karlp/src/ceres/tools/Kconfiglib/menuconfig.py", line 663, in _main
    menuconfig(standard_kconfig(__doc__))
  File "/home/karlp/src/ceres/tools/Kconfiglib/menuconfig.py", line 732, in menuconfig
    print(curses.wrapper(_menuconfig))
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib64/python3.11/curses/__init__.py", line 100, in wrapper
    nocbreak()
_curses.error: nocbreak() returned ERR
ninja: build stopped: subcommand failed.
make: *** [../cmake/Makefile.default:65: menuconfig] Error 1

Annnnnnd eventually that gave me the lead that Ninja is the culprit here.