Fix a crash (#7597) when the flutter sdk moves after getting packages (#7601)

* Add a check in case the flutter directory in .packages no longer exists. Clean up and prompt user

* Update documentation to use flutter packages get for end-users instead of flutter update-packages.

* Merge missing sdk error with the multiple sdk error. They're really the same thing.

* Use flutterPath in both checks.

* Change file_system’s copy folder to copy director which takes into account the file system

* Test support files

* Add test and split into 2 messages again.

* Move tests to run in memory file system's copy. Tested with dev/bots/test.sh
This commit is contained in:
xster
2017-01-26 15:43:28 -08:00
committed by GitHub
parent bc04c53231
commit 682c7992e5
6 changed files with 64 additions and 8 deletions

View File

@@ -352,14 +352,28 @@ class FlutterCommandRunner extends CommandRunner<Null> {
Uri rootUri = flutterUri.resolve('../../..');
String flutterPath = path.normalize(fs.file(rootUri).absolute.path);
if (!_compareResolvedPaths(flutterPath, Cache.flutterRoot)) {
if (!fs.isDirectorySync(flutterPath)) {
printError(
'Warning: the \'flutter\' tool you are currently running is different from the one referenced in your pubspec.yaml:\n'
' running Flutter : ${Cache.flutterRoot}\n'
' pubspec reference: $flutterPath\n'
'This can happen when you have multiple copies of flutter installed. Please check your system path to verify\n'
'that you\'re running the expected version (run \'flutter --version\' to see which flutter is on your path). You\n'
'can also change which flutter your project points to by editing the \'flutter:\' path in your pubspec.yaml file.\n'
'Warning! This package referenced a Flutter repository via the .packages file that is\n'
'no longer available. The repository from which the \'flutter\' tool is currently\n'
'executing will be used instead.\n'
' running Flutter tool: ${Cache.flutterRoot}\n'
' previous reference : $flutterPath\n'
'This can happen if you deleted or moved your copy of the Flutter repository, or\n'
'if it was on a volume that is no longer mounted or has been mounted at a\n'
'different location. Please check your system path to verify that you are running\n'
'the expected version (run \'flutter --version\' to see which flutter is on your path).\n'
);
} else if (!_compareResolvedPaths(flutterPath, Cache.flutterRoot)) {
printError(
'Warning! The \'flutter\' tool you are currently running is from a different Flutter\n'
'repository than the one last used by this package. The repository from which the\n'
'\'flutter\' tool is currently executing will be used instead.\n'
' running Flutter tool: ${Cache.flutterRoot}\n'
' previous reference : $flutterPath\n'
'This can happen when you have multiple copies of flutter installed. Please check\n'
'your system path to verify that you are running the expected version (run\n'
'\'flutter --version\' to see which flutter is on your path).\n'
);
}
}