VeryGoodOpenSource / very_good_cli

A Very Good Command-Line Interface for Dart created by Very Good Ventures πŸ¦„
http://cli.vgv.dev
MIT License
2.15k stars 188 forks source link

fix: Plugin creation throws PathNotFoundException in Windows #728

Open yahu1031 opened 1 year ago

yahu1031 commented 1 year ago

Description Creating a flutter plugin throws PathNotFound Exception. These exceptions must be handled by some error statements.

Steps To Reproduce

  1. Upgraded flutter from 3.7.3 - 3.7.12
  2. Install vgv CLI
  3. very_good create flutter_plugin sky_client

Now you see this error.

PS C:\Users\yaswa\Desktop> very_good create flutter_plugin sky_client
Unhandled exception:
PathNotFoundException: Directory listing failed, path = 'C:\Users\yaswa\AppData\Local\Mason\Cache\bundled\very_good_flutter_plugin_0.3.3_22878f28a4fe654485c306b2b7c238e94c4ec37c\__brick__\{{project_name.snakeCase()}}\{{#android}}{{project_name.snakeCase()}}_android{{\android}}\android\src\main\kotlin\{{org_name.pathCase()}}\*' (OS Error: The system cannot find the path specified.
, errno = 3)
#0      _Directory._fillWithDirectoryListing (dart:io-patch/directory_patch.dart:42:24)
#1      _Directory.listSync (dart:io/directory_impl.dart:233:5)
#2      MasonGenerator._fromBrick (package:mason/src/generator.dart:91:14)
#3      MasonGenerator.fromBundle (package:mason/src/generator.dart:70:27)
<asynchronous suspension>
#4      CreateSubCommand.run (package:very_good_cli/src/commands/create/commands/create_subcommand.dart:199:23)
<asynchronous suspension>
#5      CommandRunner.runCommand (package:args/command_runner.dart:212:13)
<asynchronous suspension>
#6      VeryGoodCommandRunner.runCommand (package:very_good_cli/src/command_runner.dart:211:18)
<asynchronous suspension>
#7      VeryGoodCommandRunner.run (package:very_good_cli/src/command_runner.dart:148:14)
<asynchronous suspension>
#8      main (file:///C:/Users/yaswa/AppData/Local/Pub/Cache/hosted/pub.dev/very_good_cli-0.13.1/bin/very_good.dart:5:24)
<asynchronous suspension>
Unhandled exception:
PathNotFoundException: Directory listing failed, path = 'C:\Users\yaswa\AppData\Local\Mason\Cache\bundled\very_good_flutter_plugin_0.3.3_22878f28a4fe654485c306b2b7c238e94c4ec37c\__brick__\{{project_name.snakeCase()}}\{{#android}}{{project_name.snakeCase()}}_android{{\android}}\android\src\main\kotlin\{{org_name.pathCase()}}\*' (OS Error: The system cannot find the path specified.
, errno = 3)
#0      _Directory._fillWithDirectoryListing (dart:io-patch/directory_patch.dart:42:24)
#1      _Directory.listSync (dart:io/directory_impl.dart:233:5)
#2      MasonGenerator._fromBrick (package:mason/src/generator.dart:91:14)
#3      MasonGenerator.fromBundle (package:mason/src/generator.dart:70:27)
<asynchronous suspension>
#4      CreateSubCommand.run (package:very_good_cli/src/commands/create/commands/create_subcommand.dart:199:23)
<asynchronous suspension>
#5      CommandRunner.runCommand (package:args/command_runner.dart:212:13)
<asynchronous suspension>
#6      VeryGoodCommandRunner.runCommand (package:very_good_cli/src/command_runner.dart:211:18)
<asynchronous suspension>
#7      VeryGoodCommandRunner.run (package:very_good_cli/src/command_runner.dart:148:14)
<asynchronous suspension>
#8      main (file:///C:/Users/yaswa/AppData/Local/Pub/Cache/hosted/pub.dev/very_good_cli-0.13.1/bin/very_good.dart:5:24)
<asynchronous suspension>

Expected Behavior Should create a federated plugin code.

Additional Context

Edition Windows 11 Pro Insider Preview
Version 22H2
Installed on    β€Ž20-β€Ž01-β€Ž2023
OS build    25281.1000
Experience  Windows Feature Experience Pack 1000.25281.1000.0
yahu1031 commented 1 year ago
Verbose logs
```console PS C:\Users\yaswa\Desktop> very_good create flutter_plugin sky_client --verbose Argument information: Top level options: - verbose: true Command: create Command options: Command sub command: flutter_plugin Running with analytics enabled. Building generator from brick: very_good_flutter_plugin ^0.3.3 Building generator from brick failed: PathNotFoundException: Directory listing failed, path = 'C:\Users\yaswa\AppData\Local\Mason\Cache\hosted\registry.brickhub.dev\very_good_flutter_plugin_0.3.3\__brick__\{{project_name.snakeCase()}}\{{project_name.snakeCase()}}\example\{{#android}}android{{\android}}\app\src\main\kotlin\com\example\{{project_name.snakeCase()}}\*' (OS Error: The system cannot find the path specified. , errno = 3) Building generator from bundle very_good_flutter_plugin 0.3.3 Unhandled exception: PathNotFoundException: Directory listing failed, path = 'C:\Users\yaswa\AppData\Local\Mason\Cache\bundled\very_good_flutter_plugin_0.3.3_22878f28a4fe654485c306b2b7c238e94c4ec37c\__brick__\{{project_name.snakeCase()}}\{{#android}}{{project_name.snakeCase()}}_android{{\android}}\android\src\main\kotlin\{{org_name.pathCase()}}\*' (OS Error: The system cannot find the path specified. , errno = 3) #0 _Directory._fillWithDirectoryListing (dart:io-patch/directory_patch.dart:42:24) #1 _Directory.listSync (dart:io/directory_impl.dart:233:5) #2 MasonGenerator._fromBrick (package:mason/src/generator.dart:91:14) #3 MasonGenerator.fromBundle (package:mason/src/generator.dart:70:27) #4 CreateSubCommand.run (package:very_good_cli/src/commands/create/commands/create_subcommand.dart:199:23) #5 CommandRunner.runCommand (package:args/command_runner.dart:212:13) #6 VeryGoodCommandRunner.runCommand (package:very_good_cli/src/command_runner.dart:211:18) #7 VeryGoodCommandRunner.run (package:very_good_cli/src/command_runner.dart:148:14) #8 main (file:///C:/Users/yaswa/AppData/Local/Pub/Cache/hosted/pub.dev/very_good_cli-0.13.1/bin/very_good.dart:5:24) FINE: Pub 2.19.6 Argument information: Top level options: - verbose: true Command: create Command options: Command sub command: flutter_plugin Running with analytics enabled. Building generator from brick: very_good_flutter_plugin ^0.3.3 Building generator from brick failed: PathNotFoundException: Directory listing failed, path = 'C:\Users\yaswa\AppData\Local\Mason\Cache\hosted\registry.brickhub.dev\very_good_flutter_plugin_0.3.3\__brick__\{{project_name.snakeCase()}}\{{project_name.snakeCase()}}\example\{{#android}}android{{\android}}\app\src\main\kotlin\com\example\{{project_name.snakeCase()}}\*' (OS Error: The system cannot find the path specified. , errno = 3) Building generator from bundle very_good_flutter_plugin 0.3.3 Unhandled exception: PathNotFoundException: Directory listing failed, path = 'C:\Users\yaswa\AppData\Local\Mason\Cache\bundled\very_good_flutter_plugin_0.3.3_22878f28a4fe654485c306b2b7c238e94c4ec37c\__brick__\{{project_name.snakeCase()}}\{{#android}}{{project_name.snakeCase()}}_android{{\android}}\android\src\main\kotlin\{{org_name.pathCase()}}\*' (OS Error: The system cannot find the path specified. , errno = 3) #0 _Directory._fillWithDirectoryListing (dart:io-patch/directory_patch.dart:42:24) #1 _Directory.listSync (dart:io/directory_impl.dart:233:5) #2 MasonGenerator._fromBrick (package:mason/src/generator.dart:91:14) #3 MasonGenerator.fromBundle (package:mason/src/generator.dart:70:27) #4 CreateSubCommand.run (package:very_good_cli/src/commands/create/commands/create_subcommand.dart:199:23) #5 CommandRunner.runCommand (package:args/command_runner.dart:212:13) #6 VeryGoodCommandRunner.runCommand (package:very_good_cli/src/command_runner.dart:211:18) #7 VeryGoodCommandRunner.run (package:very_good_cli/src/command_runner.dart:148:14) #8 main (file:///C:/Users/yaswa/AppData/Local/Pub/Cache/hosted/pub.dev/very_good_cli-0.13.1/bin/very_good.dart:5:24) IO : Writing 584 characters to text file C:\Users\yaswa\AppData\Local\Pub\Cache\log\pub_log.txt. MSG : Logs written to C:\Users\yaswa\AppData\Local\Pub\Cache\log\pub_log.txt. ```
yahu1031 commented 1 year ago

This happens with all the versions.

alestiago commented 1 year ago

@yahu1031 thanks for opening an issue πŸ’™ !

I've been unable to reproduce this issue in MacOS, but you seem to be using Windows. In other words, very_good create flutter_plugin sky_client succeeds for MacOS.

Do you mind sharing the output of flutter doctor -v?

yahu1031 commented 1 year ago

Could you please check if it creates the kotlin file in Mac? I will update the rest in a mean while. @alestiago

alestiago commented 1 year ago

Thanks @yahu1031 for the quick reply! I look forward to the update.

Regarding your question, the file here is not being generated. There is only a single file under my_plugin_android/android/src/main/ and that is the AndroidManifest.xml. Although the Kotlin file is not being generated, the Unhandled exception is not thrown on create (MacOS).

The brick does have the Kotlin [file](https://github.com/VeryGoodOpenSource/very_good_flutter_plugin/tree/main/brick/__brick__/%7B%7Bproject_name.snakeCase()%7D%7D/%7B%7B%23android%7D%7D%7B%7Bproject_name.snakeCase()%7D%7D_android%7B%7B/android%7D%7D/android/src/main/kotlin/%7B%7Borg_name.pathCase()%7D%7D) and there is no post hook, which is interesting. This should definitely be looked into πŸ‘€ .

renancaraujo commented 1 year ago

Possibly related: https://github.com/felangel/mason/issues/676

erickzanardo commented 1 year ago

I can confirm that this is reproducible in Windows.

yahu1031 commented 1 year ago

@alestiago Sorry about not responding so quickly. I'm away from my Windows machine. So can't give you more info. But LMK if anything is needed and I will try providing it somehow.

bawantha commented 7 months ago

This is still happening in windows