brew、gem、pip、cask,一锅粥……

背景:很久很久以前,安装了 Homebrew,再往后,不知怎么的 gem、easy_install 和 pip 这些也一一进驻到了电脑里……

现状:伟大的杨哥要讲 IPython 相关的东东,于是,痛苦开始了。

1、用 [sudo [-H]] pip install ipython,报告卸载 six 没有权限,sudo 也不行;
2、顺便还报告 pip 过时,用 sudo pip install –upgrade pip 升级了 pip(从 7.1.2 升级到了 9.0.1)再试,仍然不行;
3、根据线索(https://stackoverflow.com/questions/35049907/cannot-sudo-pip-uninstall-operation-not-permitted-tmp-in-os-x-el-capitan),用 brew reinstall python 更新 python,说“/usr/local must be writable”;
4、根据线索(https://github.com/Homebrew/legacy-homebrew/issues/49895),决定执行 sudo chgrp -R admin /usr/local && sudo chmod -R g+w /usr/local 后再试,执行前先看看有哪些不是 admin 身份的目录,见下,

➜ /Users ls -l /usr/local
total 80
-rw-r–r– 1 dandy admin 3161 5 14 2016 CODEOFCONDUCT.md
-rw-r–r– 1 dandy admin 1103 3 4 2015 CONTRIBUTING.md
drwxr-xr-x 5 dandy admin 170 8 8 16:29 Cellar
drwxr-xr-x 2 dandy admin 68 5 14 2016 Frameworks
-rw-r–r– 1 dandy admin 1241 5 14 2016 LICENSE.txt
drwxrwxr-x 11 dandy admin 374 6 21 2016 Library
-rw-r–r– 1 dandy admin 3918 5 14 2016 README.md
-rw-r–r– 1 dandy admin 23781 3 4 2015 SUPPORTERS.md
drwxrwxr-x 38 root admin 1292 8 8 16:30 bin
drwxr-xr-x 9 dandy admin 306 5 14 2016 etc
drwxr-xr-x 19 root wheel 646 10 20 2014 go
drwxrwxr-x 4 root admin 136 5 14 2016 include
drwxrwxr-x 14 root admin 476 4 13 14:50 lib
drwxr-xr-x 3 root wheel 102 2 23 16:55 n
drwxr-xr-x 5 dandy admin 170 8 8 16:30 opt
drwxr-xr-x 3 root wheel 102 2 15 06:03 remotedesktop
drwxr-xr-x 5 dandy admin 170 7 19 2016 sbin
drwxrwxr-x 10 24561 admin 340 8 8 16:30 share
drwxr-xr-x 2 dandy admin 68 5 14 2016 var
➜ /Users ls -l /usr
total 8
lrwxr-xr-x 1 root wheel 8 12 3 2016 X11 -> /opt/X11
drwxr-xr-x 1067 root wheel 36278 7 25 09:45 bin
drwxr-xr-x 283 root wheel 9622 7 25 09:45 lib
drwxr-xr-x 211 root wheel 7174 7 25 09:45 libexec
drwxr-xr-x 26 root wheel 884 2 23 16:55 local
drwxr-xr-x 246 root wheel 8364 7 25 09:44 sbin
drwxr-xr-x 46 root wheel 1564 1 17 2017 share
drwxr-xr-x 5 root wheel 170 12 13 2016 standalone
➜ /Users sudo chgrp -R admin /usr/local

5、此后尝试 brew reinstall python 则报 readline 的一个补丁包下载总是失败:
Downloading https://gist.githubusercontent.com/jacknagel/d886531fb6623b60b2af/raw/746fc543e56bc37
curl: (22) The requested URL returned error: 404 Not Found
Error: Failed to download resource “readline–patch”
Download failed: https://gist.githubusercontent.com/jacknagel/d886531fb6623b60b2af/raw/746fc543e56bc37a26ccf05d2946a45176b0894e/readline-6.3.8.diff

从 https://stackoverflow.com/questions/41337676/error-installing-python-3-with-homebrew 处看到,该补丁包已经被移除;由此感觉应该先更新 brew 自身;

6、多次尝试 brew update [–force] 不成功(甚至还执行了 cd “$(brew –repo)” && git fetch && git reset –hard origin/master && brew update),报 SSL 相关的错误;有一篇资料说 rubygems.org 已经不能用了,用 gem sources -l 查看,用的正是,于是按照建议使用 gem sources –add https://gems.ruby-china.org/ –remove https://rubygems.org/ 进行了更新,再次 brew update 也没有起色;
7、难道 gem 需要更新(此处完全是得病乱投医)?于是执行 gem update,结果报了错,说“hostname “gems.ruby-china.org” does not match the server certificate”;
8、尝试 gem update –system,报告“You don’t have write permissions for the /Library/Ruby/Gems/2.0.0 directory.”,看来有戏;尝试 sudo 执行之,成功;继续执行 sudo gem update,则中间出现错误,并因对 /usr/bin/nokogiri 的权限问题而失败;放弃 gem 这块阵地;

9、重来。用 /usr/bin/ruby -e “$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)” 安装新版本的 homebrew(老版本的应该留有不少垃圾,也许会对新版本造成干扰,顾不得了);半天没反应,最后竟然成功。

10、用 brew install python,也正常执行,正常完成;
11、pip install ipython 成功。

累个半死。

今天看有人推荐一款播放器,安装命令是 brew cask install iina,cask 是什么鬼?晕……

一条评论


  1. Cask是Homebrew的一个扩展,可以用brew安装
    brew install caskroom/cask/brew-cask

    回复

发表回复

您的电子邮箱地址不会被公开。 必填项已用*标注