欢迎光临散文网 会员登陆 & 注册

在Linux使用brew(更新版)

2022-01-24 16:34 作者:beyondware  | 我要投稿

安装前准备

1. 安装依赖

-  Ubuntu  

sudo apt install build-essential procps curl file git

-  Fedora  

sudo dnf groupinstall 'Development Tools'

sudo dnf install curl file git

2. 修改环境变量

export HOMEBREW_BREW_GIT_REMOTE="https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/brew.git"

export HOMEBREW_CORE_GIT_REMOTE="https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-core.git"

export HOMEBREW_BOTTLE_DOMAIN="https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles"

安装

1. 安装 brew

git clone --depth=1 https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/install.git brew-install

/bin/bash brew-install/install.sh

rm -rf brew-install

2. 添加 PATH 变量

echo 'eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"' >> $HOME/.bash_profile

eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"

3. brew-cask

sudo mkdir -p /home/linuxbrew/.linuxbrew/Homebrew/Library/Taps/homebrew/homebrew-cask

sudo git clone https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-cask.git /home/linuxbrew/.linuxbrew/Homebrew/Library/Taps/homebrew/homebrew-cask

4. 查看源

git -C "$(brew --repo)" remote -v

git -C "$(brew --repo homebrew/core)" remote -v

git -C "$(brew --repo homebrew/cask)" remote -v

5. 官方源

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/homebrew-core.git

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

brew update

6. 替换源

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/homebrew-core.git

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

brew update

7. brew-bottles 换源

- bash

echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles' >> ~/.bash_profile

source ~/.bash_profile

- zsh

echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles' >> ~/.zshrc

source ~/.zshrc

8. 查询版本

brew -v

brew --version

显示3个库

> Homebrew 3.3.11

> Homebrew/homebrew-core (git revision 34f9503efb7; last commit 2022-01-24)

> Homebrew/homebrew-cask (git revision b0206bb04c; last commit 2022-01-24)

9. 验证

brew doctor

10. 帮助

brew help

man brew

## 对应库

1. brew

> https://github.com/Homebrew/brew

> https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/brew.git

对应位置

> /home/linuxbrew/.linuxbrew/Homebrew/bin/brew


2. brew-croe

> https://formulae.brew.sh/formula/

> https://github.com/Homebrew/homebrew-core

> https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-core.git

对应位置

> /home/linuxbrew/.linuxbrew/Homebrew/Library/Taps/homebrew/homebrew-core


3. brew-cask

> https://formulae.brew.sh/cask/

> https://github.com/Homebrew/homebrew-cask

> https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-cask.git

对应位置

> /home/linuxbrew/.linuxbrew/Homebrew/Library/Taps/homebrew/homebrew-cask


4. 主库

> https://formulae.brew.sh/

> https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles

brew

1. 安装

> brew install

2. 移除

> brew uninstall

> brew remove

3. 自动移除

> brew autoremove

4. 查找(远程存储库)

> brew search 软件名

5. 列出(已安装)

> brew list

6. 更新

> brew update

> brew upgrade

7. 详细信息

> brew info

8. 清理(旧版本)

> brew cleanup

9. 查看缓存路径

> brew --cache

brew cask

1. 安装

> brew install --cask

2. 列出(已安装 cask)

> brew list --casks

3. 搜索

> brew search --cask

参考

1. 官方文档

> https://docs.brew.sh/Homebrew-on-Linux

2. 清华大学镜像源

> https://mirrors.tuna.tsinghua.edu.cn/help/homebrew/

> https://mirrors.tuna.tsinghua.edu.cn/help/homebrew-bottles/

3. 网友博客

> https://www.mintimate.cn/2020/04/05/Homebrew/

PS:macOS与Linux存在一些区别(特别是cask),安装路径也不一样,不一定适用于Linux。



在Linux使用brew(更新版)的评论 (共 条)

分享到微博请遵守国家法律