I come to this issue whenever I try to run Flutter command on command prompt on Windows 10 Pro.
PS C:\src\flutter> flutter doctor
Building flutter tool...
Running pub upgrade...
/C:/Users/laich/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/build-1.2.1/lib/src/analyzer/resolver.dart:6:8: Error: Error when reading '/C:/Users/laich/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/analyzer-0.38.5/lib/dart/element/element.dart': The system cannot find the path specified.
import 'package:analyzer/dart/element/element.dart';
^
/C:/Users/laich/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/build-1.2.1/lib/src/builder/build_step.dart:7:8: Error: Error when reading '/C:/Users/laich/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/analyzer-0.38.5/lib/dart/element/element.dart': The system cannot find the path specified.
import 'package:analyzer/dart/element/element.dart';
^
/C:/Users/laich/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/linter-0.1.101/lib/src/ast.dart:8:8: Error: Error when reading '/C:/Users/laich/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/analyzer-0.38.5/lib/dart/element/element.dart': The system cannot find the path specified.
import 'package:analyzer/dart/element/element.dart';
^
/C:/Users/laich/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/build-1.2.1/lib/src/builder/build_step_impl.dart:7:8: Error: Error when reading '/C:/Users/laich/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/analyzer-0.38.5/lib/dart/element/element.dart': The system cannot find the path specified.
import 'package:analyzer/dart/element/element.dart';
^
/C:/Users/laich/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/analyzer-0.38.5/lib/src/lint/linter.dart:11:8: Error: Error when reading '/C:/Users/laich/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/analyzer-0.38.5/lib/dart/element/element.dart': The system cannot find the path specified.
import 'package:analyzer/dart/element/element.dart';
^
Error: Unable to create dart snapshot for flutter tool.
Looking like it gets stuck at
running pub upgrade
How can this be fixed?
Navigate to the flutter install directory and run the following commands
git clean -xfd
git stash save --keep-index
git stash drop
git pull
flutter doctor
And your problem should be fixed.
Note:
For those on windows, if you use git bash
you'll have a problem like: Downloading Dart SDK from Flutter engine fee001c93f25a1e7258e762781a7361f122d29f5... Unknown operating system. Cannot install Dart SDK.
Use windows terminal directly.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.