Skip to content

Commit

Permalink
fix(bundler): clear env before calling wix, closes #4791 (#4819)
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasfernog committed Oct 3, 2022
1 parent a6c9411 commit 7c0fa1f
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changes/wix-clear-env.md
@@ -0,0 +1,5 @@
---
"tauri-bundler": patch
---

Clear environment variables on the WiX light.exe and candle.exe commands to avoid "Windows Installer Service could not be accessed" error. Variables prefixed with `TAURI` are propagated.
4 changes: 2 additions & 2 deletions .github/workflows/artifacts-updater.yml
Expand Up @@ -114,7 +114,7 @@ jobs:
working-directory: ./examples/updater
run: |
yarn install
cargo tauri build
cargo tauri build --verbose
env:
# Notarization (disabled)
# FIXME: enable only on `dev` push maybe? as it take some times...
Expand All @@ -134,7 +134,7 @@ jobs:
working-directory: ./examples/updater
run: |
yarn install
cargo tauri build
cargo tauri build --verbose
env:
TAURI_PRIVATE_KEY: dW50cnVzdGVkIGNvbW1lbnQ6IHJzaWduIGVuY3J5cHRlZCBzZWNyZXQga2V5ClJXUlRZMEl5YTBGV3JiTy9lRDZVd3NkL0RoQ1htZmExNDd3RmJaNmRMT1ZGVjczWTBKZ0FBQkFBQUFBQUFBQUFBQUlBQUFBQWdMekUzVkE4K0tWQ1hjeGt1Vkx2QnRUR3pzQjVuV0ZpM2czWXNkRm9hVUxrVnB6TUN3K1NheHJMREhQbUVWVFZRK3NIL1VsMDBHNW5ET1EzQno0UStSb21nRW4vZlpTaXIwZFh5ZmRlL1lSN0dKcHdyOUVPclVvdzFhVkxDVnZrbHM2T1o4Tk1NWEU9Cg==
# upload assets
Expand Down
11 changes: 11 additions & 0 deletions tooling/bundler/src/bundle/windows/msi/wix.rs
Expand Up @@ -281,6 +281,15 @@ pub fn get_and_extract_wix(path: &Path) -> crate::Result<()> {
extract_zip(&data, path)
}

fn clear_env_for_wix(cmd: &mut Command) {
cmd.env_clear();
for (k, v) in std::env::vars_os() {
if ["SYSTEMROOT", "TMP", "TEMP"].contains(k) || k.to_string_lossy().starts_with("TAURI") {
cmd.env(k, v);
}
}
}

/// Runs the Candle.exe executable for Wix. Candle parses the wxs file and generates the code for building the installer.
fn run_candle(
settings: &Settings,
Expand Down Expand Up @@ -334,6 +343,7 @@ fn run_candle(
cmd.arg("-ext");
cmd.arg(ext);
}
clear_env_for_wix(&mut cmd);
cmd
.args(&args)
.current_dir(cwd)
Expand Down Expand Up @@ -369,6 +379,7 @@ fn run_light(
cmd.arg("-ext");
cmd.arg(ext);
}
clear_env_for_wix(&mut cmd);
cmd
.args(&args)
.current_dir(build_path)
Expand Down

0 comments on commit 7c0fa1f

Please sign in to comment.