树莓派安装Homebrew全过程
首先,各大Linux官方一般都有自己的包管理器,一般首选官方的包管理器。
安装一些依赖:sudo apt install ruby build-essential
官方的给出的一键安装命令:
sh -c "$(curl -fsSL https://raw.githubusercontent.com/Linuxbrew/install/master/install.sh)"
此时很可能出现错误:curl: (7) Failed to connect to raw.githubusercontent.com port 443: Connection refused
如果官方安装太慢或者出现这个错误按照下文的操作!
官方的安装太慢,我们可以更改安装源为国内的源(我更改的是国内的清华源)。接下来将一步步讲解。
-
下载安装检查脚本:
-
如果有wget,可以尝试使用wget下载:
wget https://raw.githubusercontent.com/Linuxbrew/install/master/install.sh -O install.sh
如果出现错误:
Resolving raw.githubusercontent.com (raw.githubusercontent.com)... 151.101.228.133 Connecting to raw.githubusercontent.com (raw.githubusercontent.com)|151.101.228.133|:443... failed: Connection refused.
请使用下面的方法!
-
直接使用浏览器打开链接
https://raw.githubusercontent.com/Linuxbrew/install/master/install.sh
,看到的内容全部复制下来,创建一个文件命名为install.sh
,把复制的内容全部粘贴再这里面。
-
-
更改安装检查脚本:
在安装检查脚本里面有一行:
exec ruby -e "`curl -fsSL https://raw.githubusercontent.com/Linuxbrew/install/master/install`" "[email protected]"
我们需要更改为:
exec ruby "install_linux.rb" "[email protected]"
-
下载安装文件:
-
如果有wget,可以尝试使用wget下载:
wget https://raw.githubusercontent.com/Linuxbrew/install/master/install -O install_linux.rb
如果出现错误:
Resolving raw.githubusercontent.com (raw.githubusercontent.com)... 151.101.228.133 Connecting to raw.githubusercontent.com (raw.githubusercontent.com)|151.101.228.133|:443... failed: Connection refused.
请使用下面的方法!
-
直接使用浏览器打开链接
https://raw.githubusercontent.com/Linuxbrew/install/master/install
,看到的内容全部复制下来,创建一个文件命名为install_linux.rb
,把复制的内容全部粘贴再这里面。
-
-
更改安装文件:
修改官方文件里面的源:
在
BREW_REPO = "https://github.com/Homebrew/brew".freeze
前加#
号 在下方加入一行:
BREW_REPO = "https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/brew.git".freeze
接下来给安装检查文件加上执行权限:chmod +x install.sh
,然后执行./install.sh
等待安装,不出意外就会看见:
==> Homebrew is run entirely by unpaid volunteers. Please consider donating:
https://github.com/Homebrew/brew#donations
==> Tapping homebrew/core
Cloning into '/home/linuxbrew/.linuxbrew/Homebrew/Library/Taps/homebrew/homebrew-core'...
下载仓库的地址在国外,下载会比较慢,我们可以手动下载。
首先使用组合键CTRL+C
关闭安装过程,
创建目录:
mkdir /home/linuxbrew/.linuxbrew/Homebrew/Library/Taps/homebrew
,
进入目录:
cd /home/linuxbrew/.linuxbrew/Homebrew/Library/Taps/homebrew
。
然后执行:
git clone https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-core.git
git clone https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-cask.git
git clone https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-cask-fonts.git
git clone https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-cask-drivers.git
回到原来目录:cd -
再次执行:./install.sh
执行后会提示:
- Configure Homebrew in your ~/.profile by running
echo 'eval $(/home/linuxbrew/.linuxbrew/bin/brew shellenv)' >>~/.profile
- Add Homebrew to your PATH
eval $(/home/linuxbrew/.linuxbrew/bin/brew shellenv)
- 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/linuxbrew/.linuxbrew/bin is not in your PATH.
如果出现了这个Warning
则需要手动进行一些操作:
如果是bash用户:
- 编辑
.profile
或者.bash_profile
,添加一行:eval $(/home/linuxbrew/.linuxbrew/bin/brew shellenv)
如果是zsh用户:
- 编辑
.zhcrc
,添加一行eval $(/home/linuxbrew/.linuxbrew/bin/brew shellenv)
重启一下或者直接在命令行执行:eval $(/home/linuxbrew/.linuxbrew/bin/brew shellenv)
,就可以正常使用brew。
使用过程中更换为国内的源使用起来更加舒适
更换brew的源为清华源:
git -C /home/linuxbrew/.linuxbrew/Homebrew remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/brew.git
git -C /home/linuxbrew/.linuxbrew/Homebrew/Library/Taps/homebrew/homebrew-core remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-core.git
git -C /home/linuxbrew/.linuxbrew/Homebrew/Library/Taps/homebrew/homebrew-cask remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-cask.git
git -C /home/linuxbrew/.linuxbrew/Homebrew/Library/Taps/homebrew/homebrew-cask-fonts remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-cask-fonts.git
git -C /home/linuxbrew/.linuxbrew/Homebrew/Library/Taps/homebrew/homebrew-cask-drivers remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-cask-drivers.git
brew update
更改bintray镜像:
临时更改:export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles
长期更改:
-
bash用户
echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles' >> ~/.bash_profile source ~/.profile
-
zsh用户
echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.ustc.edu.cn/homebrew-bottles' >> ~/.zshrc source ~/.zshrc
上一篇: MySQL无法启动1067错误的又一种解决方法(机房断电)_MySQL
下一篇: PHP购物车
推荐阅读
-
树莓派4B安装64位Linux(不用显示器键盘鼠标)
-
树莓派 msmtp和mutt 的安装和配置
-
树莓派4安装Ubuntu 19.10的教程详解
-
树莓派安装Docker的方法步骤
-
树莓派安装.net core 2.1
-
高手在民间 树莓派成功安装运行Win11系统:比Win10还流畅
-
树莓派养成之路 ——系统安装
-
树莓派-10-sudo apt-get install 安装软件报错
-
sudo apt install thonny 树莓派安装thonny无法定位软件包 换源
-
视频图文教学 - 用最快的速度把 DotNet Core Blazor 程序安装到 树莓派中 并且用网页控制 GPIO 闪灯