You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
dart build cli embeds Windows path separators for Linux native assets when cross-compiling from Windows #63953
When using dart build cli on Windows to build a Linux target with native assets, the generated bundle embeds the native asset relative path using Windows path separators.
For example, building on Windows for Linux produces a native asset path like:
..\lib\libcserialport.so
Then when the bundle is run on Linux, Dart tries to resolve:
/home/.../bundle/bin/..\lib\libcserialport.so
Linux treats backslashes as normal filename characters, not path separators, so the dynamic library cannot be found.
Repro
On Windows, build a CLI app that depends on a bundled native asset, for example cserialport.
Cross-compile to Linux:
dart build cli --target-os linux --target-arch x64
Copy the generated build/cli/linux_x64/bundle/ to Linux.
Run the executable:
./bin/list_ports
Actual result
Unhandled exception:
Invalid argument(s): Couldn't resolve native function 'CSerialPortAvailablePortInfosFree' ...
Failed to load dynamic library '..\lib\libcserialport.so' relative to '/home/.../bundle/bin/list_ports'
Expected result
The embedded Linux native asset path should use POSIX separators:
../lib/libcserialport.so
and the library should load successfully from:
bundle/lib/libcserialport.so
Likely cause
The native assets kernel/YAML serialization appears to call Uri.toFilePath() using the host platform default. When the host is Windows, relative asset paths are serialized with \, even if the target platform is Linux.
The path serialization should probably use the target OS, not the host OS, for example:
uri.toFilePath(windows: target.os ==OS.windows)
This affects at least bundled dynamic native assets used by dart build cli cross-compilation from Windows to Linux.
This seems like a real problem and I have exact ideas on how to fix it. The thing that's messing with me is that I remember testing this. I remember doing cross compilation on Windows and then using WSL to run the binary and it worked. Why did it work?
Probably what happened is that I accessed the binary through /mnt/c. Using /mnt/c from WSL eventually ends up making calls to Windows, which treats backslash correctly.
Activity
bkonyi commentedon Aug 5, 2026
cc @dcharkes
dcharkes commentedon Aug 5, 2026
cc @brianquinlan who added support in 212c720 last month.
brianquinlan commentedon Aug 24, 2026
I started look at this.
This seems like a real problem and I have exact ideas on how to fix it. The thing that's messing with me is that I remember testing this. I remember doing cross compilation on Windows and then using WSL to run the binary and it worked. Why did it work?
brianquinlan commentedon Aug 24, 2026
Probably what happened is that I accessed the binary through
/mnt/c. Using/mnt/cfrom WSL eventually ends up making calls to Windows, which treats backslash correctly.brianquinlan commentedon Aug 25, 2026
So we are embedding the wrong string.
[DEPS] update "native" to the latest commit
[stable] fix windows cross compilation