Brew Install Local Files



How to install a local file with Homebrew

  1. Find the cache location
brew --cache -s <your package name>

For example, I want to install dart-lang/dart/dart from https://storage.googleapis.com/dart-archive/channels/stable/release/3.9.4/sdk/dartsdk-macos-arm64-release.zip, which may be inaccessible from within China. So I first downloaded it to my Downloads folder, then I used the command above to find Homebrew’s cache directory for dart.

Replace <your package name> with the formula name (e.g. dart-lang/dart/dart) and <your file> with the downloaded file name (e.g. dartsdk-macos-arm64-release.zip).

By the way, if you want to run dart pub get quickly, you need to add export PUB_HOSTED_URL="https://mirrors.tuna.tsinghua.edu.cn/dart-pub" to ~/.bashrc or ~/.zshrc.

  1. Move the local file
mv ~/Downloads/<your file> "$(brew --cache -s <your package name>)"
  1. Reinstall

If your Homebrew version is greater than or equal to 4.0, you may need to add the following to ~/.bash_profile or ~/.zprofile before installing:

export HOMEBREW_NO_INSTALL_FROM_API=1

Then run:

brew install <your package>