brew install spinx-build 的时候可能会遇到如下错误:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/open-uri.rb:353:in `open_http': 422 Unprocessable Entity (GitHub::Error) from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/open-uri.rb:709:in `buffer_open' from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/open-uri.rb:210:in `block in open_loop' from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/open-uri.rb:208:in `catch' from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/open-uri.rb:208:in `open_loop' from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/open-uri.rb:149:in `open_uri' from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/open-uri.rb:689:in `open' from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/open-uri.rb:30:in `open' from /usr/local/Library/Homebrew/utils.rb:367:in `open' from /usr/local/Library/Homebrew/utils.rb:397:in `issues_matching' from /usr/local/Library/Homebrew/utils.rb:425:in `issues_for_formula' from /usr/local/Library/Homebrew/exceptions.rb:145:in `fetch_issues' from /usr/local/Library/Homebrew/exceptions.rb:141:in `issues' from /usr/local/Library/Homebrew/exceptions.rb:184:in `dump' from /usr/local/Library/brew.rb:167:in `rescue in <main>' from /usr/local/Library/brew.rb:65:in `<main>' |
修改 /usr/local/Library/Homebrew/utils.rb 的代码,打印url看看:
1 |
https://api.github.com/search/issues?q=sphinx+repo:Homebrew/homebrew+in:title+state:open&per_page=100 |
莫非访问不了api.github.com ?
1 2 3 4 5 6 7 8 9 10 11 12 13 |
$ curl "https://api.github.com/search/issues?q=sphinx+repo:Homebrew/homebrew+in:title+state:open&per_page=100" { "message": "Validation Failed", "errors": [ { "message": "The listed users and repositories cannot be searched either because the resources do not exist or you do not have permission to view them.", "resource": "Search", "field": "q", "code": "invalid" } ], "documentation_url": "https://developer.github.com/v3/search/" } |
看起来是有返回值的,而且是合法的json,继续看 /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/open-uri.rb 的代码,发现很可能是httpcode的问题:
1 |
curl -v "https://api.github.com/search/issues?q=sphinx+repo:Homebrew/homebrew+in:title+state:open&per_page=100" |
发现http code为 422 , 而/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/open-uri.rb 遇到 422 是走异常逻辑的,如果能简单修改代码使其认为是正常似乎是可以的; 但是mac 不让修改/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/open-uri.rb , root账号也不行
回头看 /usr/local/Library/Homebrew/utils.rb ,发现如下逻辑:
export HOMEBREW_NO_GITHUB_API=1
问题解决
其实 spinx-build 是在生成man page的时候用到的,某些情况下,大可不必非要去生成man page