安装dart报错,下载软件包失败,错误如下
$ brew install dart
Updating Homebrew...
==> Installing dart from dart-lang/dart
==> Downloading https://storage.googleapis.com/dart-archive/channels/stable/rele
-=O=- # # # #
curl: (35) LibreSSL SSL_connect: SSL_ERROR_SYSCALL in connection to storage.googleapis.com:443
Error: An exception occurred within a child process:
DownloadError: Failed to download resource "dart"
Download failed: https://storage.googleapis.com/dart-archive/channels/stable/release/2.7.2/sdk/dartsdk-macos-x64-release.zip
下载安装包失败,这里给出了下载地址,Download failed:https://storage.googleapis.com/dart-archive/channels/stable/release/2.7.2/sdk/dartsdk-macos-x64-release.zip
-
这时我们可以去上面的网址手动下载对应的安装包
-
然后获取Homebrew的缓存目录
$ brew --cache
/Users/apple/Library/Caches/Homebrew
-
把我们下载好的安装包拷贝到缓存目录
$ cp ~/Downloads/dartsdk-macos-x64-release.zip /Users/shockerli/Library/Caches/Homebrew/
-
再次执行安装命令
$ brew upgrade dart
Updating Homebrew...
Error: dart-lang/dart/dart not installed
AppledeiMac:~ apple$ brew install dart
Updating Homebrew...
==> Installing dart from dart-lang/dart
==> Downloading https://storage.googleapis.com/dart-archive/channels/stable/rele
-=O=- # # # #
curl: (35) LibreSSL SSL_connect: SSL_ERROR_SYSCALL in connection to storage.googleapis.com:443
Error: An exception occurred within a child process:
DownloadError: Failed to download resource "dart"
Download failed: https://storage.googleapis.com/dart-archive/channels/stable/release/2.7.2/sdk/dartsdk-macos-x64-release.zip
发现还是报错了
-
这时我们执行brew install dart -v 打印详细日志
$ brew install dart -v
Updating Homebrew...
==> Installing dart from dart-lang/dart
/usr/bin/sandbox-exec -f /private/tmp/homebrew20200429-26224-5vo5ly.sb nice ruby -W0 -I $LOAD_PATH -- /usr/local/Homebrew/Library/Homebrew/build.rb /usr/local/Homebrew/Library/Taps/dart-lang/homebrew-dart/dart.rb --verbose
==> Downloading https://storage.googleapis.com/dart-archive/channels/stable/release/2.7.2/sdk/dartsdk-macos-x64-release.zip
/usr/bin/curl --disable --globoff --show-error --user-agent Homebrew/2.2.14\ \(Macintosh\;\ Intel\ Mac\ OS\ X\ 10.15.4\)\ curl/7.64.1 --fail --retry 3 --location --remote-time --continue-at 0 --output /Users/apple/Library/Caches/Homebrew/downloads/c0b5340940a63cd5a2bced72945b4f1c102aad6aa5da600d196c1805d2a336a6--dartsdk-macos-x64-release.zip.incomplete https://storage.googleapis.com/dart-archive/channels/stable/release/2.7.2/sdk/dartsdk-macos-x64-release.zip
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- 0:01:15 --:--:-- 0
curl: (7) Failed to connect to storage.googleapis.com port 443: Operation timed out
Error: An exception occurred within a child process:
DownloadError: Failed to download resource "dart"
Download failed: https://storage.googleapis.com/dart-archive/channels/stable/release/2.7.2/sdk/dartsdk-macos-x64-release.zip
我们注意到有这样一条信息 /Users/apple/Library/Caches/Homebrew/downloads/c0b5340940a63cd5a2bced72945b4f1c102aad6aa5da600d196c1805d2a336a6--dartsdk-macos-x64-release.zip.incomplete
就是dart文件下载未完成,我们Command+Shift+G 前往文件夹 /Users/apple/Library/Caches/Homebrew
看到download文件夹中确实有c0b5340940a63cd5a2bced72945b4f1c102aad6aa5da600d196c1805d2a336a6--dartsdk-macos-x64-release.zip.incomplete这样一个文件,这时我们把之前下载好的dart压缩安装包的名字改为c0b5340940a63cd5a2bced72945b4f1c102aad6aa5da600d196c1805d2a336a6--dartsdk-macos-x64-release.zip(就是上面文件名去掉.incomplete),并放入到download文件夹中
-
再次执行brew install dart -v即可
-
如果安装过程中遇到Error: An exception occurred within a child process:ChecksumMismatchError: SHA256 mismatch
$ brew install dart -v
Updating Homebrew...
==> Installing dart from dart-lang/dart
/usr/bin/sandbox-exec -f /private/tmp/homebrew20200429-38199-16ne2gr.sb nice ruby -W0 -I $LOAD_PATH -- /usr/local/Homebrew/Library/Homebrew/build.rb /usr/local/Homebrew/Library/Taps/dart-lang/homebrew-dart/dart.rb --verbose
==> Downloading https://storage.googleapis.com/dart-archive/channels/stable/release/2.7.2/sdk/dartsdk-macos-x64-release.zip
Already downloaded: /Users/apple/Library/Caches/Homebrew/downloads/c0b5340940a63cd5a2bced72945b4f1c102aad6aa5da600d196c1805d2a336a6--dartsdk-macos-x64-release.zip
==> Verifying c0b5340940a63cd5a2bced72945b4f1c102aad6aa5da600d196c1805d2a336a6--dartsdk-macos-x64-release.zip checksum
Error: An exception occurred within a child process:
ChecksumMismatchError: SHA256 mismatch
Expected: 529281db2b4450c1aabdda0e6c53ccfa5709869dae56d248fb62365c0ea03f84
Actual: e5b67c8fb21a8d8c13a9c37b6d9ccf9b3735876558a0c5d63c80a2f64cdcd245
Archive: /Users/apple/Library/Caches/Homebrew/downloads/c0b5340940a63cd5a2bced72945b4f1c102aad6aa5da600d196c1805d2a336a6--dartsdk-macos-x64-release.zip
To retry an incomplete download, remove the file above.
- 我们注意到上面的几行命令
Error: An exception occurred within a child process:
ChecksumMismatchError: SHA256 mismatch
Expected: 529281db2b4450c1aabdda0e6c53ccfa5709869dae56d248fb62365c0ea03f84
Actual: e5b67c8fb21a8d8c13a9c37b6d9ccf9b3735876558a0c5d63c80a2f64cdcd245
错误:在子进程中发生异常:
ChecksumMismatchError: SHA256不匹配
预期:529281 db2b4450c1aabdda0e6c53ccfa5709869dae56d248fb62365c0ea03f84
实际:e5b67c8fb21a8d8c13a9c37b6d9ccf9b3735876558a0c5d63c80a2f64cdcd245)
解决办法如下:命令行输入brew edit dart(或command+shift+g前往/usr/local/Homebrew/Library/Taps/dart-lang/homebrew-dart/dart.rb文件夹编辑修改)
$ brew edit dart
Editing /usr/local/Homebrew/Library/Taps/dart-lang/homebrew-dart/dart.rb
Warning: Using vim because no editor was set in the environment.
This may change in the future, so we recommend setting EDITOR,
or HOMEBREW_EDITOR to your preferred text editor.
class Dart < Formula
desc "The Dart SDK"
homepage "https://dart.dev"
conflicts_with "dart-beta", :because => "dart-beta ships the same binaries"
version "2.7.2"
if OS.mac?
url "https://storage.googleapis.com/dart-archive/channels/stable/release/2.7.2/sdk/dartsdk-macos-x64-release.zip"
sha256 "529281db2b4450c1aabdda0e6c53ccfa5709869dae56d248fb62365c0ea03f84"
elsif OS.linux? && Hardware::CPU.intel?
if Hardware::CPU.is_64_bit?
url "https://storage.googleapis.com/dart-archive/channels/stable/release/2.7.2/sdk/dartsdk-linux-x64-release.zip"
sha256 "9b1434cd60c56aa39d66575b0cc9ea0a16877abf09475f86950d571d547b7a6f"
else
url "https://storage.googleapis.com/dart-archive/channels/stable/release/2.7.2/sdk/dartsdk-linux-ia32-release.zip"
sha256 "158d984c679c0099f8e099ca351f30ab190dbf337a8fd30b63e366ce450b4036"
end
elsif OS.linux? && Hardware::CPU.arm?
if Hardware::CPU.is_64_bit?
url "https://storage.googleapis.com/dart-archive/channels/stable/release/2.7.2/sdk/dartsdk-linux-arm64-release.zip"
sha256 "57a856e0fa199b6c9e80182a1a9c5223d2e1073be6d5a6eaf560cf00db74c6dc"
else
url "https://storage.googleapis.com/dart-archive/channels/stable/release/2.7.2/sdk/dartsdk-linux-arm-release.zip"
sha256 "dbab7fe86ba5b2a8b4c99ea7055bf8bc681c7804503b844a9ff1061dce53ea12"
end
end
devel do
version "2.9.0-4.0.dev"
if OS.mac?
url "https://storage.googleapis.com/dart-archive/channels/dev/release/2.9.0-4.0.dev/sdk/dartsdk-macos-x64-release.zip"
sha256 "3a4977e7dc69848261c2ffbd770c2ae60b0531a54c902355dfba67bcd70d493e"
elsif OS.linux? && Hardware::CPU.intel?
if Hardware::CPU.is_64_bit?
url "https://storage.googleapis.com/dart-archive/channels/dev/release/2.9.0-4.0.dev/sdk/dartsdk-linux-x64-release.zip"
sha256 "594c7931424ceb0e849cfed167129eaed99fb6aab17ee021600b8fe50441a999"
else
根据提示把上面文件
“529281db2b4450c1aabdda0e6c53ccfa5709869dae56d248fb62365c0ea03f84”改为“e5b67c8fb21a8d8c13a9c37b6d9ccf9b3735876558a0c5d63c80a2f64cdcd245”不出意外,再次执行brew install dart -v命令即可
安装完成后查看Dart版本dart --version
$ brew install dart -v
Updating Homebrew...
==> Installing dart from dart-lang/dart
/usr/bin/sandbox-exec -f /private/tmp/homebrew20200429-1792-owx1ca.sb nice ruby -W0 -I $LOAD_PATH -- /usr/local/Homebrew/Library/Homebrew/build.rb /usr/local/Homebrew/Library/Taps/dart-lang/homebrew-dart/dart.rb --verbose
==> Downloading https://storage.googleapis.com/dart-archive/channels/stable/release/2.7.2/sdk/dartsdk-macos-x64-release.zip
Already downloaded: /Users/apple/Library/Caches/Homebrew/downloads/c0b5340940a63cd5a2bced72945b4f1c102aad6aa5da600d196c1805d2a336a6--dartsdk-macos-x64-release.zip
==> Verifying c0b5340940a63cd5a2bced72945b4f1c102aad6aa5da600d196c1805d2a336a6--dartsdk-macos-x64-release.zip checksum
unzip -o /Users/apple/Library/Caches/Homebrew/downloads/c0b5340940a63cd5a2bced72945b4f1c102aad6aa5da600d196c1805d2a336a6--dartsdk-macos-x64-release.zip -d /private/tmp/d20200429-1793-1k6r6ut
cp -pR /private/tmp/d20200429-1793-1k6r6ut/dartsdk-macos-x64-release/. /private/tmp/dart-20200429-1793-kpufzc/dartsdk-macos-x64-release
chmod -Rf +w /private/tmp/d20200429-1793-1k6r6ut
==> Cleaning
==> Finishing up
ln -s ../Cellar/dart/2.7.2/bin/dart dart
ln -s ../Cellar/dart/2.7.2/bin/dart2js dart2js
ln -s ../Cellar/dart/2.7.2/bin/dart2native dart2native
ln -s ../Cellar/dart/2.7.2/bin/dartanalyzer dartanalyzer
ln -s ../Cellar/dart/2.7.2/bin/dartaotruntime dartaotruntime
ln -s ../Cellar/dart/2.7.2/bin/dartdevc dartdevc
ln -s ../Cellar/dart/2.7.2/bin/dartdoc dartdoc
ln -s ../Cellar/dart/2.7.2/bin/dartfmt dartfmt
ln -s ../Cellar/dart/2.7.2/bin/pub pub
/usr/bin/sandbox-exec -f /private/tmp/homebrew20200429-2042-1zq9nk.sb nice ruby -W0 -I $LOAD_PATH -- /usr/local/Homebrew/Library/Homebrew/postinstall.rb /usr/local/Homebrew/Library/Taps/dart-lang/homebrew-dart/dart.rb
==> Caveats
Please note the path to the Dart SDK:
/usr/local/opt/dart/libexec
==> Summary
/usr/local/Cellar/dart/2.7.2: 474 files, 463.3MB, built in 9 minutes 27 seconds
AppledeiMac:~ apple$ dart --version
Dart VM version: 2.7.2 (Mon Mar 23 22:11:27 2020 +0100) on "macos_x64"