Question:

➜ ~ mvn

zsh: command not found: mvn

Answer:

step 1:
vim ~/.zshrc
step 2:(Add at the end of the file)
source ~/.bash_profile;
step 3:(Execution shell)
> source ~/.bash_profile

You can use mvn :

➜  / mvn

[INFO] Scanning for projects...
.......
Answer from sunmeilinbbs on Stack Overflow
🌐
JetBrains
intellij-support.jetbrains.com › hc › en-us › community › posts › 360010047820-zsh-command-not-found-mvn
zsh: command not found: mvn – IDEs Support (IntelliJ Platform) | JetBrains
I installed maven on my mac and it returns the mvn -version as 3.6.3. I installed maven, maven helper, maven runner, maven test support plugin, maven dependency helper etc., But the problem is when I run mvn -version, it returns zsh: command not found: mvn and when I click on maven tab on the right side vertical bar to run maven life cycle commands, the tab simply vanishes from the IDE until I restart the IDE.
Discussions

macos - Maven commands resuting in Killed: 9 on MAC OS - Stack Overflow
WIN201-S9L:psg 201$ mvn -version Killed: 9 WIN201-S9L:psg 201$ sudo mvn -version Password: Apache Maven 3.5.4 (1edded0938998edf8bf061f1ceb3cfdeccf443fe; 2018-06-18T00:03:14+05:30) Maven home: /Lib... More on stackoverflow.com
🌐 stackoverflow.com
January 13, 2021
Maven command not found on mac sonoma - Stack Overflow
I am new to mac os. I am using zsh as terminal and I have this in my .zprofile · export M2_HOME="/Users/myUser/apache-maven-3.6.3" PATH="${M2_HOME}/bin:${PATH}" export PATH eval "$(/opt/homebrew/bin/brew shellenv)" ... but the command mvn could not be found. More on stackoverflow.com
🌐 stackoverflow.com
macos - Mac command line: zsh: command not found: mvn - Stack Overflow
I installed maven in /Users/chenmin/software/apache-maven-3.6.3, and when I type cat ~/.bash_profile, it returns: export PATH=$PATH:/Users/chenmin/software/apache-maven-3.6.3/bin export PATH=${PATH... More on stackoverflow.com
🌐 stackoverflow.com
Mac os server - zsh killed ./ManagerServer
Hello all, I’ve installed the arm server version for mac and tried to opened in via terminal, but nothing worked, i also disabled the unverified developers in the setting and using the command: sudo spctl --master-disable after running ./ManagerServer it gives me this zsh: killed ./ManagerServer ... More on forum.manager.io
🌐 forum.manager.io
13
0
February 10, 2024
🌐
Apple Community
discussions.apple.com › thread › 254967682
zsh: killed - Apple Community
I don't think its a mac os bug ... since mac os 13 and now the current version is 14.4. 384 1 ... You could try temporarily rename th ~/.zprofile, quit and restart Terminal, open a new window and see if the problem persists. If it does, you can put the file back.
🌐
Code2care
code2care.org › home › howto › [error] zsh: command not found: mvn
[Error] zsh: command not found: mvn | Code2care
January 26, 2026 - If you get mvn command not found when you run a maven command on macOS or any bash terminal then you have not set the PATH for maven home. You need to locate where Apache Maven got installed on your device, on my macOS Big Sur it got installed ...
🌐
Stack Overflow
stackoverflow.com › questions › 65704643 › maven-commands-resuting-in-killed-9-on-mac-os
macos - Maven commands resuting in Killed: 9 on MAC OS - Stack Overflow
January 13, 2021 - WIN201-S9L:psg 201$ mvn -version Killed: 9 WIN201-S9L:psg 201$ sudo mvn -version Password: Apache Maven 3.5.4 (1edded0938998edf8bf061f1ceb3cfdeccf443fe; 2018-06-18T00:03:14+05:30) Maven home: /Library/apache-maven-3.5.4 · For some reason mvn command works with sudo and result in "Killed: 9" without sudo. I am new to mac PC Cataline not sure what could be the issue?
🌐
Medium
medium.com › @fraycs › how-to-solve-zsh-killed-on-macos-ventura-5c1b01d1ed8a
How to solve zsh: killed on MacOS Ventura | by Sebastían Pulido | Medium
February 1, 2023 - #if you have something like this in your .zshrc export PATH="$HOME/bin:/usr/local/bin:$PATH" # just comment out that line by adding a # at the beginning # export PATH="$HOME/bin:/usr/local/bin:$PATH" # if you have this message # MacPorts Installer addition on 2022-07-12_at_22:37:02: adding an appropriate $ export PATH=/opt/local/bin:/opt/local/sbin:$PATH # Finished adapting your PATH environment variable for use with MacPorts.
Find elsewhere
🌐
Manager Forum
forum.manager.io › t › mac-os-server-zsh-killed-managerserver › 51630
Mac os server - zsh killed ./ManagerServer - Manager Forum
February 10, 2024 - Hello all, I’ve installed the arm server version for mac and tried to opened in via terminal, but nothing worked, i also disabled the unverified developers in the setting and using the command: sudo spctl --master-disable after running ./ManagerServer it gives me this zsh: killed ./ManagerServer ...
🌐
Super User
superuser.com › questions › 1830280 › default-shell-zsh-but-responding-bin-bash
linux - Default shell zsh but responding bin/bash - Super User
February 14, 2024 - I'm definitely in the wrong place as I was able to return mvn -v with a version and now it's saying mvn isn't found. ... That message indicates you are running bash (it's trying to talk you into switching to zsh).
🌐
Reddit
reddit.com › r/youtubedl › "zsh: killed" error immediately after every command on m1 macbook
r/youtubedl on Reddit: "ZSH: Killed" Error immediately after every command on M1 MacBook
February 11, 2021 -

Hi, I'm pretty new to homebrew and the whole command line thing on the Mac, so please be kind ;) Every time I try to use YouTube-DL this happens:

youtube-dl --verbose "https://www.youtube.com/watch?v=lKeUCkBO8QA" zsh: killed youtube-dl --verbose "https://www.youtube.com/watch?v=lKeUCkBO8QA"

I spend hours googling for help, but I couldn't find anything. Can someone please explain to me what's going on there and wtf is killing that process?

Btw I got Vidl installed also.

🌐
Apple Community
discussions.apple.com › thread › 254910900
Terminal zsh:killed - Apple Community
June 7, 2023 - I don't know what macOS sets for a default, but nothing would be better at this point. Delete it and research how to customize it for what you need. ... The shell is still telling you that you have not entirely setup the Zsh shell yet. However, the first thing I would remove would be that homebrew eval statement in your ~/.zshrc file.
🌐
DigitalOcean
digitalocean.com › community › tutorials › install-maven-mac-os
How to Install Maven on macOS | DigitalOcean
September 25, 2025 - Maven home: /opt/homebrew/Cellar/maven/3.9.11/libexec Java version: 17.0.8, vendor: Homebrew, runtime: /opt/homebrew/Cellar/openjdk@17/17.0.8/libexec/openjdk.jdk/Contents/Home Default locale: en_US, platform encoding: UTF-8 OS name: "mac os x", version: "14.2.1", arch: "aarch64", family: "mac" If you see an output similar to this, Maven is already installed, and you can proceed to Step 5 — Testing Maven with a Sample Project to verify its functionality. If the command returns zsh: command not found: mvn or a similar message, Maven is not installed or not configured in your system’s PATH.
🌐
Mkyong
mkyong.com › home › java › maven $java_home is not defined correctly on mac os
Maven $JAVA_HOME is not defined correctly on Mac OS - Mkyong.com
January 19, 2021 - $ mvn -version Error: JAVA_HOME is not defined correctly. We cannot execute /usr/libexec/java_home/bin/java · Further Reading How to set $JAVA_HOME environment variable on macOS · On macOS 10.15 Catalina and later, the default Terminal shell is zsh.
Top answer
1 of 9
85

Try following these if these might help:

Since your installation works on the terminal you installed, all the exports you did, work on the current bash and its child process. but is not spawned to new terminals.

env variables are lost if the session is closed; using .bash_profile, you can make it available in all sessions, since when a bash session starts, it 'runs' its .bashrc and .bash_profile

Now follow these steps and see if it helps:

  1. type env | grep M2_HOME on the terminal that is working. This should give something like

    M2_HOME=/usr/local/apache-maven/apache-maven-3.1.1

  2. typing env | grep JAVA_HOME should give like this:

    JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.7.0_40.jdk/Contents/Home

Now you have the PATH for M2_HOME and JAVA_HOME.

If you just do ls /usr/local/apache-maven/apache-maven-3.1.1/bin, you will see mvn binary there. All you have to do now is to point to this location everytime using PATH. since bash searches in all the directory path mentioned in PATH, it will find mvn.

  1. now open .bash_profile, if you dont have one just create one

    vi ~/.bash_profile

Add the following:

#set JAVA_HOME
JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.7.0_40.jdk/Contents/Home
export JAVA_HOME


M2_HOME=/usr/local/apache-maven/apache-maven-3.1.1
export M2_HOME

PATH=$PATH:$JAVA_HOME/bin:$M2_HOME/bin
export PATH
  1. save the file and type source ~/.bash_profile. This steps executes the commands in the .bash_profile file and you are good to go now.

  2. open a new terminal and type mvn that should work.

2 of 9
69

Solutions above are good but they require ~/.bash_profile. /usr/local/bin is already in the $PATH and it can be confirmed by doing echo $PATH. Download maven and run the following commands -

$ cd ~/Downloads
$ tar xvf apache-maven-3.5.3-bin.tar.gz
$ mv apache-maven-3.5.3 /usr/local/
$ cd /usr/local/bin
$ sudo ln -s ../apache-maven-3.5.3/bin/mvn mvn
$ mvn -version
$ which mvn

Note: The version of apache maven would be the one you will download.

🌐
Apple Community
discussions.apple.com › thread › 254560637
New MacosVentura 13.1 installed killed zsh
January 16, 2023 - Mac M1 Terminal not working Properly I recently updated my mac os to 13.01. Now, terminal is not working properly. zsh killed ls, mkdir. I tried changing to bash as well same error comes up. I thought my homebrew got some problem and tried to uninstall the app but i could not it says "Unable to create temp dir '/tmp/uninstall.2615' ".
🌐
Super User
superuser.com › questions › 1793132 › zsh-killed-in-terminal
macos - zsh: killed in Terminal - Super User
July 2, 2023 - This is most likely due to macOS attribute flags protecting the user from running a binary in a protected folder, and/or due to permission setting on that binary. You can inspect the binary's attributes with xattr -laF@ and you'll likely see ...
🌐
Medium
medium.com › @rajeshmuthusamy › maven-setup-with-mac-and-visual-studio-code-4622bd5d9fe4
Maven Setup with Mac and Visual Studio Code | by Rajesh Muthusamy | Medium
April 14, 2023 - It’s possible that Visual Studio Code is not using the same shell as your Mac terminal. For example if you are using zsh shell, then the mvn might not be recognised inside visual studio code.
🌐
Apple Community
discussions.apple.com › thread › 255154958
zsh killing some commands but not others - Apple Community
September 26, 2023 - Below image is what is seen on overall all the different versions Did a search on other platforms to find out what is the possible reason but this has lead to another road block. found that the .bash_profile / .zsh_profile is corrupted or deleted from the system.