slang-i18n / slang

Type-safe i18n for Dart and Flutter
https://pub.dev/packages/slang
MIT License
459 stars 39 forks source link

Cli failed to run in nested projects depend on package super_native_extensions #238

Closed realth000 closed 1 month ago

realth000 commented 1 month ago

Describe the bug dart run slang fails to run when:

Similar to #142 but end up with different error The system cannot find the path specified. (os error 3).

To Reproduce Steps to reproduce the behavior:

Use the repo here:

  1. cd packages/my_package/example
  2. flutter build Windows --debug
  3. cd ../../../
  4. dart run slang.

Or complete steps to prepare a demo:

  1. Create a flutter project like: flutter create -t my_project_outside.
  2. Enter the project folder, install slang: flutter pub add slang slang_flutter dev:build_runner dev:slang_build_runner
  3. Mkdir a directory called packages for inner used packages. In the packages folder, create a package called my_package: flutter create -t package my_package.
  4. Inside project my_package, create an example app for it: flutter create -t app example.
  5. Enter example app, add package: flutter pub add super_native_extensions.
  6. Run DEBUG build: flutter build windows --debug.
  7. Back to the top project folder where added slang, run dart run slang.

Expected behavior Command finished without error.

Additional context Command finished with error:

$ dart run slang
Resolving dependencies in `C:\Programming\Projects\slang_super_native_extension_demo`...
Downloading packages...
Got dependencies in `C:\Programming\Projects\slang_super_native_extension_demo`.
Building package executable...
Built slang:slang.
Generating translations...
No build.yaml or slang.yaml, using default settings.
Unhandled exception:
PathNotFoundException: Directory listing failed, path = 'C:\Programming\Projects\slang_super_native_extension_demo\packages\my_package\example\build\windows\x64\plugins\super_native_extensions\cargokit_build\x86_64-pc-windows-msvc\debug\incremental\super_native_extensions-1r15fy4hptxzz\s-gypqjg342p-1nzj08p-ble5texxy5ahw51mu1j7vdnbd\*' (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:228:5)
#2      _getFilesBreadthFirst (package:slang/builder/builder/slang_file_collection_builder.dart:214:41)
#3      SlangFileCollectionBuilder.readFromFileSystem (package:slang/builder/builder/slang_file_collection_builder.dart:32:15)
#4      main (file:///C:/Users/L/AppData/Local/Pub/Cache/hosted/pub.dev/slang-3.31.1/bin/slang.dart:125:34)
#5      _delayEntrypointInvocation.<anonymous closure> (dart:isolate-patch/isolate_patch.dart:295:33)
#6      _RawReceivePort._handleMessage (dart:isolate-patch/isolate_patch.dart:184:12)

dart run build_runner build works well, only cli fails.

realth000 commented 1 month ago

Seems only reproduce on Windows.

I tried on Linux but worked well.

Tienisto commented 1 month ago

Maybe the path is too long so it cannot be read by Dart on Windows.

There are some directories that are ignored during scan. Maybe there is a characteristic folder name that can be ignored? According to your logs cargokit_build might be specific enough that we can safely ignore.

https://github.com/slang-i18n/slang/blob/e0a684f57adea5a3e7f7b60e95df7fae1f639667/slang/lib/builder/builder/slang_file_collection_builder.dart#L44

realth000 commented 1 month ago

Yes I also think so. It should be ignored during scan.

Tienisto commented 1 month ago

Fixed in 3.31.2