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 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测
  • ¥15 ETLCloud 处理json多层级问题
  • ¥15 matlab中使用gurobi时报错
  • ¥15 这个主板怎么能扩出一两个sata口
  • ¥15 不是,这到底错哪儿了😭
  • ¥15 2020长安杯与连接网探
  • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么