• Mac安装Dart时,Homebrew报错 Error: Failure while executing


    前言:

    最近准备开发Flutter项目时,在安装环境时,安装Homebew时遇到了以下报错信息,在这里分享一下。

    报错信息:

    ~ % brew tap dart-lang/dart
    ==> Tapping dart-lang/dart
    Cloning into '/opt/homebrew/Library/Taps/dart-lang/homebrew-dart'...
    fatal: unable to access 'https://github.com/dart-lang/homebrew-dart/': LibreSSL SSL_connect: SSL_ERROR_SYSCALL in connection to github.com:443 
    Error: Failure while executing; `git clone https://github.com/dart-lang/homebrew-dart /opt/homebrew/Library/Taps/dart-lang/homebrew-dart --origin=origin --template= --config core.fsmonitor=false` exited with 128.
    
    • 1
    • 2
    • 3
    • 4
    • 5

    解决方案:

    安装 ARM 版 Homebrew
    ARM版Homebrew最终被安装在/opt/homebrew路径下。

    直接执行:

    /bin/bash -c "$(curl -fsSL https://gitee.com/ineo6/homebrew-install/raw/master/install.sh)"
    
    • 1

    然后还需设置环境变量,具体操作步骤如下,一定要仔细阅读。

    在终端执行命令echo $SHELL获得终端类型:

    /bin/zsh => zsh => .zprofile
    /bin/bash => bash => .bash_profile
    
    • 1
    • 2

    如果看到的是/bin/zsh执行:

    echo 'eval "$(/opt/homebrew/bin/brew shellenv)" #brew.idayer.com' >> ~/.zprofile
    eval "$(/opt/homebrew/bin/brew shellenv)"
    
    • 1
    • 2

    如果看到的是/bin/bash执行:

    echo 'eval "$(/opt/homebrew/bin/brew shellenv)" #brew.idayer.com' >> ~/.bash_profile
    eval "$(/opt/homebrew/bin/brew shellenv)"
    
    • 1
    • 2

    从macOS Catalina(10.15.x) 版开始,Mac使用zsh作为默认Shell。

    Homebrew 安装成功~

    ~ % brew -v
    Homebrew 4.1.7
    
    • 1
    • 2

    然后继续执行

     brew tap dart-lang/dart
     brew install dart
    
    • 1
    • 2

    提示安装失败

    ~ % brew tap dart-lang/dart
    ==> Tapping dart-lang/dart
    Cloning into '/opt/homebrew/Library/Taps/dart-lang/homebrew-dart'...
    
    
    error: RPC failed; curl 35 LibreSSL SSL_read: Operation timed out, errno 60
    fatal: expected flush after ref listing
    Error: Failure while executing; `git clone https://github.com/dart-lang/homebrew-dart /opt/homebrew/Library/Taps/dart-lang/homebrew-dart --origin=origin --template= --config core.fsmonitor=false` exited with 128.
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8

    再次执行效果:

    ~ % brew tap dart-lang/dart
    ==> Tapping dart-lang/dart
    Cloning into '/opt/homebrew/Library/Taps/dart-lang/homebrew-dart'...
    remote: Enumerating objects: 3684, done.
    remote: Counting objects: 100% (1438/1438), done.
    remote: Compressing objects: 100% (437/437), done.
    remote: Total 3684 (delta 1185), reused 1199 (delta 995), pack-reused 2246
    Receiving objects: 100% (3684/3684), 671.61 KiB | 54.00 KiB/s, done.
    Resolving deltas: 100% (2461/2461), done.
    Tapped 22 formulae (53 files, 857.5KB).
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10

    安装成功啦!!!!

    然后安装

    ~ % brew install dart
    ==> Fetching dart-lang/dart/dart
    ==> Downloading https://storage.googleapis.com/dart-archive/channels/stable/release/3.1.
    ############################################                                       54.8%curl: (56) LibreSSL SSL_read: Connection reset by peer, errno 54
    
    Error: dart: Failed to download resource "dart"
    Download failed: https://storage.googleapis.com/dart-archive/channels/stable/release/3.1.0/sdk/dartsdk-macos-arm64-release.zip
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7

    又出现报错信息了

    那我们再次尝试一下呢

    这次就很快安装成功了

    brew install dart
    ==> Downloading https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles/api/formula.jws.js
    ##O#- #                                                                                
    ==> Downloading https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles/api/cask.jws.json
    ##O#- #                                                                                
    ==> Fetching dart-lang/dart/dart
    ==> Downloading https://storage.googleapis.com/dart-archive/channels/stable/release/3.1.
    ################################################################################# 100.0%
    ==> Installing dart from dart-lang/dart
    Warning: A newer Command Line Tools release is available.
    Update them from Software Update in System Preferences.
    
    If that doesn't show you any updates, run:
      sudo rm -rf /Library/Developer/CommandLineTools
      sudo xcode-select --install
    
    Alternatively, manually download them from:
      https://developer.apple.com/download/all/.
    You should download the Command Line Tools for Xcode 14.2.
    
    ==> Caveats
    Please note the path to the Dart SDK:
      /opt/homebrew/opt/dart/libexec
    ==> Summary
    🍺  /opt/homebrew/Cellar/dart/3.1.0: 987 files, 554.3MB, built in 6 seconds
    ==> Running `brew cleanup dart`...
    Disable this behaviour by setting HOMEBREW_NO_INSTALL_CLEANUP.
    Hide these hints with HOMEBREW_NO_ENV_HINTS (see `man brew`).
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28

    安装环境的时候和网络也有一定的关系,我们可以多试两次

    我们我们测试一下安装成功没

    ~ % dart --version
    Dart SDK version: 3.1.0 (stable) (Tue Aug 15 21:33:36 2023 +0000) on "macos_arm64"
    
    • 1
    • 2

    👌👌👌

  • 相关阅读:
    系统架构设计:14 论软基于架构的软件设计方法(ABSD)的软件开发
    SpringBoot中常用校验注解简介说明
    通过IP地址查询避免电子招投标串标的方法
    【Ubuntu】安装gRPC
    docker系列(9) - docker-compose
    【编译原理实验】 -- 词法分析程序设计原理与实现(C语言实现)
    无代码开发平台数据ID入门教程
    webpack优化系列三:vue子目录路径更改---publicPath
    C# out参数out多个参数
    Fake Maxpooling 二维滑动窗口
  • 原文地址:https://blog.csdn.net/qq_37255976/article/details/132603606