From 57ad5778fad8cbdeada7815ca9c58fec63db90d8 Mon Sep 17 00:00:00 2001 From: 0hDEADBEAF <0xdeadbeaf@tutamail.com> Date: Mon, 30 Sep 2024 10:34:44 +0200 Subject: [PATCH] Add a way to explicitly specify RC toolkit path (#18402) Closes #18393 Release Notes: - Added a `ZED_RC_TOOLKIT_PATH` env variable so `winresource` crate can fetch the RC executable path correctly on some configurations --- crates/zed/build.rs | 7 +++++++ docs/src/development/windows.md | 27 +++++++++++++++++++++++++++ 2 files changed, 34 insertions(+) diff --git a/crates/zed/build.rs b/crates/zed/build.rs index c0d5c418750a4dd9ee522a85d8d77549dd6df99a..3013773f918342becb9e0b43b1915b490b8dde56 100644 --- a/crates/zed/build.rs +++ b/crates/zed/build.rs @@ -56,6 +56,13 @@ fn main() { println!("cargo:rerun-if-changed={}", icon.display()); let mut res = winresource::WindowsResource::new(); + + // Depending on the security applied to the computer, winresource might fail + // fetching the RC path. Therefore, we add a way to explicitly specify the + // toolkit path, allowing winresource to use a valid RC path. + if let Some(explicit_rc_toolkit_path) = std::env::var("ZED_RC_TOOLKIT_PATH").ok() { + res.set_toolkit_path(explicit_rc_toolkit_path.as_str()); + } res.set_icon(icon.to_str().unwrap()); res.set("FileDescription", "Zed"); res.set("ProductName", "Zed"); diff --git a/docs/src/development/windows.md b/docs/src/development/windows.md index 67808186d1961b98399b296b0a453ce2dc286d4e..03e8cae66b86d3bcff2b58dbef7a5541850a2efa 100644 --- a/docs/src/development/windows.md +++ b/docs/src/development/windows.md @@ -93,3 +93,30 @@ This error can happen if you are using the "rust-lld.exe" linker. Consider tryin If you are using a global config, consider moving the Zed repository to a nested directory and add a `.cargo/config.toml` with a custom linker config in the parent directory. See this issue for more information [#12041](https://github.com/zed-industries/zed/issues/12041) + +### Invalid RC path selected + +Sometimes, depending on the security rules applied to your laptop, you may get the following error while compiling Zed: + +``` +error: failed to run custom build command for `zed(C:\Users\USER\src\zed\crates\zed)` + +Caused by: + process didn't exit successfully: `C:\Users\USER\src\zed\target\debug\build\zed-b24f1e9300107efc\build-script-build` (exit code: 1) + --- stdout + cargo:rerun-if-changed=../../.git/logs/HEAD + cargo:rustc-env=ZED_COMMIT_SHA=25e2e9c6727ba9b77415588cfa11fd969612adb7 + cargo:rustc-link-arg=/stack:8388608 + cargo:rerun-if-changed=resources/windows/app-icon.ico + package.metadata.winresource does not exist + Selected RC path: 'bin\x64\rc.exe' + + --- stderr + The system cannot find the path specified. (os error 3) +warning: build failed, waiting for other jobs to finish... +``` + +In order to fix this issue, you can manually set the `ZED_RC_TOOLKIT_PATH` environment variable to the RC toolkit path. Usually, you can set it to: +`C:\Program Files (x86)\Windows Kits\10\bin\\x64`. + +See this [issue](https://github.com/zed-industries/zed/issues/18393) for more information.