Arm Mac 的编译环境配置

进击的学霸...大约 2 分钟

添置了 mbp14 ,记录下开发环境的配置。

安装 Homebrew

使用科大源安装,具体见 官方文档open in new window

# 设置环境变量
export HOMEBREW_BREW_GIT_REMOTE="https://mirrors.ustc.edu.cn/brew.git"
export HOMEBREW_CORE_GIT_REMOTE="https://mirrors.ustc.edu.cn/homebrew-core.git"
export HOMEBREW_BOTTLE_DOMAIN="https://mirrors.ustc.edu.cn/homebrew-bottles"

# 运行安装脚本(cdn版)
/bin/bash -c "$(curl -fsSL https://cdn.jsdelivr.net/gh/Homebrew/install@HEAD/install.sh)"

运行之后就开始刷命令行,会要求输入 sudo 密码,需要注意的就是后面有一步下载和安装 Command Line Tools for Xcode 时间会比较久,这要它也没有进度条,看起来就像失去响应了一样,这里只要没有报错,就耐心等待吧。

第一遍安装给我报了个错 Fetching /opt/homebrew failed! ,我直接拿安装脚本又安装了一遍,这次就可以了,命令行最后输出了

==> Next steps:
- Run these two commands in your terminal to add Homebrew to your PATH:
    echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> /Users/leo/.zprofile
    eval "$(/opt/homebrew/bin/brew shellenv)"
- Run these commands in your terminal to add the non-default Git remotes for Homebrew/brew and Homebrew/homebrew-core:
    echo 'export HOMEBREW_BREW_GIT_REMOTE="https://mirrors.ustc.edu.cn/brew.git"' >> /Users/leo/.zprofile
    echo 'export HOMEBREW_CORE_GIT_REMOTE="https://mirrors.ustc.edu.cn/homebrew-core.git"' >> /Users/leo/.zprofile
    export HOMEBREW_BREW_GIT_REMOTE="https://mirrors.ustc.edu.cn/brew.git"
    export HOMEBREW_CORE_GIT_REMOTE="https://mirrors.ustc.edu.cn/homebrew-core.git"
- Run brew help to get started
- Further documentation:
    https://docs.brew.sh

按照命令里要求的依次执行这些命令后,输入 brew -v ,能看到输出版本号,就算安装完了

安装 oh my zsh

sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"

# set alias
vim ~/.zshrc
# alias code="/Applications/Visual\ Studio\ Code.app/Contents/Resources/app/bin/code"
# 在文件底部按照示例新增后运行使生效
source ~/.zshrc
  • 创建 ~/.bash_profile 文件

  • vim ~/.bash_profile 文件,进行环境变量的配置

  • 完了之后使用zsh终端发现配置的环境变量还是无效,每次打开 zsh 都需要手动 source ~/.bash_profile

  • 解决方案:修改zsh的配置文件,让其在每次启动的时候来读取 ~/.bash_profile 里面的配置。vim ~/.zshrc 在文件的最后面加上source ~/.bash_profile

  • source ~/.zshrc 使其立即生效

安装及配置 Git

brew install git

# 查看 git 版本
git --version
# 生成公私钥
ssh-keygen -o
# 查看公钥
cat ~/.ssh/id_rsa.pub

# git 用户名和邮箱 全局配置
git config --global user.name "goodlcw1"
git config --global user.email "goodlcw1@163.com"

# 查看全局配置
git config --global user.name
git config --global user.email

# git 用户名和邮箱 局部配置
git config user.name "goodlcw1"
git config user.email "goodlcw1@163.com"

# 查看局部配置
git config user.name
git config user.email

安装 Node 及相关

访问 官网open in new window 下载最新的稳定版安装包,下载完成后一路下一步即可

# 安装 pnpm
brew install pnpm
# 安装 nvm,并按照输出操作
brew install nvm
# nvm 的环境变量按上文 zsh 部分设置
# nvm 安装 node,不要安装 14 ,会因为 arm 芯片兼容性报错
nvm install 16
# 安装 nrm
sudo npm i nrm -g 
# 安装 yarn
sudo npm i yarn -g

安装 Docker

访问 官网open in new window 下载 Docker Desktop

一键同步

  1. VSCode 登录账号,一键同步插件及配置
  2. Chrome 登录账号,一键同步插件及书签
评论
  • 按正序
  • 按倒序
  • 按热度