Important: Please read the Qt Code of Conduct -

HOWTO set the HOME environment variable when debugging on target

  • I am launching an application for debug on an RPi target from a Linux x86-64 host, via QtCreator. Strangely, the HOME env variable does not get set when debugging. As a result, reads from QSettings etc fail because the application is trying to read from an incorrect location. (When running normally without debugging, the environment gets set correctly).

    From here: it should be possible to add "GDB commands after GDB has been started, but before the debugged program is started or attached" in the "Additional startup commands" field in Project settings. I tried adding the following:

    set environment HOME = /home/pi
    set environment FOO = /home/pi

    and printing out the vars from my application, and FOO gets printed out correctly, but HOME is still empty. I can force HOME to get set via qputenv and that works. But I'd like to avoid doing that if possible. So my questions are:

    1. Why does the gdb environment setting not work for the HOME variable?
    2. Is there an environment variable that gets set only when debugging so I can at least qualify the qputenv with that? (i.e. perform the qputenv of HOME only when the app is being debugged).

Log in to reply