anaisbetts / squirrel-flutter

Build installers for your Flutter applications with Squirrel
BSD 3-Clause "New" or "Revised" License
57 stars 13 forks source link

ref: use dart:mirrors instead of `Platform.script` to resolve uri #9

Closed V3ntus closed 1 year ago

V3ntus commented 1 year ago

Using Platform.script resolved a snapshot in the .dart_tool\pub\bin\squirrel directory, not the installer_windows.dart in the pub cache. This broke the program where it could not find the vendor/ directory and other required files.

dart:mirrors resolves the correct path of installer_windows.dart when in the dart pub cache and vendor files are located properly.

V3ntus commented 1 year ago

There's still the odd issue where the path being resolved is not found even though it exists:

B:\GitRepos\dart_project>dart run squirrel:installer_windows
Building package executable... (1.3s)
Built squirrel:installer_windows.
Unhandled exception:
PathNotFoundException: Cannot copy file to 'b:\gitrepos\dart_project\build\windows\runner\Release\squirrel.exe', path = 'c:\users\ventus\appdata\local\pub\cache\git\squirrel-flutter-1612e8f1bd8eb2c9df317da0e181e0564afcff7a\vendor\squirrel.exe' (OS Error: The system cannot find the path specified.
, errno = 3)
#0      _checkForErrorResponse (dart:io/common.dart:55:9)
#1      _File.copy.<anonymous closure> (dart:io/file_impl.dart:356:7)
<asynchronous suspension>
#2      main (file:///C:/Users/Ventus/AppData/Local/Pub/Cache/git/squirrel-flutter-1612e8f1bd8eb2c9df317da0e181e0564afcff7a/bin/installer_windows.dart:220:5)
<asynchronous suspension>

B:\GitRepos\dart_project>dir c:\users\ventus\appdata\local\pub\cache\git\squirrel-flutter-1612e8f1bd8eb2c9df317da0e181e0564afcff7a\vendor\squirrel.exe
 Volume in drive C is Windows
 Volume Serial Number is 1882-216A

 Directory of c:\users\ventus\appdata\local\pub\cache\git\squirrel-flutter-1612e8f1bd8eb2c9df317da0e181e0564afcff7a\vendor

05/21/2023  16:20         1,899,520 Squirrel.exe
               1 File(s)      1,899,520 bytes
               0 Dir(s)  422,942,474,240 bytes free

Most likely this https://github.com/dart-lang/path/issues/102

V3ntus commented 1 year ago

Brain dead moment. The source file did exist, but that was not the problem. I had ran flutter clean which deleted the required build directory contents. Building my flutter app then running this worked again

anaisbetts commented 1 year ago

Thanks!