macOS 安装 homebrew

Homebrew:macOS(或 Linux)缺失的软件包的管理器

官网:https://brew.sh/

安装homebrew方式区别

官方命令行 官方pkg安装 国内安装
镜像容易下载推荐 页面化安装 下载快,中文

命令行

复制代码
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

安装过程

复制代码
johnny@MacBook-Pro homebrew % /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
==> Checking for `sudo` access (which may request your password)...
Password:
==> This script will install:
/opt/homebrew/bin/brew
/opt/homebrew/share/doc/homebrew
/opt/homebrew/share/man/man1/brew.1
/opt/homebrew/share/zsh/site-functions/_brew
/opt/homebrew/etc/bash_completion.d/brew
/opt/homebrew
==> The following new directories will be created:
/opt/homebrew/share/zsh
/opt/homebrew/share/zsh/site-functions

Press RETURN/ENTER to continue or any other key to abort:
==> /usr/bin/sudo /bin/mkdir -p /opt/homebrew/share/zsh /opt/homebrew/share/zsh/site-functions
==> /usr/bin/sudo /bin/chmod ug=rwx /opt/homebrew/share/zsh /opt/homebrew/share/zsh/site-functions
==> /usr/bin/sudo /bin/chmod go-w /opt/homebrew/share/zsh /opt/homebrew/share/zsh/site-functions
==> /usr/bin/sudo /usr/sbin/chown hongwei /opt/homebrew/share/zsh /opt/homebrew/share/zsh/site-functions
==> /usr/bin/sudo /usr/bin/chgrp admin /opt/homebrew/share/zsh /opt/homebrew/share/zsh/site-functions
==> /usr/bin/sudo /usr/sbin/chown -R hongwei:admin /opt/homebrew
==> Downloading and installing Homebrew...
remote: Enumerating objects: 87, done.
remote: Counting objects: 100% (87/87), done.
remote: Compressing objects: 100% (19/19), done.
remote: Total 87 (delta 67), reused 87 (delta 67), pack-reused 0 (from 0)
==> Updating Homebrew...
==> Downloading https://ghcr.io/v2/homebrew/portable-ruby/portable-ruby/blobs/sha256:d9faa506c014dedc0b034a68103ba75c9a58242f4d6c67b6ca0f649c39602bcf
######################################################################### 100.0%
==> Pouring portable-ruby-3.3.7.arm64_big_sur.bottle.tar.gz
Updated 1 tap (homebrew/core).
Warning: /opt/homebrew/bin is not in your PATH.
  Instructions on how to configure your shell for Homebrew
  can be found in the 'Next steps' section below.
==> Installation successful!

==> Homebrew has enabled anonymous aggregate formulae and cask analytics.
Read the analytics documentation (and how to opt-out) here:
  https://docs.brew.sh/Analytics
No analytics data has been sent yet (nor will any be during this install run).

==> Homebrew is run entirely by unpaid volunteers. Please consider donating:
  https://github.com/Homebrew/brew#donations

==> Next steps:
- Run these commands in your terminal to add Homebrew to your PATH:
    echo >> /Users/johnny/.zprofile
    echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> /Users/johnny/.zprofile
    eval "$(/opt/homebrew/bin/brew shellenv)"
- Run brew help to get started
- Further documentation:
    https://docs.brew.sh

根据提示配置环境变量

复制代码
johnny@MacBook-Pro homebrew % brew
zsh: command not found: brew
johnny@MacBook-Pro homebrew % echo >> /Users/johnny/.zprofile
johnny@MacBook-Pro homebrew % echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> /Users/johnny/.zprofile
johnny@MacBook-Pro homebrew % eval "$(/opt/homebrew/bin/brew shellenv)"
johnny@MacBook-Pro homebrew % 
johnny@MacBook-Pro homebrew % brew
Example usage:
  brew search TEXT|/REGEX/
  brew info [FORMULA|CASK...]
  brew install FORMULA|CASK...
  brew update
  brew upgrade [FORMULA|CASK...]
  brew uninstall FORMULA|CASK...
  brew list [FORMULA|CASK...]

Troubleshooting:
  brew config
  brew doctor
  brew install --verbose --debug FORMULA|CASK

Contributing:
  brew create URL [--no-fetch]
  brew edit [FORMULA|CASK...]

Further help:
  brew commands
  brew help [COMMAND]
  man brew
  https://docs.brew.sh

pkg安装

根据提示一直安装即可

配置环境变量

复制代码
echo 'export PATH="/opt/homebrew/bin:$PATH"' >> ~/.bash_profile 

source ~/.bash_profile

echo 'export PATH="/opt/homebrew/bin:$PATH"' >> ~/.zshrc   

source ~/.zshrc

国内地址

安装脚本:

复制代码
/bin/zsh -c "$(curl -fsSL https://gitee.com/cunkai/HomebrewCN/raw/master/Homebrew.sh)"

卸载脚本:

复制代码
/bin/zsh -c "$(curl -fsSL https://gitee.com/cunkai/HomebrewCN/raw/master/HomebrewUninstall.sh)"
相关推荐
大米饭667 小时前
解决Mac 安装 PyICU 依赖失败
macos·ragflow
我该如何取个名字7 小时前
Mac配置Java的环境变量
java·开发语言·macos
黑心老人8 小时前
Mac OS系统下kernel_task占用大量CPU资源导致系统卡顿
linux·运维·服务器·macos
我的代码永没有bug8 小时前
day1-小白学习JAVA---JDK安装和环境变量配置(mac版)
java·学习·macos
孤寂码农_defector12 小时前
鸿蒙系统的 “成长烦恼“:生态突围与技术迭代的双重挑战
macos·华为·objective-c·cocoa·harmonyos
方始终_12 小时前
亲测有效,如何macOS上卸载并且重新安装homeBrew
前端·后端·macos
依旧风轻13 小时前
iOS 冷启动时间监控:启动起点有哪些选择?
macos·ios·cocoa·sqi·coldstart
carlZzzzzzz13 小时前
mac上安装VMWare Fusion安装ubuntu系统问题
linux·ubuntu·macos
slash下划线13 小时前
【开源自荐】Shui:一个专注喝水提醒的桌面端 App,关注打工人健康💪 ,改善你的喝水习惯。
macos
bjxiaxueliang13 小时前
一文详解opencv-python环境搭建:Mac配置python的cv2开发环境
python·opencv·macos