Here I put the final solution. I tried many methods on my mac M1, the best method is re-install homebrew.

Step1:

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/uninstall.sh)"

Step2: Install homebrew

cd /opt 
mkdir homebrew # if not exist, just create one.
curl -L https://github.com/Homebrew/brew/tarball/master | tar xz --strip 1 -C homebrew

Then, the problem solved.

Answer from Frank on Stack Overflow
Discussions

Terminal zsh:killed - Apple Community
When I open Terminal the first I see is: zsh: killed mkdir -m 700 -p "$SHELL_SESSION_DIR" Whenever i try to run a command the same problem occurs: Desktop % ls zsh: killed ls It happened after I was trying to install mongoDB I've checked my system's resources and there doesn't seem to be any ... More on discussions.apple.com
🌐 discussions.apple.com
June 7, 2023
macos - ZSH Killed my executable file in mac m1 while running the iOS project using script - Ask Different
ZSH Killed my executable file in mac m1 machine. I am using the mac m1 machine to run my iOS project. Here while running the app it gets killing my executable script in the m1 machine. I have fastl... More on apple.stackexchange.com
🌐 apple.stackexchange.com
November 5, 2021
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
zsh: killed - Apple Community
I'm encountering an issue on macOS where I'm getting an error "zsh: killed". More on discussions.apple.com
🌐 discussions.apple.com
🌐
GitHub
github.com › pocketbase › pocketbase › discussions › 5168
zsh: killed ./app · pocketbase/pocketbase · Discussion #5168
July 3, 2024 - By googling zsh: killed this seems to be a common issue and could be returned for a lot of reasons, including permission issues or missing C tooling dependencies if you have CGO_ENABLED=1 by default.
Author   pocketbase
🌐
Apple Community
discussions.apple.com › thread › 254910900
Terminal zsh:killed - Apple Community
June 7, 2023 - zsh: killed mkdir -m 700 -p "$SHELL_SESSION_DIR" Hello! I am in dire need of some assistance with my Mac. I was able to install it onto it through brew and was able to use it. My Mac just updated to the Ventura 13.4.1 (22F82). This happened Wednesday July 12th.
🌐
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"
🌐
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 ...
Find elsewhere
🌐
GitHub
github.com › go-swagger › go-swagger › issues › 3171
zsh: killed · Issue #3171 · go-swagger/go-swagger
February 22, 2025 - For some reason, SIP is killing him. It's not obvious, and I only noticed it when I started looking for difference between manual build and release version (because binary from release works).
Author   go-swagger
🌐
Super User
superuser.com › questions › 1793132 › zsh-killed-in-terminal
macos - zsh: killed in Terminal - Super User
July 2, 2023 - After trying to install mongoDB on macOS Ventura, I'm getting error zsh: killed. When I open Terminal, I see: zsh: killed mkdir -m 700 -p "$SHELL_SESSION_DIR" Whenever I try to run a com...
🌐
Apple Community
discussions.apple.com › thread › 255154958
zsh killing some commands but not others - Apple Community
September 26, 2023 - Last login: Mon Sep 25 19:02:09 on ttys000 zsh: killed mkdir -m 700 -p "$SHELL_SESSION_DIR" zsh: killed
🌐
Image.sc
forum.image.sc › usage & issues
Update ZSH killed during training - Usage & Issues - Image.sc Forum
September 28, 2023 - I posted here a little while ago regarding the ZSH killed issue I’ve been experiencing. I tried erasing the program, environment, really everything associated with DLC and trying again. I’m still running into some issues, at about iteration ~3500 the program returns: zsh: killed python -m deeplabcut I’m provided with this traceback when restarting as well: Traceback (most recent call last): File "/Users/jakeziegler/Desktop/deeplabcut/DeepLabCut/deeplabcut/gui/tabs/train_network.py", lin...
🌐
Apple Community
discussions.apple.com › thread › 254010763
“zsh: killed” — problem in shell, or my o… - Apple Community
July 1, 2022 - The answer by MrHoffman made sense, and indeed I found 8 year old command in my .zshrc apparently left over from an old project. As MrHoffman suggested I: closed Terminal, set aside the old zsh dot files (.zshrc, .zprofile, and .zlogin), and relaunched Terminal.
🌐
GitHub
github.com › anomalyco › opencode › issues › 8381
zsh: killed opencode -version · Issue #8381 · anomalyco/opencode
January 14, 2026 - Description zsh: killed opencode -version Plugins No response OpenCode version 1.1.9 Steps to reproduce No response Screenshot and/or share link No response Operating System No response Terminal No response
Author   anomalyco
🌐
YouTube
youtube.com › watch
How to Resolve zsh: killed code . Command Issue on MacOS M1 Chip - YouTube
Resolve the frustrating `zsh: killed code .` command issue on MacOS Monterey machines, especially for Visual Studio Code users. Follow our step-by-step guide...
Published   April 15, 2025
Views   7
🌐
Reddit
reddit.com › r/rust › rust binary terminates with a "zsh: killed" on m1 macbook pro
r/rust on Reddit: Rust binary terminates with a "zsh: killed" on M1 MacBook Pro
June 13, 2024 -

As the title says, when I do cargo run --release and use the resulting binary, I get a zsh: killed. I get the sense this may not be a Rust related issue. Regardless, I cannot find much stuff on the net and would appreciate some tips/help.

🌐
Reddit
reddit.com › r/jailbreak › zsh :killed when i try to launch a binary
r/jailbreak on Reddit: ZSH :killed when I try to launch a binary
June 16, 2025 -

Hello everyone, I’m currently experimenting with arm exploitation on iOS to learn about various techniques. However, I’m facing an issue when I compile and sign my binary using ldid -S on my iPhone. Every time I attempt to launch the binary, I encounter the error message “zsh:killed.” I do not understand the cause of this error. So I hope you could help me. I’m using an iPhone 8 running iOS 16.7.8 with Palera1n -l (rootless) jailbreak.

🌐
Reddit
reddit.com › r/macos › installed homebrew programs return "zsh: killed"
r/MacOS on Reddit: Installed homebrew programs return "zsh: killed"
May 11, 2022 -

When I type brew, I get the output:

zsh: killed     brew

Writing out the whole path still gives the same output, so it doesn't seem like a path problem.

Furthermore, running /bin/bash gives the output:

zsh: killed     /bin/bash

I changed the names of .zshrc and .zprofile, yet the problem still persisted.

To add on, this problem also occurs with programs like pyenv.

🌐
Apple Developer
developer.apple.com › forums › thread › 775045
suddenly 'zsh: killed' my Xcode-ba… | Apple Developer Forums
At first, I could still run the app from the command line, without Automator. But then after I recompiled the app, now I cannot even do that. When I run it, it's saying 'zsh: killed' followed by my app's path.