找不到命令,尽管它在$ PATH中 [英] Command not found, although it is in the $PATH

查看:86
本文介绍了找不到命令,尽管它在$ PATH中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的系统找不到 phpunit ,尽管它肯定在我的 $ PATH 中.

My system does not find phpunit, although it is definitely in my $PATH.

我正在使用ubuntu 16.04.这是我的PATH,其中包含/usr/local/bin

I am using ubuntu 16.04. Here is my PATH, which contains /usr/local/bin

$ echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin

composer phpunit 都位于同一目录中:

composer and phpunit both lie in the same directory:

$ which composer;which phpunit
/usr/local/bin/composer
/usr/local/bin/phpunit

但是当我打电话给他们时,尽管找到了 composer ,却没有找到 phpunit ...因为找到了 composer ,所以我的路径应该是好吧...

but when i call them, phpunit is not found althogh composer is found... since composer is found, my path should be okay...

$ composer --version;phpunit --version
Composer version 1.4.2 2017-05-17 08:17:52
-bash: /usr/bin/phpunit: Datei oder Verzeichnis nicht gefunden

当我用命令说的完整路径调用它时,它就起作用了....

when I call it with the entire path the which command says, it works....

$ /usr/local/bin/phpunit --version
PHPUnit 6.2.3 by Sebastian Bergmann and contributors.

而且我没有别名:

alias alert='notify-send --urgency=low -i "$([ $? = 0 ] && echo terminal || echo error)" "$(history|tail -n1|sed -e '\''s/^\s*[0-9]\+\s*//;s/[;&|]\s*alert$//'\'')"'
alias egrep='egrep --color=auto'
alias fgrep='fgrep --color=auto'
alias grep='grep --color=auto'
alias l='ls -CF'
alias la='ls -A'
alias ll='ls -alF'
alias ls='ls --color=auto'

我在这里想念东西吗?

推荐答案

拖放bash的可执行文件位置哈希值

运行哈希phpunit

/usr/bin/文件夹中有一个 phpunit 二进制文件(从错误消息中可以看出).

There was a phpunit binary in /usr/bin/ folder (as can be seen from the error message).

现在,它已被移至/usr/local/bin/.

但是bash会存储以前找到的可执行文件位置,并且不会立即对其进行更新,因此应清除旧的/usr/bin/phpunit 位置,以便找到新的可执行文件.

But bash stored the previously found locations of executables and doesn't update them immediately, so the old /usr/bin/phpunit location should be cleared for the new one to be found.

检查此ServerFault答案以获取更多信息.

这篇关于找不到命令,尽管它在$ PATH中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆