🐞 [Rust SDK] Rust crate not compiling on Windows! #12629
Unanswered
MikeTeddyOmondi
asked this question in
Help
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
What is the issue?
I don't know if the Rust SDK was meant to be cross compatible (Unix & Windows) but it would be useful to allow the SDK be able to compile in Windows by separating the following configuration below referenced for Unix and Windows.
The issue is that the
dagger-sdkcrate is attempting to use Unix-specific functionality (os::unix::prelude::PermissionsExtandset_modeonPermissions) on a Windows platform. This won't work because theunixmodule withinosis conditionally compiled out on Windows.Here's a breakdown and how to address it:
could not find \unix` in `os`** This means the code is trying to access theunixmodule within theosmodule, but that module doesn't exist when compiling for Windows. Thecfgattributes in the standard library source code snippets you included confirm that theunix` module is excluded when the target OS is not a Unix-like system.no method named \set_mode` found for struct `Permissions`** This is a consequence of the first error. Theset_modemethod is provided by thePermissionsExt` trait, which is only available when compiling for Unix-like systems.Dagger version
dagger v0.18.3
Steps to reproduce
The
dagger-sdkcrate needs to be modified to handle Windows properly. It should avoid using Unix-specific code when compiling for Windows. This likely involves using conditional compilation usingcfgattributes to provide alternative implementations for file permission setting on Windows.Here's the likely area in
dagger-sdk-0.18.3\src\core\downloader.rsthat needs changes:Explanation of suggested code:
#[cfg(not(windows))]and#[cfg(windows)]: These attributes conditionally compile code based on the target OS. The code within the#[cfg(not(windows))]block will only be compiled when the target OS is not Windows. The code within the#[cfg(windows)]block will only be compiled when the target OS is Windows.#[cfg(windows)], there's a placeholder comment. You'll need to find the appropriate Windows API calls to set the executable permission on the file.use std::os::unix::prelude::PermissionsExt;line should probably also be guarded by a#[cfg(not(windows))]attribute.How to Fix:
#[cfg(unix)]or#[cfg(not(windows))]attributes. This will exclude that code from being compiled when building for Windows.SetFileSecurityorchmodfunctions (available through crates likewinapiorpermissions_rs).winapi), make sure they are also conditionally included using#[cfg(windows)]in yourCargo.toml.Example
Cargo.tomlmodification (if you needwinapi):Important Considerations:
dagger-sdkwork seamlessly on both Unix-like systems and Windows. Carefully consider the differences in file permission models and provide appropriate implementations for each platform.Log output
Beta Was this translation helpful? Give feedback.
All reactions