一、安装:
不能在root下运行
$sh -c "$(curl -fsSL https://raw.githubusercontent.com/Linuxbrew/install/master/install.sh)"
- Add Linuxbrew to your PATH
PATH="/home/linuxbrew/.linuxbrew/bin:$PATH"
- We recommend that you install GCC by running:
brew install gcc
- Run `brew help` to get started
- Further documentation:
https://docs.brew.sh
Warning: /home/ubuntu/.linuxbrew/bin is not in your PATH.
设置路径:
$export PATH="/home/linuxbrew/.linuxbrew/bin:$PATH"
这里参考设置环境变量
linux 修改配置文件
二、卸载:
$/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/uninstall)"
The following possible Homebrew files were not deleted:
/home/linuxbrew/.linuxbrew/share/
/home/linuxbrew/.linuxbrew/etc/
/home/linuxbrew/.linuxbrew/lib/
/home/linuxbrew/.linuxbrew/var/
You may wish to remove them yourself.
需要手动删除文件夹:
$rm -r -f /home/linuxbrew/.linuxbrew
三、更换源
brew默认的源速度太慢了,可以替换成国内的清华大学提供的源
1.Homebrew 的 formula 索引的镜像(即brew update时所更新内容)
替换brew.git
这里$(brew --repo) 是/home/linuxbrew/.linuxbrew/Homebrew
$ cd "$(brew --repo)"
$ git remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/brew.git
替换homebrew-core.git
$ cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core"
$ git remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-core.git
$ brew update
2. Homebrew 二进制预编译包的镜像(注: 2.1 2.2 任选其一)
2.1 临时替换(关闭终端再次打开终端时配置失效,使用默认配置)
export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles
2.2 长期替换(建议使用此项配置)
echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles'>> ~/.bash_profile
source ~/.bash_profile
#执行.bash_profile脚本让配置即时生效
注意:
linux 必须先安装gcc,很多软件编译还是得用apt下载gcc和g++,make,cmake,还有环境配置,不是很好用