DarkMatter in Cyberspace
  • Home
  • Categories
  • Tags
  • Archives

Homebrew Notes


Homebrew 和 asdf 都采用下载源码包安装的方式, 但 asdf 多了版本管理局部环境定义 (asdf local python 3.8)功能, 适合开发者,尤其是多语言开发者,brew 更适合最终用户, 另外 homebrew 可以在 github 上自己建 tap, 架设私有 bottle(软件库,相当于 PyPI, docker-hub),然后最终进入 homebrew core, 这个模式也是非常开放和友好的。

brew 安装有续传功能,也就是在下载依赖时可以 Ctrl-c 断掉, 然后再次执行 install 命令,这时上次下载过的文件就不会被再次下载了。

Troubleshooting

Download too slow to fail during installation

下面以 brew 安装 joplin 为例说明工作流程。

  1. 执行 brew deps joplin 看一下这个包依赖多少其他包,如果太多, 例如 joplin 依赖了100多个包,则要谨慎安装,寻找其他方式,比如下载 appimage, 或者用 asdf 安装二进制包等;
  2. 安装某个依赖(以 gcc 为例)时 brew 会打印出下载地址,如果速度太慢, 可以根据此地址手工下载到本地磁盘上,完整路径为 A;
  3. 执行 brew --cache gcc 获得这个依赖作为 cache 文件的路径 B;
  4. cp A B
  5. 再次执行 brew install joplin,这时 brew 就会认为 gcc 已经下载完毕了。

Select repo mirror

Use TUNA mirror repo:

git -C "$(brew --repo)" remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/brew.git
git -C "$(brew --repo homebrew/core)" remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/linuxbrew-core.git
brew update

Use official repo:

git -C "$(brew --repo)" remote set-url origin https://github.com/Homebrew/brew.git
git -C "$(brew --repo homebrew/core)" remote set-url origin https://github.com/Homebrew/linuxbrew-core.git
brew update

参考:Homebrew/Linuxbrew 镜像使用帮助

Avoid Working with PyInstaller

主机 A 上通过 homebrew 安装了 Python 3.8,用它的 venv 包创建了虚拟环境, 在其中用 pip 安装了 PyInstaller,再将此环境中的一个应用打包为独立的可执行文件, 在其他 Ubuntu 18.04 主机上运行时报 "Illegal hardware instruction" 错误。

解决方法是不要使用 homebrew 安装的 Python 创建虚拟环境, 使用 asdf 执行下面的命令安装 Python 并创建虚拟环境:

PYTHON_CONFIGURE_OPTS="--enable-shared" asdf install python 3.8.5
~/.asdf/installs/python/3.8.5/bin/python -m venv env


Published

Aug 28, 2020

Last Updated

Sep 2, 2020

Category

Tech

Tags

  • homebrew 1

Contact

  • Powered by Pelican. Theme: Elegant by Talha Mansoor