zshell 说在 MacOS 中未找到命令

zshell 说在 MacOS 中未找到命令

我使用的是 MacOS Monterey 12.4。当我打开 zsh 时,我立即得到

/etc/zshrc:7: command not found: locale
/etc/zshrc_Apple_Terminal:104: command not found: mkdir

我知道我的终端会立即执行“/etc/zshrc”和“/etc/zshrc_Apple_Terminal”的内容,然后再执行我插入命令的“~/.zshrc”的内容

export PATH="/usr/bin:/bin:/usr/sbin:/sbin:$PATH"

事实上,在终端加载这些文件后,每个命令都是可以执行的,因为我可以

me@mylaptop ~ % which locale
/usr/bin/locale
me@mylaptop ~ % which mkdir
/bin/mkdir

我尝试编辑文件“/etc/zshrc”和“/etc/zshrc_Apple_Terminal”,但是我无法做到这一点,因为系统说它们被阻止了,即使我打开它们的属性并通过使用 sudo 密码打开锁来更改每个组的读/写权限。

答案1

我和你有同样的问题

不要修改这两个文件 '/etc/zshrc' 和 '/etc/zshrc_Apple_Terminal'

问题应该是你搞错了 .zprofile 或 .zshrc 的配置

在你已经备份这两个文件的前提下,尝试删除其中的内容,以便终端可以正常运行。你必须逐行调试你的.zshrc 和/或 .zprofile。

我的问题是我搞砸了配置.zprofile,我把下面的内容放在一行中

export PATHeval $(/opt/homebrew/bin/brew shellenv)

改成下面这样就可以了

export PATH
eval $(/opt/homebrew/bin/brew shellenv)

您可以参考示例这里

相关内容