Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
QProcess and environment
tombough last edited by
My question: how can I have a process executed within the user's default bash environment? Currently, if I open a terminal, the correct program launches due to paths exported from .bash_profile. However, this is not the case when executing the command via QProcess. Similarly, if I have aliases under .bash_profile or .bashrc, they are not recognized when executed directly by a process. I have also attempted to launch a shell first and execute the alias within that, but again the alias was not recognized:
where alias foo='/Library/Frameworks/Python.framework/Versions/2.6/bin/python' is defined in .bashrc.
I am using QProcess to launch a python script from within Qt. As the script requires the import of certain modules, I would like to simply call the command 'python' and make it the users responsibility that the correct version of python is called (with other fixes to come later). Solving this will be of use in other projects as well - basically whenever I want to assume a program is installed without hunting for it.
I can't remember offhand, but with using bash in this scenario, do you need to pass in a -i or -l flag? I know bash has rules about which config files are read based on whether it's an interactive, a login, or non-interactive shell. (See man bash for more info.)