zsh 錯誤及解決方式匯總

terminal

zsh 每次打開出現 zsh compinit: insecure files, run compaudit for list.

image 19

錯誤訊息:

zsh compinit: insecure directories, run compaudit for list.
Ignore insecure directories and continue [y] or abort compinit [n]? ncompinit: initialization aborted
complete:13: command not found: compdef

解決方式

輸入 compaudit 確認有哪些不安全的目錄:

$ compaudit
There are insecure directories:
/opt/homebrew/share/zsh/site-functions
/opt/homebrew/Cellar/zsh/5.9/share/zsh/functions
/opt/homebrew/share/zsh
/opt/homebrew/Cellar/zsh/5.9/share/zsh

分別修改這幾個目錄權限為 755

$ sudo chmod -R 755 /opt/homebrew/share/zsh/site-functions
$ sudo chmod -R 755 /opt/homebrew/Cellar/zsh/5.9/share/zsh/functions
$ sudo chmod -R 755 /opt/homebrew/share/zsh
$ sudo chmod -R 755 /opt/homebrew/Cellar/zsh/5.9/share/zsh

接著重啟 terminal 就不會再出現提示了。

no such file or directory path/to/new/ohmyzsh/folder/oh-my-zsh.sh

image 20

解決方式

nano ~/.zshrc 找到 source $ZSH/oh-my-zsh.sh 這句,然後在最前面加上一個 # 註釋掉:

# Which plugins would you like to load?
# Standard plugins can be found in $ZSH/plugins/
# Custom plugins may be added to $ZSH_CUSTOM/plugins/
# Example format: plugins=(rails git textmate ruby lighthouse)
# Add wisely, as too many plugins slow down shell startup.
plugins=(git zsh-autosuggestions zsh-syntax-highlighting)

# source $ZSH/oh-my-zsh.sh

nano 操作指令參考:https://www.nano-editor.org/dist/latest/cheatsheet.html

zsh: command not found: conda

可能是沒設置 conda 路徑到 .zshrc 或者路徑錯誤。

不知道 conda 路徑在哪可以用指令找一下(需要一段時間):

$ sudo find / -name "anaconda" 2>/dev/null

找到一個路徑為 anaconda3/bin 的就是我們要找的

image 21

編輯 .zshrc

$ nano ~/.zshrc

在最下面加上(或者修改原本的路徑):

export PATH="/opt/homebrew/anaconda3/bin:$PATH"

完成後保存,接著使用 conda -V 指令確認一下是不是設置成功了:

$ conda -V
conda 23.7.4

留言

目前沒有留言。

發佈留言

發佈留言必須填寫的電子郵件地址不會公開。 必填欄位標示為 *