PDA

View Full Version : Set system $PATH in running environment



rno
29th May 2012, 22:38
Hi,

My project is a gui for a command line program. The gui needs to find in the path the command line program.

If I go to Project > Run Settings > Run Environment and the scroll down to PATH I can add ':/the path to the command line program' and it works.

But what I want is for my gui to use the system $PATH variable when running.

I cannot firgure out how to add the system $PATH to the Run Environment PATH. I tried to add :$PATH or :$(PATH) or :${PATH} none seems to work. Would someone know how to add the system $PATH to the already define PATH in the Run Environment?

Cheers,
Rno

ChrisW67
30th May 2012, 00:25
Assuming you are using Qt Creator then:

Go to Project, Run Settings.
Expand the block headed "Run Environment".
Find the combo box labelled "Base configuration for the run configuration".
Drop down the list and select "System Environment".
Do not change anything in the environment it shows you.

rno
30th May 2012, 18:26
Hi ChrisW67,

Thanks but it does not work. So far the only way is to give the path to the command line program. I really would like to give the system path variable to Qt creator.

wysota
30th May 2012, 18:53
The system path is always available to any running program. What QtCreator shows you in its settings is the system path.

rno
31st May 2012, 19:08
Well maybe I am not understanding what the system path is.

Qt creator shows this:

Path is set to /usr/lib/lightdm/lightdm:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games

When starting a terminal and doing
echo $PATH
/home/CAMPUS/Software/32bits/imagic//openmpi/bin:/home/CAMPUS/Software/32bits/XRayView-linux/:/home/CAMPUS/Software/32bits/XDS-IA32_Linux_x86:/home/CAMPUS/Software/64bits/usf:/home/CAMPUS/Software/32bits/solve-2.13/bin:/home/CAMPUS/Software/32bits/shelx_linux:/home/CAMPUS/Software/32bits/sharp-2.6/adm/bin:/home/CAMPUS/Software/32bits/Situs_2.6.3/bin://home/CAMPUS/Software/32bits/rosetta/rosetta_source/bin:/home/CAMPUS/Software/32bits/phenix/phenix-1.7.2-869/build/intel-linux-2.6/bin:/home/CAMPUS/Software/32bits/o/:/usr/local/xtal/ActiveTcl-8.4/bin:/usr/local/xtal/hkl2000:/home/CAMPUS/Software/32bits/fasta/fasta-35.4.1/bin:/home/CAMPUS/auth/xtal/EMAN2/bin:/home/CAMPUS/Software/32bits/chimera/bin:/home/CAMPUS/Software/32bits/ccp4/ccp4-6.2.0/src/phaser/phaser-2.3.0/build/intel-linux/bin:/home/CAMPUS/Software/32bits/ccp4/graphviz-2.20.2/bin:/home/CAMPUS/Software/32bits/ccp4/fasta-35.4.1/bin:/home/CAMPUS/Software/32bits/ccp4/clustalw-2.0.9/bin:/home/CAMPUS/Software/32bits/ccp4/ccp4-6.2.0//bin:/home/CAMPUS/Software/32bits/ccp4/ccp4-6.2.0/share/dbccp4i/bin:/home/CAMPUS/Software/32bits/ccp4/ccp4-6.2.0/ccp4i/bin:/home/CAMPUS/Software/32bits/ccp4/ccp4-6.2.0/etc:/home/CAMPUS/Software/32bits/Autoproc32/autoPROC/bin/linux:/usr/lib/lightdm/lightdm:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/home/CAMPUS/Software/32bits/ccp4/ccp4-6.2.0/share/xia2/xia2core//Test:/home/CAMPUS/Software/32bits/ccp4/ccp4-6.2.0/share/xia2/xia2//Applications:/home/CAMPUS/Software/32bits/em2em:.

So it is not the same at all...:confused:

wysota
31st May 2012, 21:01
The terminal might have a different content of environment variables. That's how environment variables work. If you start Creator from within this exact terminal and reset the variables like Chris told you, Creator will inherit PATH from its parent process.

rno
31st May 2012, 22:10
I was starting creator from kde menu.
Starting from the terminal make it works.
Thanks a lot.:)

wysota
31st May 2012, 22:52
So the bottom line is that it is your terminal that has a different PATH than the "system PATH" (since KDE defines your system environment).