avatar

解决macOS下VS Code启动时报错的问题

解决macOS下VS Code启动时报错的问题

问题复现

MAC升级到macOS Monterey,每次重启电脑之后打开VS Code,右下角都有一个错误弹窗:
Unable to resolve your shell environment in a reasonable time. Please review your shell configuration.

而且重启电脑后,打开terminal时,也有很长时间卡住的现象(这时zsh的标题窗口一直卡在xcodebuild上)

解决问题

由于terminal卡在xcodebuild上,推断是系统升级后xcode的问题,百度了一番,说是内置git的问题,解决方案如下:

  1. 通过homebrew安装git

    1
    brew install git
  2. 编辑.zshrc,将新装的git路径加入PATH中

    1
    vim ~/.zshrc 

    .zshrc文件内容如下:

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    export ZSH="/Users/williampeng/.oh-my-zsh"
    ZSH_DISABLE_COMPFIX="true"
    DISABLE_AUTO_UPDATE="true"
    ZSH_THEME="ys"
    DISABLE_AUTO_UPDATE="true"
    #plugins=(git osx brew)
    plugins=(osx brew)
    export PATH="/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/sbin:/usr/local/opt/node@14/bin:/Users/williampeng/.composer/vendor/bin:/usr/local/Cellar/git/2.36.1/bin:$PATH"
    export LDFLAGS="-L/usr/local/opt/openssl/lib"

    source $ZSH/oh-my-zsh.sh

    zmodload zsh/zprof
    #export JAVA_HOME=/Applications/Android\ Studio.app/Contents/jre/jdk/Contents/Home
    export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.ustc.edu.cn/homebrew-bottles
文章作者: pengweifu
文章链接: https://www.pengwf.com/2022/09/08/other/macOS-VSCode-Error/
版权声明: 本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自 麦子的博客
打赏
  • 微信
    微信
  • 支付宝
    支付宝

评论