| Index: utils/pub/pub.dart | 
| diff --git a/utils/pub/pub.dart b/utils/pub/pub.dart | 
| index dcd76c68c4d8895399ab7c5702362109e6c6775f..db628d03157cdb811e2d28078b7397952053c0fa 100644 | 
| --- a/utils/pub/pub.dart | 
| +++ b/utils/pub/pub.dart | 
| @@ -235,43 +235,34 @@ abstract class PubCommand { | 
| exit(_chooseExitCode(error)); | 
| } | 
|  | 
| -    var future = new Future.immediate(null); | 
| -    if (requiresEntrypoint) { | 
| -      // TODO(rnystrom): Will eventually need better logic to walk up | 
| -      // subdirectories until we hit one that looks package-like. For now, just | 
| -      // assume the cwd is it. | 
| -      future = Entrypoint.load(path.current, cache); | 
| -    } | 
| - | 
| -    future = future.then((entrypoint) { | 
| -      this.entrypoint = entrypoint; | 
| -      try { | 
| -        var commandFuture = onRun(); | 
| -        if (commandFuture == null) return true; | 
| +    defer(() { | 
| +      if (requiresEntrypoint) { | 
| +        // TODO(rnystrom): Will eventually need better logic to walk up | 
| +        // subdirectories until we hit one that looks package-like. For now, | 
| +        // just assume the cwd is it. | 
| +        entrypoint = new Entrypoint(path.current, cache); | 
| +      } | 
|  | 
| -        return commandFuture; | 
| -      } catch (error, trace) { | 
| -        handleError(error, trace); | 
| +      var commandFuture = onRun(); | 
| +      if (commandFuture == null) return true; | 
| + | 
| +      return commandFuture; | 
| +    }).whenComplete(() => cache_.deleteTempDir()).catchError((asyncError) { | 
| +      var e = asyncError.error; | 
| +      if (e is PubspecNotFoundException && e.name == null) { | 
| +        e = 'Could not find a file named "pubspec.yaml" in the directory ' | 
| +          '${path.current}.'; | 
| +      } else if (e is PubspecHasNoNameException && e.name == null) { | 
| +        e = 'pubspec.yaml is missing the required "name" field (e.g. "name: ' | 
| +          '${basename(path.current)}").'; | 
| } | 
| -    }); | 
|  | 
| -    future | 
| -      .then((_) => cache_.deleteTempDir()) | 
| -      .catchError((asyncError) { | 
| -        var e = asyncError.error; | 
| -        if (e is PubspecNotFoundException && e.name == null) { | 
| -          e = 'Could not find a file named "pubspec.yaml" in the directory ' | 
| -            '${path.current}.'; | 
| -        } else if (e is PubspecHasNoNameException && e.name == null) { | 
| -          e = 'pubspec.yaml is missing the required "name" field (e.g. "name: ' | 
| -            '${basename(path.current)}").'; | 
| -        } | 
| - | 
| -        handleError(e, asyncError.stackTrace); | 
| -      }) | 
| +      handleError(e, asyncError.stackTrace); | 
| +    }).then((_) { | 
| // Explicitly exit on success to ensure that any dangling dart:io handles | 
| // don't cause the process to never terminate. | 
| -      .then((_) => exit(0)); | 
| +      exit(0); | 
| +    }); | 
| } | 
|  | 
| /// Override this to perform the specific command. Return a future that | 
|  |