解决brew search报错“Unknown option n”和“Unknown option 1”

Posted by fengmiaosen on 2016-11-23

问题描述

macOS 10.12终端使用brew搜索软件包

1
brew search pip

搜索结果前包含如下一段错误信息:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
Unknown option: n
Unknown option: 1
Usage: head [-options] <url>...
-m <method> use method for the request (default is 'HEAD')
-f make request even if head believes method is illegal
-b <base> Use the specified URL as base
-t <timeout> Set timeout value
-i <time> Set the If-Modified-Since header on the request
-c <conttype> use this content-type for POST, PUT, CHECKIN
-a Use text mode for content I/O
-p <proxyurl> use this as a proxy
-P don't load proxy settings from environment
-H <header> send this HTTP header (you can specify several)
-u Display method and URL before any response
-U Display request headers (implies -u)
-s Display response status code
-S Display response status chain
-e Display response headers
-d Do not display content
-o <format> Process HTML content in various ways
-v Show program version
-h Print this message
-x Extra debugging output

问题原因

解决方法

  • 查看当前系统目录下的 ~/.bashrc 或者 ~/.bash_profile,有如下一段类似的设置系统PATH的命令
1
export PATH=/Applications/XAMPP/bin:$PATH
  • 先把系统 PATH 保存到一个临时变量 path(名字随意)中
1
path=${PATH}
  • 删除变量path中的 /Applications/XAMPP/bin部分,并赋值给系统 PATH
1
PATH=${path#/*XAMPP/bin:}
  • 再次打开~/.bashrc 或者 ~/.bash_profile,修改 export PATH部分,将/Applications/XAMPP/bin追加在系统PATH后面。
1
export PATH=/Applications/XAMPP/bin:$PATH

修改为

1
export PATH=$PATH:/Applications/XAMPP/bin
  • 保存并退出,执行 source ~/.bashrc 或者 source ~/.bash_profile使配置立即生效。

参考资料