Sunday, May 31, 2009

Environment Variable Problem Solved, This Time Fo' Reals

So between Zack and I, we've got the super frustrating environment variable problem solved. Here's a rundown of what was going on, for posterity.

Okay, so basically the issue involved shell variables. It's a little complex.

If you create a variable that doesn't exist yet, and assign a value to it, such as "JAVA_HOME="/opt/jdk1.6.0_10" you create a shell variable. A shell variable, according to the Ubuntu community documentation, " is similar to an environment variable but does not influence the behaviour of other applications." IE, it will exist in the shell, but not in any processes spawned by the shell. Nice, huh? So that explains why echo was working--the variable was in the shell, it was just that ant didn't know about it.

In order to make it available to applications beyond the shell, you actually have to export it, ie,
"export JAVA_HOME="/opt/jdk1.6.0_10""

Now, the reason why restarting worked that one time is that I had defined the environment variables in /etc/environment, which is not actually a script, the way the other files, such as /home/.bashrc and /home/.profile are scripts. Instead, it is a file only of environment variables. Likely, at some point during the boot process, some script goes through that file, line by line, and exports each of those variables. If I had to guess, the exporting script only executes under certain situations, which is why restarting only worked that once.

So. There you have it, friends and neighors. The lesson learned from this is: If you've eliminated something because it "could not possibly" be the cause of the problem, go back and try it, as it likely is the cause of the problem.

I dreamed last night that my brother was sort of kidnapped by Karl Lagerfield. And that everything was flooding and I had to escape on a skateboard. And also that truckers burned shredded cheddar cheese as fuel instead of diesel.