【问题标题】:Shell not picking correct path to run drush壳牌没有选择正确的路径来运行 drush
【发布时间】:2014-05-21 17:14:09
【问题描述】:

我在/usr/local/bin 有电话。运行 which drush 返回 /usr/local/bin/drush。但是运行drush 会显示“-bash: /usr/bin/drush: No such file or directory”。运行 /usr/local/bin/drush 工作正常。

我的 $PATH 是/usr/local/bin:/usr/local/mysql/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/opt/X11/bin

[在编辑中添加] 在遇到此问题之前,我删除了 位于 /usr/bin/drush 的脚本副本。它没有正确构建。

到底是什么导致了这个问题?我不想每次都输入/usr/local/bin/drush;这就是为什么/usr/local/bin 在我的$PATH 中。

【问题讨论】:

    标签: sh homebrew drush


    【解决方案1】:

    您之前是否在此 shell 中运行过 drush,然后将其从 /usr/bin 移动到 /usr/local/bin ?如果是这样,hash 命令将显示 shell 已经记住了/usr/bin 位置中的命令,并且会假定它在那里而无需重新检查。运行hash -r 将清除此列表。

    工作示例:

    $ echo >/usr/bin/hello 'echo hello'
    $ chmod +x /usr/bin/hello
    $ hash
    hits    command
       1    /bin/chmod
    $ hello
    hello
    $ hash
    hits    command
       1    /bin/chmod
       1    /usr/bin/hello
    $ which hello
    /usr/bin/hello
    $ mv /usr/bin/hello /usr/local/bin/
    $ hello
    bash: /usr/bin/hello: No such file or directory
    $ hash
    hits    command
       1    /usr/bin/which
       1    /bin/chmod
       1    /bin/mv
       2    /usr/bin/hello
    $ which hello
    /usr/local/bin/hello
    $ hash -r
    $ hash
    hash: hash table empty
    $ hello
    hello
    $ hash
    hits    command
       1    /usr/local/bin/hello
    

    【讨论】:

    • 我认为这可能是我的问题,但hash -d 只显示了一个列表。它似乎没有清除任何东西。
    • 对不起,我的意思是hash -r
    • 太好了,成功了!为这件事打开另一个终端也是如此,如果我没有完全被我遇到的问题弄糊涂的话,我会早点这样做的。
    • 郑重声明,hash -r drush 只会重新散列这个命令,这显然是一种更轻松的操作。
    猜你喜欢
    • 2012-02-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-06-18
    • 2022-01-07
    • 1970-01-01
    相关资源
    最近更新 更多