Repository: flutter
Issue: [tool_crash] FileSystemException: Cannot open file, OS Error: No such file or directory, errno = 2
Labels: c: crash,tool,P2,team-tool,triaged-tool

This error happened in a project I hadn't touched for a long time (it had a constraint for Flutter 1.9.1)
The tool tried to access the directory `.dart_tool`, which doesn't exist.

## Command
```
flutter pub upgrade --major-versions -n
```

## Logs
FileSystemException: Cannot open file, OS Error: No such file or directory, errno = 2
```
#0      _File.throwIfError (dart:io/file_impl.dart:635:7)
#1      _File.openSync (dart:io/file_impl.dart:479:5)
#2      _File.writeAsBytesSync (dart:io/file_impl.dart:604:31)
#3      _File.writeAsStringSync (dart:io/file_impl.dart:628:5)
#4      ForwardingFile.writeAsStringSync (package:file/src/forwarding/forwarding_file.dart:147:16)
#5      ErrorHandlingFile.writeAsStringSync.<anonymous closure> (package:flutter_tools/src/base/error_handling_io.dart:271:22)
#6      _runSync (package:flutter_tools/src/base/error_handling_io.dart:597:14)
#7      ErrorHandlingFile.writeAsStringSync (package:flutter_tools/src/base/error_handling_io.dart:270:5)
#8      _DefaultPub.interactively (package:flutter_tools/src/dart/pub.dart:404:21)
<asynchronous suspension>
#9      PackagesInteractiveGetCommand.runCommand (package:flutter_tools/src/commands/packages.dart:344:5)
<asynchronous suspension>
#10     FlutterCommand.run.<anonymous closure> (package:flutter_tools/src/runner/flutter_command.dart:1125:27)
<asynchronous suspension>
#11     AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:150:19)
<asynchronous suspension>
#12     CommandRunner.runCommand (package:args/command_runner.dart:209:13)
<asynchronous suspension>
#13     FlutterCommandRunner.runCommand.<anonymous closure> (package:flutter_tools/src/runner/flutter_command_runner.dart:288:9)
<asynchronous suspension>
#14     AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:150:19)
<asynchronous suspension>
#15     FlutterCommandRunner.runCommand (package:flutter_tools/src/runner/flutter_command_runner.dart:236:5)
<asynchronous suspension>
#16     run.<anonymous closure>.<anonymous closure> (package:flutter_tools/runner.dart:62:9)
```
```
[✓] Flutter (Channel stable, 2.5.2, on macOS 11.6 20G165 darwin-arm, locale en-GB)
    • Flutter version 2.5.2 at /Users/minnovi/flutter_sdks/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 3595343e20 (13 days ago), 2021-09-30 12:58:18 -0700
    • Engine revision 6ac856380f
    • Dart version 2.14.3

[✓] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
    • Android SDK at /Users/minnovi/Library/Android/sdk
    • Platform android-31, build-tools 31.0.0
    • ANDROID_HOME = /Users/minnovi/Library/Android/sdk
    • ANDROID_SDK_ROOT = /Users/minnovi/Library/Android/sdk
    • Java binary at: /Users/minnovi/Library/Application Support/JetBrains/Toolbox/apps/AndroidStudio/ch-0/203.7678000/Android Studio.app/Contents/jre/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7249189)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 13.0, Build version 13A233
    • CocoaPods version 1.10.1

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2020.3)
    • Android Studio at /Users/minnovi/Library/Application Support/JetBrains/Toolbox/apps/AndroidStudio/ch-0/203.7678000/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7249189)

[✓] Android Studio (version 2020.3)
    • Android Studio at /Users/minnovi/Library/Application Support/JetBrains/Toolbox/apps/AndroidStudio/ch-0/203.7678000/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7249189)

[✓] Android Studio (version 2020.3)
    • Android Studio at /Users/minnovi/Library/Application Support/JetBrains/Toolbox/apps/AndroidStudio/ch-0/203.7621141/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7249189)

[✓] VS Code (version 1.60.2)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.27.0

[✓] Connected device (3 available)
    • RMX2155 (mobile)       • 6DCASCXKSK6DXWEY                     • android-arm64  • Android 10 (API 29)
    • iPhone 13 Pro (mobile) • BD92AF67-2F86-46C5-BCAE-9DC8B4B021B1 • ios            • com.apple.CoreSimulator.SimRuntime.iOS-15-0 (simulator)
    • Chrome (web)           • chrome                               • web-javascript • Google Chrome 94.0.4606.81
    ! Error: iPhone is not connected. Xcode will continue when iPhone is connected. (code -13)

• No issues found!

```

## Flutter Application Metadata
**Type**: app
**Version**: 1.2.0+20
**Material**: true
**Android X**: false
**Module**: false
**Plugin**: false
**Android package**: null
**iOS bundle identifier**: null
**Creation channel**: stable
**Creation framework version**: 20e59316b8b8474554b38493b8ca888794b0234a