views:

200

answers:

4

Whenever I open a Bash shell, my classpath is "someProgram". I know that adding an export entry to ".bashrc" changes my classpath, but I want to know where "someProgram" is being added to the classpath (it's not in ".bashrc").

Is there a way to track down where this is being set, or some typical spots I should be checking besides ".bashrc"?

Details:

I'm using Ubuntu 9.10.

Eclipse Version: 3.5.1 is installed.

echo $SHELL
/bin/bash

java -version
java version "1.6.0_0"
OpenJDK Runtime Environment (IcedTea6 1.6.1) (6b16-1.6.1-3ubuntu1)
OpenJDK Server VM (build 14.0-b16, mixed mode)

javac -version
javac 1.6.0_15

More details if requested.

Checked:

  • ~/.bashrc
  • /etc/profile
  • /etc/profile.d/*
  • ~/.bash_profile (not present)
  • ~/.bash_login (not present)
  • ~/.profile
  • /etc/bash.bashrc

Found!

/etc/environment

+1  A: 

in the file /etc/profile.

Geln Yang
Thanks for the suggestion. I checked the "/etc/profile" file and the files in "/etc/profile.d", but the classpath isn't changed there.
Nimnio
+1  A: 

The answer depends on where bash reads the profile from. A well-explained answer is here. An excerpt:


When bash is invoked as an interactive login shell, or as a non-interactive shell with the --login option, it first reads and executes commands from the file /etc/profile, if that file exists. After reading that file, it looks for ~/.bash_profile, ~/.bash_login, and ~/.profile, in that order, and reads and executes commands from the first one that exists and is readable. The --noprofile option may be used when the shell is started to inhibit this behavior. ... When an interactive shell that is not a login shell is started, bash reads and executes commands from /etc/bash.bashrc and ~/.bashrc, if these files exist. This may be inhibited by using the --norc option. The --rcfile file option will force bash to read and execute commands from file instead of /etc/bash.bashrc and ~/.bashrc.


Amit Kumar
Thanks, Amit. I checked the files listed in the excerpt, but the classpath wasn't being changed in those files.
Nimnio
+1  A: 

Recheck all of those files to see if they source any other files using the "." builtin command.

Stephen C
Thanks for the suggestion, Stephen. I'll check when I get home tonight.
Nimnio
+1  A: 

Ah yes, the whackamole process of finding which startup file is sourced where. I propose brute forcing it, try:

$ grep CLASSPATH .?*
$ grep -r CLASSPATH --binary-files=without-match /etc/ 2>/dev/null
wds
"When in doubt, use brute force." ~ Butler Lampson.Thanks for the good suggestion, wds: I'll try it soon, and Stephen's, too. (I'm a programmer by trade, so I usually don't feel like debugging when I get home, but I do appreciate everyone's help.)
Nimnio
It was in /etc/environment. Nice grepping, wds!
Nimnio
We're programmers for a reason aren't we. :-) Glad I could be of help.
wds
I work mostly in Windows, where using the built-in search tool isn't a troubleshooting step: it's an act of desperation.
Nimnio