Mac电脑安装Homebrew的操作指南

homebrew是什么?

   Homebrew是一个专为macOS设计的开源软件包管理器,旨在简化在macOS上安装、更新和管理软件的过程。它通过命令行界面提供大量软件包,帮助用户轻松获取和维护各种开源软件和开发工具。

homebrew如何安装?

根据本人亲测有效的方法,总结了下来,大家按照下面黄色背景的命令去输入,就可以安装成功了,希望能帮助到有需要的同学~~
(base) duanyunyan@duanyunyandeMacBook-Pro bin % /bin/zsh -c "$(curl -fsSL https://gitee.com/cunkai/HomebrewCN/raw/master/Homebrew.sh)" git version 2.39.5 (Apple Git-154) 开始执行Homebrew自动安装程序 [cunkai.wang@foxmail.com] ['2025-04-21 19:51:50']['15.3'] https://zhuanlan.zhihu.com/p/111014448 请选择下列一个 数字编号 后回车 (这里只是下载brew,随意选。国内下载源有5种稍后让你选择配置) 1、通过清华大学下载brew 2、通过Gitee下载brew 3、!我已经安装brew,跳过克隆,直接带我去配置国内下载源 4、不克隆brew,只把仓库地址设置成Gitee 5、不克隆brew,只把仓库地址设置成清华大学 请输入序号: 1 你选择了清华大学brew本体下载源 Mac os设置开机密码方法: (设置开机密码:在左上角苹果图标->系统偏好设置->用户与群组->更改密码) (如果提示This incident will be reported. 在用户与群组中查看是否管理员) 请输入开机密码,输入过程不显示,输入完后回车 Password: 已获取权限 ==> 安装过程开始调用Brew官方安装脚本,提示会变成英文,看不懂的复制到在线翻译。 如果下载速度慢可以ctrl+c或control+c重新运行脚本选择下载源 -> !!!!是否删除之前本机安装的Brew(是Y 否N) 我没有检测本机是否安装brew,选哪个都会继续运行 (Y/N): y --> 脚本开始执行 未发现Git代理(属于正常状态) 开始 进入brew官方安装脚本 开始 下载官方install.sh文件,当前目录是: /Users/duanyunyan Cloning into 'brew-install-ck'... remote: Enumerating objects: 20, done. remote: Counting objects: 100% (20/20), done. remote: Compressing objects: 100% (18/18), done. remote: Total 20 (delta 0), reused 13 (delta 0), pack-reused 0 Receiving objects: 100% (20/20), 22.06 KiB | 752.00 KiB/s, done. ==> Checking for sudo access (which may request your password)... ==> This script will install: /usr/local/bin/brew /usr/local/share/doc/homebrew /usr/local/share/man/man1/brew.1 /usr/local/share/zsh/site-functions/_brew /usr/local/etc/bash_completion.d/brew /usr/local/Homebrew ==> The following existing directories will be made group writable: /usr/local/bin ==> The following existing directories will have their owner set to duanyunyan: /usr/local/bin ==> The following existing directories will have their group set to admin: /usr/local/bin ==> The following new directories will be created: /usr/local/etc /usr/local/include /usr/local/lib /usr/local/sbin /usr/local/share /usr/local/var /usr/local/opt /usr/local/share/zsh /usr/local/share/zsh/site-functions /usr/local/var/homebrew /usr/local/var/homebrew/linked /usr/local/Cellar /usr/local/Caskroom /usr/local/Frameworks Press RETURN/ENTER 现在是brew官方安装提示,它需要你按回车键开始 other key to abort: ==> /usr/bin/sudo /bin/chmod u+rwx /usr/local/bin ==> /usr/bin/sudo /bin/chmod g+rwx /usr/local/bin ==> /usr/bin/sudo /usr/sbin/chown duanyunyan /usr/local/bin ==> /usr/bin/sudo /usr/bin/chgrp admin /usr/local/bin ==> /usr/bin/sudo /bin/mkdir -p /usr/local/etc /usr/local/include /usr/local/lib /usr/local/sbin /usr/local/share /usr/local/var /usr/local/opt /usr/local/share/zsh /usr/local/share/zsh/site-functions /usr/local/var/homebrew /usr/local/var/homebrew/linked /usr/local/Cellar /usr/local/Caskroom /usr/local/Frameworks ==> /usr/bin/sudo /bin/chmod ug=rwx /usr/local/etc /usr/local/include /usr/local/lib /usr/local/sbin /usr/local/share /usr/local/var /usr/local/opt /usr/local/share/zsh /usr/local/share/zsh/site-functions /usr/local/var/homebrew /usr/local/var/homebrew/linked /usr/local/Cellar /usr/local/Caskroom /usr/local/Frameworks ==> /usr/bin/sudo /bin/chmod go-w /usr/local/share/zsh /usr/local/share/zsh/site-functions ==> /usr/bin/sudo /usr/sbin/chown duanyunyan /usr/local/etc /usr/local/include /usr/local/lib /usr/local/sbin /usr/local/share /usr/local/var /usr/local/opt /usr/local/share/zsh /usr/local/share/zsh/site-functions /usr/local/var/homebrew /usr/local/var/homebrew/linked /usr/local/Cellar /usr/local/Caskroom /usr/local/Frameworks ==> /usr/bin/sudo /usr/bin/chgrp admin /usr/local/etc /usr/local/include /usr/local/lib /usr/local/sbin /usr/local/share /usr/local/var /usr/local/opt /usr/local/share/zsh /usr/local/share/zsh/site-functions /usr/local/var/homebrew /usr/local/var/homebrew/linked /usr/local/Cellar /usr/local/Caskroom /usr/local/Frameworks ==> /usr/bin/sudo /bin/mkdir -p /usr/local/Homebrew ==> /usr/bin/sudo /usr/sbin/chown -R duanyunyan:admin /usr/local/Homebrew ==> /usr/bin/sudo /bin/mkdir -p /Users/duanyunyan/Library/Caches/Homebrew ==> /usr/bin/sudo /bin/chmod g+rwx /Users/duanyunyan/Library/Caches/Homebrew ==> /usr/bin/sudo /usr/sbin/chown -R duanyunyan /Users/duanyunyan/Library/Caches/Homebrew ==> Downloading and installing Homebrew... remote: Enumerating objects: 299500, done. remote: Counting objects: 100% (93133/93133), done. remote: Compressing objects: 100% (11079/11079), done. remote: Total 299500 (delta 91701), reused 82098 (delta 82054), pack-reused 206367 remote: Enumerating objects: 55, done. remote: Counting objects: 100% (35/35), done. remote: Total 55 (delta 35), reused 35 (delta 35), pack-reused 20 ==> Fetching /usr/local/Homebrew... ==> Resetting /usr/local/Homebrew... Reset branch 'stable' ==> 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://mirrors.tuna.tsinghua.edu.cn/git/homebrew/brew#donations ==> Next steps: ● Run these commands in your terminal to add Homebrew to your PATH: echo >> /Users/duanyunyan/.zprofile echo 'eval "$(/usr/local/bin/brew shellenv)"' >> /Users/duanyunyan/.zprofile eval "$(/usr/local/bin/brew shellenv)" ● Run brew help to get started ● Further documentation: https://docs.brew.sh 此步骤成功 Password: 完成 退出brew官方安装脚本 完成 ==> 配置国内镜像源HOMEBREW BOTTLE 此处如果显示Password表示需要再次输入开机密码,输入完后回车 有些电脑xcode和git混乱,再运行一次,此处如果有error正常。 xcode-select: note: Command line tools are already installed. Use "Software Update" in System Settings or the softwareupdate command line interface to install updates Homebrew已经安装成功,接下来配置国内软件下载源。 请选择今后brew install的时候访问那个国内镜像,例如阿里巴巴,输入5回车。 1、中科大国内源 2、清华大学国内源 3、上海交通大学国内源 4、腾讯国内源 5、阿里巴巴国内源(推荐) 请输入序号: 5 你选择了阿里巴巴国内源 环境变量写入->/Users/duanyunyan/.zprofile 此步骤成功 ==> 安装完成,brew版本 Homebrew 4.4.31 Homebrew前期配置成功 ==>Updating Homebrew... ==>Downloading https://mirrors.aliyun.com/homebrew/homebrew-bottles/bottles-portable-ruby/portable-ruby-3.3.8.el_capitan.bottle.tar.gz ################################################################################################################################################################## 100.0% ==>Pouring portable-ruby-3.3.8.el_capitan.bottle.tar.gz ==>Homebrew collects anonymous analytics. Read the analytics documentation (and how to opt-out) here: https://docs.brew.sh/Analytics No analytics have been recorded yet (nor will be during this `brew` run). ==>Homebrew is run entirely by unpaid volunteers. Please consider donating: https://github.com/Homebrew/brew#donations Already up-to-date. Homebrew自动安装程序运行完成 国内地址已经配置完成 之前步骤选了删除本机brew的话,桌面多出一个Old_Homebrew文件夹,可以删除。 初步介绍几个brew命令 查看版本:brew -v 更新brew版本:brew update 查找:brew search python(其中python替换为要查找的关键字) 安装:brew install python(其中python替换为要安装的名称) 本地软件库列表:brew ls 欢迎右键点击下方地址-打开链接 点个赞吧 https://zhuanlan.zhihu.com/p/111014448 如果遇到问题可以右键下面地址查看常见错误解决办法 https://gitee.com/cunkai/HomebrewCN/blob/master/error.md brew官方地址:https://brew.sh/zh-cn/ 安装成功 但还需要重启终端 或者 运行 source /Users/duanyunyan/.zprofile 否则国内地址无法生效 (base) duanyunyan@duanyunyandeMacBook-Pro bin % source /Users/duanyunyan/.zprofile (base) duanyunyan@duanyunyandeMacBook-Pro bin % brew -v ---表示安装成功 Homebrew 4.4.31 (base) duanyunyan@duanyunyandeMacBook-Pro bin %

 

posted on 2025-04-22 11:19  不怕风雨的向日葵  阅读(1924)  评论(0)    收藏  举报

导航