3

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.

Tim Post
  • 33,371
  • 15
  • 110
  • 174
user170114
  • 625
  • 6
  • 16
  • 24
  • You need some more clarification here. Should be an easy fix, but there is no debugging information at all in the question post. – dpb Oct 28 '09 at 04:00

2 Answers2

4

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
  • 562,542
  • 136
  • 1,062
  • 1,124
1

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

Michael Aaron Safyan
  • 93,612
  • 16
  • 138
  • 200