tags:

views:

753

answers:

2

Hi. I tried setting the Maven PATH in .profile file as well using export commands in terminal(Mac OSX). But, on running mvn commands, getting -bash: mvn: command not found

Please help.

A: 

Have you installed Maven, already? If you use MacPorts to install Maven, you won't need to edit your PATH.

Michael Aaron Safyan
+1  A: 

What did you set up exactly? Did you setup PATH like this (or something equivalent):

export PATH=$PATH:...:$M2_HOME/bin

If yes, did you logout and login again? According to the bash manpage:

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.

As you can see, commands from .profile are not executed for a non-login shell (the type of shells you open after logging in). So you have to logout/login or to source the file manually to take your setup into account. See this blog post for more details.

Pascal Thivent
On Mac OS X, the Terminal executes "login -fp $USER" on startup.
Michael Aaron Safyan
So, you only need to close and reopen the Terminal.
Michael Aaron Safyan
Ah, good to know. I'm not a mac user, I didn't know "normal" shells were login shells on mac. But indeed, closing and reopening a terminal should then do the trick. I'd like to see the output of `echo $PATH` though.
Pascal Thivent