Getting -bash: mvn: command not found

放肆的年华 提交于 2019-12-07 12:35:02

问题


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.


回答1:


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.




回答2:


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



来源:https://stackoverflow.com/questions/1606174/getting-bash-mvn-command-not-found

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!