@@ -276,13 +276,16 @@ class UpdatePackagesCommand extends FlutterCommand {
276276 final File fakePackage = _pubspecFor (tempDir);
277277 fakePackage.createSync ();
278278 fakePackage.writeAsStringSync (_generateFakePubspec (dependencies.values));
279- // First, we create a synthetic flutter SDK so that transitive flutter SDK
279+ // Create a synthetic flutter SDK so that transitive flutter SDK
280280 // constraints are not affected by this upgrade.
281- final Directory temporaryFlutterSdk = createTemporaryFlutterSdk (
282- globals.fs,
283- globals.fs.directory (Cache .flutterRoot),
284- pubspecs,
285- );
281+ Directory temporaryFlutterSdk;
282+ if (upgrade) {
283+ temporaryFlutterSdk = createTemporaryFlutterSdk (
284+ globals.fs,
285+ globals.fs.directory (Cache .flutterRoot),
286+ pubspecs,
287+ );
288+ }
286289
287290 // Next we run "pub upgrade" on this generated package:
288291 await pub.get (
@@ -291,13 +294,15 @@ class UpdatePackagesCommand extends FlutterCommand {
291294 upgrade: true ,
292295 checkLastModified: false ,
293296 offline: offline,
294- flutterRootOverride: temporaryFlutterSdk.path,
297+ flutterRootOverride: upgrade
298+ ? temporaryFlutterSdk.path
299+ : null ,
295300 );
296301 // Cleanup the temporary SDK
297302 try {
298- temporaryFlutterSdk.deleteSync (recursive: true );
303+ temporaryFlutterSdk? .deleteSync (recursive: true );
299304 } on FileSystemException {
300- // So sad.. .
305+ // Failed to delete temporary SDK .
301306 }
302307
303308 // Then we run "pub deps --style=compact" on the result. We pipe all the
0 commit comments