fzyzcjy / flutter_rust_bridge

Flutter/Dart <-> Rust binding generator, feature-rich, but seamless and simple.
https://fzyzcjy.github.io/flutter_rust_bridge/
MIT License
4.12k stars 282 forks source link

Cannot build project on windows when using symlinks #2160

Closed 0xNF closed 2 months ago

0xNF commented 2 months ago

Describe the bug

Following the Create New quickstart tutorial, Windows fails to build.

Steps to reproduce

  1. Create a new application with flutter_rust_bridge_codegen create frb_test_2
  2. Run the flutter app

Logs

PS C:\Users\0xnf\projects\experiments\frb_test_2> flutter run    
Connected devices:
Windows (desktop) • windows • windows-x64    • Microsoft Windows [Version 10.0.22631.3737]
Chrome (web)      • chrome  • web-javascript • Google Chrome 126.0.6478.62
Edge (web)        • edge    • web-javascript • Microsoft Edge 126.0.2592.68
[1]: Windows (windows)
[2]: Chrome (chrome)
[3]: Edge (edge)
Please choose one (or "q" to quit): 1
Launching lib\main.dart on Windows in debug mode...
Get-Item : Cannot find path 'C:\Users\0xnf\Documents\projects\experiments\frb_test_2\Users' because it does not
exist.
At C:\Users\0xnf\projects\experiments\frb_test_2\windows\flutter\ephemeral\.plugin_symlinks\rust_lib_frb_test_2\cargokit\
cmake\resolve_symlinks.ps1:18 char:17
+         $item = Get-Item $realPath
+                 ~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (C:\Users\0xnf\Doc...rb_test_2\Users:String) [Get-Item], ItemNotFoundExcep
   tion
    + FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.GetItemCommand

Get-Item : Cannot find path 'C:\Users\0xnf\Documents\projects\experiments\frb_test_2\Users\nf' because it does
not exist.
At C:\Users\0xnf\projects\experiments\frb_test_2\windows\flutter\ephemeral\.plugin_symlinks\rust_lib_frb_test_2\cargokit\
cmake\resolve_symlinks.ps1:18 char:17
+         $item = Get-Item $realPath
+                 ~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (C:\Users\0xnf\Doc...test_2\Users\nf:String) [Get-Item], ItemNotFoundExcep
   tion
    + FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.GetItemCommand

Get-Item : Cannot find path 'C:\Users\0xnf\Documents\projects\experiments\frb_test_2\Users\0xnf\projects' because
it does not exist.
At C:\Users\0xnf\projects\experiments\frb_test_2\windows\flutter\ephemeral\.plugin_symlinks\rust_lib_frb_test_2\cargokit\
cmake\resolve_symlinks.ps1:18 char:17
+         $item = Get-Item $realPath
+                 ~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (C:\Users\0xnf\Doc...ers\0xnf\projects:String) [Get-Item], ItemNotFoundExcep
   tion
    + FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.GetItemCommand

Get-Item : Cannot find path
'C:\Users\0xnf\Documents\projects\experiments\frb_test_2\Users\0xnf\projects\experiments' because it does not
exist.
At C:\Users\0xnf\projects\experiments\frb_test_2\windows\flutter\ephemeral\.plugin_symlinks\rust_lib_frb_test_2\cargokit\
cmake\resolve_symlinks.ps1:18 char:17
+         $item = Get-Item $realPath
+                 ~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (C:\Users\0xnf\Doc...cts\experiments:String) [Get-Item], ItemNotFoundExcep
   tion
    + FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.GetItemCommand

Get-Item : Cannot find path
'C:\Users\0xnf\Documents\projects\experiments\frb_test_2\Users\0xnf\projects\experiments\frb_test_2' because it
does not exist.
At C:\Users\0xnf\projects\experiments\frb_test_2\windows\flutter\ephemeral\.plugin_symlinks\rust_lib_frb_test_2\cargokit\
cmake\resolve_symlinks.ps1:18 char:17
+         $item = Get-Item $realPath
+                 ~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (C:\Users\0xnf\Doc...ents\frb_test_2:String) [Get-Item], ItemNotFoundExcep
   tion
    + FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.GetItemCommand

Get-Item : Cannot find path
'C:\Users\0xnf\Documents\projects\experiments\frb_test_2\Users\0xnf\projects\experiments\frb_test_2\windows'
because it does not exist.
At C:\Users\0xnf\projects\experiments\frb_test_2\windows\flutter\ephemeral\.plugin_symlinks\rust_lib_frb_test_2\cargokit\
cmake\resolve_symlinks.ps1:18 char:17
+         $item = Get-Item $realPath
+                 ~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (C:\Users\0xnf\Doc..._test_2\windows:String) [Get-Item], ItemNotFoundExcep
   tion
    + FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.GetItemCommand

Get-Item : Cannot find path 'C:\Users\0xnf\Documents\projects\experiments\frb_test_2\Users\0xnf\projects\experimen
ts\frb_test_2\windows\flutter' because it does not exist.
At C:\Users\0xnf\projects\experiments\frb_test_2\windows\flutter\ephemeral\.plugin_symlinks\rust_lib_frb_test_2\cargokit\
cmake\resolve_symlinks.ps1:18 char:17
+         $item = Get-Item $realPath
+                 ~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (C:\Users\0xnf\Doc...windows\flutter:String) [Get-Item], ItemNotFoundExcep
   tion
    + FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.GetItemCommand

Get-Item : Cannot find path 'C:\Users\0xnf\Documents\projects\experiments\frb_test_2\Users\0xnf\projects\experimen
ts\frb_test_2\windows\flutter\ephemeral' because it does not exist.
At C:\Users\0xnf\projects\experiments\frb_test_2\windows\flutter\ephemeral\.plugin_symlinks\rust_lib_frb_test_2\cargokit\
cmake\resolve_symlinks.ps1:18 char:17
+         $item = Get-Item $realPath
+                 ~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (C:\Users\0xnf\Doc...utter\ephemeral:String) [Get-Item], ItemNotFoundExcep
   tion
    + FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.GetItemCommand

Get-Item : Cannot find path 'C:\Users\0xnf\Documents\projects\experiments\frb_test_2\Users\0xnf\projects\experimen
ts\frb_test_2\windows\flutter\ephemeral\.plugin_symlinks' because it does not exist.
At C:\Users\0xnf\projects\experiments\frb_test_2\windows\flutter\ephemeral\.plugin_symlinks\rust_lib_frb_test_2\cargokit\
cmake\resolve_symlinks.ps1:18 char:17
+         $item = Get-Item $realPath
+                 ~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (C:\Users\0xnf\Doc...plugin_symlinks:String) [Get-Item], ItemNotFoundExcep
   tion
    + FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.GetItemCommand

Get-Item : Cannot find path 'C:\Users\0xnf\Documents\projects\experiments\frb_test_2\Users\0xnf\projects\experimen
ts\frb_test_2\windows\flutter\ephemeral\.plugin_symlinks\rust_lib_frb_test_2' because it does not exist.
At C:\Users\0xnf\projects\experiments\frb_test_2\windows\flutter\ephemeral\.plugin_symlinks\rust_lib_frb_test_2\cargokit\
cmake\resolve_symlinks.ps1:18 char:17
+         $item = Get-Item $realPath
+                 ~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (C:\Users\0xnf\Doc..._lib_frb_test_2:String) [Get-Item], ItemNotFoundExcep
   tion
    + FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.GetItemCommand

Get-Item : Cannot find path 'C:\Users\0xnf\Documents\projects\experiments\frb_test_2\Users\0xnf\projects\experimen
ts\frb_test_2\windows\flutter\ephemeral\.plugin_symlinks\rust_lib_frb_test_2\cargokit' because it does not exist.
At C:\Users\0xnf\projects\experiments\frb_test_2\windows\flutter\ephemeral\.plugin_symlinks\rust_lib_frb_test_2\cargokit\
cmake\resolve_symlinks.ps1:18 char:17
+         $item = Get-Item $realPath
+                 ~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (C:\Users\0xnf\Doc...test_2\cargokit:String) [Get-Item], ItemNotFoundExcep
   tion
    + FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.GetItemCommand

C:\Program Files\Microsoft Visual Studio\2022\Professional\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets(248,5): error MSB8066: Custom build for 'C:\Users\0xnf\projects\experiments\frb_test_2\build\windows\x64\CMakeFiles\e6673144129b504fb54fb3805ae94740\rust_lib_frb_test_2.dll.rule;C:\Users\0xnf\projects\experiments\frb_test_2\build\windows\x64\CMakeFiles\e63beef0aa0ef8f81292f4fde473ad44\rust_lib_frb_test_2_cargokit.rule' exited with code 1. [C:\Users\0xnf\projects\experiments\frb_test_2\build\windows\x64\plugins\rust_lib_frb_test_2\rust_lib_frb_test_2_cargokit.vcxproj]
Building Windows application...                                  2,505ms
Error: Build process failed.

Expected behavior

No response

Generated binding code

No response

OS

No response

Version of flutter_rust_bridge_codegen

No response

Flutter info

No response

Version of clang++

No response

Additional context

No response

welcome[bot] commented 2 months ago

Hi! Thanks for opening your first issue here! :smile:

mcmah309 commented 2 months ago

You created your app with flutter_rust_bridge_codegen create my_app but you are in the frb_test_2 directory running flutter run. I would expect you would try to run from the my_app directory. If this is just a typo, does the issue persist with CMD?

0xNF commented 2 months ago

Sorry, it was a typo. I just copy-pasted it from the quickstart page. I updated the issue body to make clear I ran flutter_rust_bridge_codegen create frb_test_2

Here is some output from my powershell terminal:

ls and run output ```powershell PS C:\Users\0xnf\projects\experiments\frb_test_2> ls Directory: C:\Users\0xnf\projects\experiments\frb_test_2 Mode LastWriteTime Length Name ---- ------------- ------ ---- d---- 6/26/2024 7:55 PM .dart_tool d---- 6/26/2024 7:54 PM .idea d---- 6/26/2024 7:57 PM .vscode d---- 6/26/2024 7:56 PM android d---- 6/26/2024 7:56 PM build d---- 6/26/2024 7:54 PM integration_test d---- 6/26/2024 7:54 PM ios d---- 6/26/2024 7:54 PM lib d---- 6/26/2024 7:54 PM linux d---- 6/26/2024 7:54 PM macos d---- 6/26/2024 7:55 PM rust d---- 6/26/2024 7:55 PM rust_builder d---- 6/26/2024 7:54 PM test d---- 6/26/2024 7:54 PM test_driver d---- 6/26/2024 7:54 PM web d---- 6/26/2024 7:54 PM windows -a--- 6/26/2024 9:34 PM 257 .flutter-plugins -a--- 6/26/2024 9:34 PM 1469 .flutter-plugins-dependencies -a--- 6/26/2024 7:54 PM 734 .gitignore -a--- 6/26/2024 7:54 PM 1706 .metadata -a--- 6/26/2024 7:54 PM 1448 analysis_options.yaml -a--- 6/26/2024 7:54 PM 65 flutter_rust_bridge.yaml -a--- 6/26/2024 7:54 PM 859 frb_test_2.iml -a--- 6/26/2024 7:56 PM 8900 pubspec.lock -a--- 6/26/2024 7:54 PM 4082 pubspec.yaml -a--- 6/26/2024 7:54 PM 569 README.md PS C:\Users\0xnf\projects\experiments\frb_test_2> flutter run Connected devices: Windows (desktop) • windows • windows-x64 • Microsoft Windows [Version 10.0.22631.3737] Chrome (web) • chrome • web-javascript • Google Chrome 126.0.6478.62 Edge (web) • edge • web-javascript • Microsoft Edge 126.0.2592.68 [1]: Windows (windows) [2]: Chrome (chrome) [3]: Edge (edge) Please choose one (or "q" to quit): 1 Launching lib\main.dart on Windows in debug mode... Get-Item : Cannot find path 'C:\Users\0xnf\Documents\projects\experiments\frb_test_2\Users' because it does not exist. At C:\Users\0xnf\projects\experiments\frb_test_2\windows\flutter\ephemeral\.plugin_symlinks\rust_lib_frb_test_2\cargokit\ cmake\resolve_symlinks.ps1:18 char:17 + $item = Get-Item $realPath + ~~~~~~~~~~~~~~~~~~ + CategoryInfo : ObjectNotFound: (C:\Users\nf\Doc...rb_test_2\Users:String) [Get-Item], ItemNotFoundExcep tion + FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.GetItemCommand Get-Item : Cannot find path 'C:\Users\0xnf\Documents\projects\experiments\frb_test_2\Users\nf' because it does not exist. At C:\Users\0xnf\projects\experiments\frb_test_2\windows\flutter\ephemeral\.plugin_symlinks\rust_lib_frb_test_2\cargokit\ cmake\resolve_symlinks.ps1:18 char:17 + $item = Get-Item $realPath + ~~~~~~~~~~~~~~~~~~ + CategoryInfo : ObjectNotFound: (C:\Users\nf\Doc...test_2\Users\nf:String) [Get-Item], ItemNotFoundExcep tion + FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.GetItemCommand Get-Item : Cannot find path 'C:\Users\0xnf\Documents\projects\experiments\frb_test_2\Users\nf\projects' because it does not exist. At C:\Users\0xnf\projects\experiments\frb_test_2\windows\flutter\ephemeral\.plugin_symlinks\rust_lib_frb_test_2\cargokit\ cmake\resolve_symlinks.ps1:18 char:17 + $item = Get-Item $realPath + ~~~~~~~~~~~~~~~~~~ + CategoryInfo : ObjectNotFound: (C:\Users\nf\Doc...ers\nf\projects:String) [Get-Item], ItemNotFoundExcep tion + FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.GetItemCommand Get-Item : Cannot find path 'C:\Users\0xnf\Documents\projects\experiments\frb_test_2\Users\nf\projects\experiments' because it does not exist. At C:\Users\0xnf\projects\experiments\frb_test_2\windows\flutter\ephemeral\.plugin_symlinks\rust_lib_frb_test_2\cargokit\ cmake\resolve_symlinks.ps1:18 char:17 + $item = Get-Item $realPath + ~~~~~~~~~~~~~~~~~~ + CategoryInfo : ObjectNotFound: (C:\Users\nf\Doc...cts\experiments:String) [Get-Item], ItemNotFoundExcep tion + FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.GetItemCommand Get-Item : Cannot find path 'C:\Users\0xnf\Documents\projects\experiments\frb_test_2\Users\nf\projects\experiments\frb_test_2' because it does not exist. At C:\Users\0xnf\projects\experiments\frb_test_2\windows\flutter\ephemeral\.plugin_symlinks\rust_lib_frb_test_2\cargokit\ cmake\resolve_symlinks.ps1:18 char:17 + $item = Get-Item $realPath + ~~~~~~~~~~~~~~~~~~ + CategoryInfo : ObjectNotFound: (C:\Users\nf\Doc...ents\frb_test_2:String) [Get-Item], ItemNotFoundExcep tion + FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.GetItemCommand Get-Item : Cannot find path 'C:\Users\0xnf\Documents\projects\experiments\frb_test_2\Users\nf\projects\experiments\frb_test_2\windows' because it does not exist. At C:\Users\0xnf\projects\experiments\frb_test_2\windows\flutter\ephemeral\.plugin_symlinks\rust_lib_frb_test_2\cargokit\ cmake\resolve_symlinks.ps1:18 char:17 + $item = Get-Item $realPath + ~~~~~~~~~~~~~~~~~~ + CategoryInfo : ObjectNotFound: (C:\Users\nf\Doc..._test_2\windows:String) [Get-Item], ItemNotFoundExcep tion + FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.GetItemCommand Get-Item : Cannot find path 'C:\Users\0xnf\Documents\projects\experiments\frb_test_2\Users\nf\projects\experimen ts\frb_test_2\windows\flutter' because it does not exist. At C:\Users\0xnf\projects\experiments\frb_test_2\windows\flutter\ephemeral\.plugin_symlinks\rust_lib_frb_test_2\cargokit\ cmake\resolve_symlinks.ps1:18 char:17 + $item = Get-Item $realPath + ~~~~~~~~~~~~~~~~~~ + CategoryInfo : ObjectNotFound: (C:\Users\nf\Doc...windows\flutter:String) [Get-Item], ItemNotFoundExcep tion + FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.GetItemCommand Get-Item : Cannot find path 'C:\Users\0xnf\Documents\projects\experiments\frb_test_2\Users\nf\projects\experimen ts\frb_test_2\windows\flutter\ephemeral' because it does not exist. At C:\Users\0xnf\projects\experiments\frb_test_2\windows\flutter\ephemeral\.plugin_symlinks\rust_lib_frb_test_2\cargokit\ cmake\resolve_symlinks.ps1:18 char:17 + $item = Get-Item $realPath + ~~~~~~~~~~~~~~~~~~ + CategoryInfo : ObjectNotFound: (C:\Users\nf\Doc...utter\ephemeral:String) [Get-Item], ItemNotFoundExcep tion + FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.GetItemCommand Get-Item : Cannot find path 'C:\Users\0xnf\Documents\projects\experiments\frb_test_2\Users\nf\projects\experimen ts\frb_test_2\windows\flutter\ephemeral\.plugin_symlinks' because it does not exist. At C:\Users\0xnf\projects\experiments\frb_test_2\windows\flutter\ephemeral\.plugin_symlinks\rust_lib_frb_test_2\cargokit\ cmake\resolve_symlinks.ps1:18 char:17 + $item = Get-Item $realPath + ~~~~~~~~~~~~~~~~~~ + CategoryInfo : ObjectNotFound: (C:\Users\nf\Doc...plugin_symlinks:String) [Get-Item], ItemNotFoundExcep tion + FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.GetItemCommand Get-Item : Cannot find path 'C:\Users\0xnf\Documents\projects\experiments\frb_test_2\Users\nf\projects\experimen ts\frb_test_2\windows\flutter\ephemeral\.plugin_symlinks\rust_lib_frb_test_2' because it does not exist. At C:\Users\0xnf\projects\experiments\frb_test_2\windows\flutter\ephemeral\.plugin_symlinks\rust_lib_frb_test_2\cargokit\ cmake\resolve_symlinks.ps1:18 char:17 + $item = Get-Item $realPath + ~~~~~~~~~~~~~~~~~~ + CategoryInfo : ObjectNotFound: (C:\Users\nf\Doc..._lib_frb_test_2:String) [Get-Item], ItemNotFoundExcep tion + FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.GetItemCommand Get-Item : Cannot find path 'C:\Users\0xnf\Documents\projects\experiments\frb_test_2\Users\nf\projects\experimen ts\frb_test_2\windows\flutter\ephemeral\.plugin_symlinks\rust_lib_frb_test_2\cargokit' because it does not exist. At C:\Users\0xnf\projects\experiments\frb_test_2\windows\flutter\ephemeral\.plugin_symlinks\rust_lib_frb_test_2\cargokit\ cmake\resolve_symlinks.ps1:18 char:17 + $item = Get-Item $realPath + ~~~~~~~~~~~~~~~~~~ + CategoryInfo : ObjectNotFound: (C:\Users\nf\Doc...test_2\cargokit:String) [Get-Item], ItemNotFoundExcep tion + FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.GetItemCommand C:\Program Files\Microsoft Visual Studio\2022\Professional\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets(248,5): error MSB8066: Custom build for 'C:\Users\0xnf\projects\experiments\frb_test_2\build\windows\x64\CMakeFiles\e6673144129b504fb54fb3805ae94740\rust_lib_frb_test_2.dll.rule;C:\Users\0xnf\projects\experiments\frb_test_2\build\windows\x64\CMakeFiles\e63beef0aa0ef8f81292f4fde473ad44\rust_lib_frb_test_2_cargokit.rule' exited with code 1. [C:\Users\0xnf\projects\experiments\frb_test_2\build\windows\x64\plugins\rust_lib_frb_test_2\rust_lib_frb_test_2_cargokit.vcxproj] Building Windows application... 2,076ms Error: Build process failed. PS C:\Users\0xnf\projects\experiments\frb_test_2> ```

The directory structure on my machine uses symlinks here and there, so I guess the project build scripts dont like windows symlinks very much.

I can confirm that going into the directory directly, without symlinks, the project builds fine.

fzyzcjy commented 2 months ago

Hmm, looks like it is a cagokit error (instead of frb core error), thus it would be great to ask there.

The directory structure on my machine uses symlinks here and there, so I guess the project build scripts dont like windows symlinks very much. I can confirm that going into the directory directly, without symlinks, the project builds fine.

Based on these and the error message, I agree - looks like something related to symlink resolving!

fzyzcjy commented 2 months ago

Close since this looks like cargokit-related, but feel free to reopen if there are any questions!

github-actions[bot] commented 1 month ago

This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new issue.