cbindgen icon indicating copy to clipboard operation
cbindgen copied to clipboard

Cargo expand fails on windows within deeply nested folders

Open TomzBench opened this issue 1 year ago • 1 comments

Hello,

Cargo-expand fails on windows when building the project in a deeply nested folder. I noticed this issue first on a CI for which i do not easily control the directories used, so i can't simply change my directory to work around the issue.

It seems like every build script.exe file is failing to link. Speaking in chat with somebody alluded to the fact that large link commands will some times fail. I suspect something like this is happening. Im not sure.

I created a minimum repository which reproduces the issue here.

Clone the repository into a pretty deep folder on a windows system. (For example C:\Users\tom\Git\gitlab-runners\atx-zdk\GjRA6MGh9\0\software-engineering\this\is\a\superlong\dir) and run the command cargo build --target thumbv7em-none-eabi --no-default-features --release. You will see some cargo-expand failure with error code 1104 file not found errors. And note that build_script.exe's are not found.

Run the same command in a more sensible windows directory, and the project will compile fine...

TomzBench avatar Nov 22 '23 14:11 TomzBench

This workaround seems to work for me.

from: https://github.com/mozilla/cbindgen/issues/347

    let crate_dir = env::var("CARGO_MANIFEST_DIR").expect("invalid manifest dir");
    env::set_var("CARGO_EXPAND_TARGET_DIR", crate_dir.clone());

Could be a cargo expand issue perhaps, or the way cbindgen is invoking cargo-expand 🤷‍♂️

TomzBench avatar Nov 22 '23 16:11 TomzBench

Yeah this seems unlikely to be a cbindgen bug per se, and more of a windows limitation with long command line arguments / paths...

emilio avatar Apr 15 '24 00:04 emilio

Yeah this seems unlikely to be a cbindgen bug per se, and more of a windows limitation with long command line arguments / paths...

ya. I run into permutations of this in various different ways in rust/javascript ecosystems. Should windows "be better"... Of course. Will it? ...no

TomzBench avatar Apr 15 '24 13:04 TomzBench

I don't think this is actionable on cbindgen's side unless we can somehow shorten the window paths or something... If you think there's anything we could do better here let me know and we can re-open / fix it :)

emilio avatar Apr 15 '24 13:04 emilio