我在这里尝试使用一种非常基本的设置模式:我有两个不同的工具安装(ocamlc,但那并不重要)。为了选择一个工具,我试图通过在路径前面添加一个条目来覆盖PATH变量。
% where ocamlc
/home/choeger/ueb/uebb/amsun-integration/Runtime/test_src/../../opam/4.02.3/bin/ocamlc
/home/choeger/.opam/4.02.3/bin/ocamlc
/usr/bin/ocamlc
然而,zsh 仍然使用较旧的入口:
% ocamlc -v
The OCaml compiler, version 4.02.3
Standard library directory: /home/choeger/.opam/4.02.3/lib/ocaml
可以看出它使用了第二个条目,因为库目录是硬编码到该安装中的。
Bash 的行为符合预期:
% bash -c "ocamlc -v"
The OCaml compiler, version 4.02.3
Standard library directory: /home/choeger/ueb/uebb/amsun-integration/opam/4.02.3/lib/ocaml
因此,为什么zsh会忽略第一个PATH条目,尽管它将其列为 where
的第一个元素?编辑: 为了验证zsh不会调用相同的二进制文件,这里进行另一次运行:
% type -a ocamlc
ocamlc is /home/choeger/ueb/uebb/amsun-integration/tests/pendulum/../../opam/4.02.3/bin/ocamlc
ocamlc is /home/choeger/.opam/4.02.3/bin/ocamlc
ocamlc is /usr/bin/ocamlc
% ocamlc -v
The OCaml compiler, version 4.02.3
Standard library directory: /home/choeger/.opam/4.02.3/lib/ocaml
% /home/choeger/ueb/uebb/amsun-integration/tests/pendulum/../../opam/4.02.3/bin/ocamlc -v
The OCaml compiler, version 4.02.3
Standard library directory: /home/choeger/ueb/uebb/amsun-integration/opam/4.02.3/lib/ocaml
编辑2:
这里是setopt输出:
% setopt
autocd
autopushd
nobeep
completeinword
correct
extendedglob
extendedhistory
histignorealldups
histignorespace
nohup
interactive
interactivecomments
longlistjobs
monitor
nonomatch
pushdignoredups
shinstdin
zle
%
配置是在这里找到的grml配置加上.local文件中的一些路径变量。
hash
显示该条目仍指向旧位置。不幸的是,重新哈希在这里并没有改变任何事情。rehash
从哪里获取源?我是否遇到了真正的错误? - choegerPATH
中进行任何更改都应该自动导致使用新PATH
中正确的二进制文件,至少在zsh
5.0.6和5.2上的默认设置是如此。因此,这似乎不太可能是一个错误。请发布您配置的链接或至少将setopt
的输出添加到您的问题中? - AdaephonPATH
时立即使用新设置。通过查看配置,它甚至包含一些额外的功能,以确保自动执行rehash
以避免任何更正或完成问题。也许升级到zsh 5.2会解决这个问题,但是 - 如我所说 - 我认为这不太可能,很抱歉,我已经没有更多想法了。 - Adaephon