dongyong1897 2018-03-11 15:47
浏览 43
已采纳

OSX在尝试安装自制软件时不尊重PATH

I have installed homebrew-php php72 on OSX high sierra. Strangely when I run php I still get the pre-installed php 7.1 - even more strangely when I run which php it tells me that it will use the homebrew version from /usr/local/bin not the pre-installed version in /usr/bin. I dont have an aliases set up.

Some shell output:

$ echo $PATH
/usr/local/bin:/bin:/usr/bin:/usr/sbin:/sbin:/opt/X11/bin

$ which php
/usr/local/bin/php

$ php --version
PHP 7.1.7 (cli) (built: Jul 15 2017 18:08:09) ( NTS )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.1.0, Copyright (c) 1998-2017 Zend Technologies

$ /usr/local/bin/php --version
PHP 7.2.3 (cli) (built: Mar  8 2018 10:30:06) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
    with Zend OPcache v7.2.3, Copyright (c) 1999-2018, by Zend Technologies

$ /usr/bin/php --version
PHP 7.1.7 (cli) (built: Jul 15 2017 18:08:09) ( NTS )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.1.0, Copyright (c) 1998-2017 Zend Technologies

$ alias | grep php # There are no aliases
$

$ type -a php
php is /usr/local/bin/php
php is /usr/bin/php

I cant think of any reason this could happen any ideas?

Thanks NFV

  • 写回答

1条回答 默认 最新

  • duancui19840401 2018-03-11 16:04
    关注

    As discussed in the commands hash -r fixed the issue. From help hash:

      -r                forget all remembered locations
    

    And just for the record: Why not use “which”? What to use then?

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 安装svn网络有问题怎么办
  • ¥15 Python爬取指定微博话题下的内容,保存为txt
  • ¥15 vue2登录调用后端接口如何实现
  • ¥65 永磁型步进电机PID算法
  • ¥15 sqlite 附加(attach database)加密数据库时,返回26是什么原因呢?
  • ¥88 找成都本地经验丰富懂小程序开发的技术大咖
  • ¥15 如何处理复杂数据表格的除法运算
  • ¥15 如何用stc8h1k08的片子做485数据透传的功能?(关键词-串口)
  • ¥15 有兄弟姐妹会用word插图功能制作类似citespace的图片吗?
  • ¥15 latex怎么处理论文引理引用参考文献