解决flutter升级卡住的问题

944 阅读1分钟

升级卡住,提示

Waiting for another flutter command to release the startup lock

首先解决掉这个

有两种方法

1.把这个进程干掉

killall -9 dart

Remove lockfile

<flutter folder>/bin/cache/lockfile

2.进程太多,干不过来

ps aux
ps aux | grep flutter
ps aux | grep flutter | awk '{print $2}'
kill $(ps aux | grep flutter | grep -v grep  | awk '{print $2}')

这时候发现flutter已经半路卡死用不了

执行

flutter doctor

开始自我修复下载了,但速度好慢

然后换镜像

我之前用的

export PUB_HOSTED_URL=https://pub.flutter-io.cn 
export FLUTTER_STORAGE_BASE_URL=https://storage.flutter-io.cn

虽然上推荐,但还是太慢,升级要三个小时

换腾讯源

export PUB_HOSTED_URL=https://mirrors.cloud.tencent.com/dart-pub
export FLUTTER_STORAGE_BASE_URL=https://mirrors.cloud.tencent.com/flutter

我用的zsh,所以就是修改.zsh文件,完事记得source .zshrc

结果到了169M,提示

  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
 81  209M   81  169M    0     0   517k      0  0:06:54  0:05:36  0:01:18  408k
curl: (18) transfer closed with 41498439 bytes remaining to read

Failed to retrieve the Dart SDK from: https://mirrors.cloud.tencent.com/flutter/flutter_infra_release/flutter/57d3bac3dd5cb5b0e464ab70e7bc8a0d8cf083ab/dart-sdk-darwin-x64.zip
If you're located in China, please see this page:
  https://flutter.dev/community/china

继续换清华源

$ export PUB_HOSTED_URL=http://mirrors.cnnic.cn/dart-pub
$ export FLUTTER_STORAGE_BASE_URL=http://mirrors.cnnic.cn/flutter

然后速度就很快了