Skip to content

only use code single path for verification of target file existence#70962

Merged
jonahwilliams merged 3 commits intoflutter:masterfrom
jonahwilliams:check_target_existence
Nov 20, 2020
Merged

only use code single path for verification of target file existence#70962
jonahwilliams merged 3 commits intoflutter:masterfrom
jonahwilliams:check_target_existence

Conversation

@jonahwilliams
Copy link
Contributor

Description

Currently the flutter tool has two different ways of finding the target file and a few existence checks in each resident runner. Move to a single code path that uses the existing validation.

This causes a crash in beta, because the tool need to know the correct target file earlier so that it can determine the language version.

Fixes crash:

Thread 0 main threadFileSystemException: FileSystemException: Cannot open file, path = 'lib/main.dart' (OS Error: No such file or directory, errno = 2)

  | at _File.throwIfError | (file_impl.dart:635)
-- | -- | --
  | at _File.openSync | (file_impl.dart:479)
  | at _File.readAsBytesSync | (file_impl.dart:539)
  | at _File.readAsStringSync | (file_impl.dart:584)
  | at _File.readAsLinesSync | (file_impl.dart:590)
  | at ForwardingFile.readAsLinesSync | (forwarding_file.dart:104)
  | at ForwardingFile.readAsLinesSync | (forwarding_file.dart:104)
  | at determineLanguageVersion | (language_version.dart:27)
  | at FlutterDevice.create | (resident_runner.dart:113)
  | at <asynchronous gap> | (async)
  | at RunCommand.runCommand | (run.dart:531)
  | at <asynchronous gap> | (async)
  | at FlutterCommand.verifyThenRunCommand | (flutter_command.dart:1080)
  | at <asynchronous gap> | (async)
  | at FlutterCommand.run.<anonymous closure> | (flutter_command.dart:931)
  | at <asynchronous gap> | (async)
  | at AppContext.run.<anonymous closure> | (context.dart:150)
  | at <asynchronous gap> | (async)
  | at AppContext.run | (context.dart:149)
  | at <asynchronous gap> | (async)
  | at CommandRunner.runCommand | (command_runner.dart:197)
  | at <asynchronous gap> | (async)
  | at FlutterCommandRunner.runCommand.<anonymous closure> | (flutter_command_runner.dart:284)
  | at <asynchronous gap> | (async)
  | at AppContext.run.<anonymous closure> | (context.dart:150)
  | at <asynchronous gap> | (async)
  | at AppContext.run | (context.dart:149)
  | at <asynchronous gap> | (async)
  | at FlutterCommandRunner.runCommand | (flutter_command_runner.dart:230)
  | at <asynchronous gap> | (async)
  | at run.<anonymous closure>.<anonymous closure> | (runner.dart:63)
  | at <asynchronous gap> | (async)
  | at run.<anonymous closure> | (runner.dart:61)
  | at <asynchronous gap> | (async)
  | at AppContext.run.<anonymous closure> | (context.dart:150)
  | at <asynchronous gap> | (async)
  | at AppContext.run | (context.dart:149)
  | at <asynchronous gap> | (async)
  | at runInContext | (context_runner.dart:70)
  | at <asynchronous gap> | (async)
  | at main | (executable.dart:90)
  | at <asynchronous gap> | (async)

@flutter-dashboard flutter-dashboard bot added the tool Affects the "flutter" command-line tool. See also t: labels. label Nov 20, 2020
@google-cla google-cla bot added the cla: yes label Nov 20, 2020

class FakeTargetCommand extends FlutterCommand {
FakeTargetCommand() {
usesTargetOption();
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

usesTargetOption already validates if the file exists

Copy link
Member

@jmagman jmagman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

tool Affects the "flutter" command-line tool. See also t: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants