Having
$ echo $PAPARAZZI_HOME
print the expected value doesn't verify that $PAPARAZZI_HOME
is an environment variable. It could be an unexported shell variable.
If you set it by typing this at your shell prompt:
$ PAPARAZZI_HOME=/home/manish/paprazzi-git/paparazzi/
then it's not an environment variable. Try this:
$ export PAPARAZZI_HOME=/home/manish/paprazzi-git/paparazzi/
and run your program again. or, if you've already assigned a value to it:
$ export PAPARAZZI_HOME
Some older shells, like the original sh
, don't support setting and exporting a variable in one command. If you're using such a shell, you'll need to use two commands to set an environment variable:
$ PAPARAZZI_HOME=/home/manish/paprazzi-git/paparazzi/
$ export PAPARAZZI_HOME
If you're using csh or tcsh, the syntax is different. To set a (non-environment) shell variable:
% set PAPARAZZI_HOME = /home/manish/paprazzi-git/paparazzi/
To set an environment variable:
% setenv PAPARAZZI_HOME /home/manish/paprazzi-git/paparazzi/
In csh and tcsh, shell variables and environment variables are not as closely tied as they are in sh, ksh, bash, zsh, et al; there's no direct way (like the export
command) to change an existing shell variable to an environment variable. And you can have a shell variable and an environment variable with the same name, in which case $PAPARAZZI_HOME
would expand to the value of the shell variable. If you're using bash, you can safely ignore this paragraph.
Another possibility is that your program is being launched in such a way that it doesn't inherit your shell's environment. If you launch the program from the IDE or from some other GUI, it won't inherit environment variables you set in your shell -- unless you launched the IDE or GUI from that shell, and after setting the environment variable. Since you're on Ubuntu, try launching your application by typing its full path at your shell prompt.
Oh, and you probably don't need the trailing /
.
** UPDATE :**
After a lengthy discussion in chat, it turns out that the OP is invoking his program using sudo
, because it needs root privileges.
sudo
, by default, removes most environment variables.
You can ask it to preserve your environment by using sudo -E
. man sudo
for details.
It's not clear that sudo -E
is the best solution; it may have security implications.
If the program only needs that one environment variable, then this:
$ sudo env PAPARAZZI_HOME=/home/manish/paprazzi-git/paparazzi /path/to/the/program