$PATH zsh: no such file or directory: /usr/bin:/bin:/usr/sbin:/sbin: ... 我使用pre-6ren">
gpt4 book ai didi

zsh路径 "no such file or directory"在哪里取消设置?

转载 作者:行者123 更新时间:2023-12-01 06:57:59 28 4
gpt4 key购买 nike

我只是注意到$PATH的位置无效:

\> $PATH

zsh: no such file or directory: /usr/bin:/bin:/usr/sbin:/sbin: ...

我使用prezto,根据文档,配置文件是按以下顺序获取的:

  • /etc/zshenv
  • 〜/.zshenv
  • /etc/zprofile
  • 〜/.zprofile
  • /etc/zshrc
  • 〜/.zshrc
  • 〜/.zpreztorc
  • /etc/zlogin
  • 〜/.zlogin
  • 〜/.zlogout
  • /etc/zlogout

  • 我检查了整个列表,但找不到 /usr/bin之前的任何内容

    关于如何找到引发问题的任何建议?

    谢谢!

    最佳答案

    据我所知,您的PATH没有错。如果要查看PATH的内容,请使用echo:

    % echo $PATH
    /usr/sbin:/usr/bin:/sbin:/bin
    PATH是用冒号分隔的目录列表,用于搜索命令。本质上,zsh将尝试使用每个路径的命令名称并执行第一个查找( /usr/sbin/foo/usr/bin/foo等)。如果列出的目录中的任何一个都不存在,则不会出现错误消息,zsh只会在该目录中找不到二进制文件并尝试下一个二进制文件。

    您遇到的问题是通过尝试执行 $PATH触发的。在执行命令行之前,zsh(除其他外)将所有变量替换为其内容,这称为参数扩展(有关此信息,请参见 man 1 zshexpn)。

    因此,当您仅编写 $PATH时,zsh将其替换为 /usr/bin:/bin:/usr/sbin:/sbin:...并将其解释为一条长路径。也就是说, :不被当作分隔符,而是被当作目录名的一部分。任何您得到与其他任何不存在的目录相同的错误消息:
    % ls /some/path
    dir1 dir2
    % /some/path/nothere/notthere
    zsh: no such file or directory: /some/path/nothere/notthere

    关于zsh路径 "no such file or directory"在哪里取消设置?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21608617/

    28 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com