1

I'm upgrading to maven 3 but have hit a small snag in that maven 2 is mysteriously showing up in my PATH variable. I've checked ~/.bashrc, ~/.profile, /etc/bash.bashrc, /etc/environment, /etc/profile and can't find it anywhere. What am I missing?

heemayl
  • 91,753
Chris
  • 133
  • 1
  • 6
  • Did you install both versions locally? whats the output of echo "$PATH" ? how did you find it in your path? – heemayl May 07 '15 at 23:50
  • /home/elpinguino/scala-2.10.5/bin:/home/elpinguino/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/opt/apache-maven-2.2.1/bin:/bin:/bin:/opt/apache-maven-3.3.3/bin – Chris May 07 '15 at 23:51
  • well that sums up the answer..you have installed both locally....you have two options 1)you can either remove the maven-2 installation directory completely by sudo rm -r /opt/apache-maven-2.2.1 or 2)remove /opt/apache-maven-2.2.1/bin from PATH. Which one do you want? – heemayl May 07 '15 at 23:54
  • Ideally both. I wish I could find where I was setting /opt/apache-maven-2.2.1 in my path. – Chris May 07 '15 at 23:54
  • You mean the file where you have put the PATH? – heemayl May 07 '15 at 23:59
  • Yeah. For what it's worth removing the old maven 2 fixes the issue but somewhere out there a file is adding it to the PATH. The files I listed above do not contain this addition. – Chris May 08 '15 at 00:01
  • Do you have ~/.bash_profile or ~/.bash_login. If so , check them – heemayl May 08 '15 at 00:02

1 Answers1

0

From man bash:

When bash is invoked as an interactive login shell, or as a non-inter‐ active shell with the --login option, it first reads and executes com‐ mands 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.

As you have logged into an interactive non-login shell, the files to look for the PATH assignment is /etc/bash.bashrc, ~/.bashrc and also in /etc/environment as its the default place to declare system wide environment variables. You should also check the directories that are sourced while logging into an interactive login shell to be sure that there is no reference or pointer to change PATH in them.

If you does not find any reference to PATH having maven-2 then there must be something in one of these files that is causing the PATH to be changed i.e. something in one of these files triggering something else that is changing the PATH. It is very hard to tell without checking the content of the files.

If you want to remove maven-2 from your PATH:

/home/elpinguino/scala-2.10.5/bin:/home/elpinguino/bin:/usr/local/sbin
:/usr/loca‌​l/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games
:/opt/apache-maven‌​-2.2.1/bin:/bin:/bin:/opt/apache-maven-3.3.3/bin 

You can either remove the directory /opt/apache-maven‌​-2.2.1 so that PATH won't find the executable or declare PATH environment variable again discarding the /opt/apache-maven‌​-2.2.1/bin directory and putting it at the end of ~/.bashrc.

heemayl
  • 91,753