DioxusLabs/dioxus · error

Failed to run linker

Error message

Failed to run linker

What it means

`run_link_inner` invokes the linker as a subprocess and errors with this message if the process fails to start or exits unsuccessfully. Causes include a missing/misconfigured linker binary or invalid arguments written to the link args file.

Solutions

  1. Install the required linker for your target (e.g. the Android NDK linker or wasm linker) and ensure `dx` can find it on PATH or via configuration.
Defensive patterns

Strategy: fallback

When it happens

Trigger: Thrown at packages/cli/src/cli/link.rs:156 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of DioxusLabs/dioxus@24f6a829df (2026-08-23). Data as JSON: /api/errors/9a6d7808b7da8982. Report an issue: GitHub.

Appendix: source

Thrown at packages/cli/src/cli/link.rs:156

        if self.triple.environment == target_lexicon::Environment::Android {
            args.retain(|arg| !arg.ends_with(".lib"));
        }

        // Write the linker args to a file for the main process to read
        // todo: we might need to encode these as escaped shell words in case newlines are passed
        std::fs::write(&self.link_args_file, args.join("\n"))?;

        // If there's a linker specified, we use that. Otherwise, we write a dummy object file to satisfy
        // any post-processing steps that rustc does.
        match self.linker {
            Some(linker) => {
                let mut cmd = std::process::Command::new(linker);
                match cfg!(target_os = "windows") {
                    true => cmd.arg(format!("@{}", &self.link_args_file.display())),
                    false => cmd.args(args),
                };
                let res = cmd.output().expect("Failed to run linker");

                if !res.status.success() {
                    bail!(
                        "{}\n{}",
                        String::from_utf8_lossy(&res.stdout),
                        String::from_utf8_lossy(&res.stderr)
                    );
                }
                if !res.stderr.is_empty() || !res.stdout.is_empty() {
                    // Write linker warnings to file so that the main process can read them.
                    _ = std::fs::create_dir_all(self.link_err_file.parent().unwrap());
                    _ = std::fs::write(
                        self.link_err_file,
                        format!(
                            "Linker warnings: {}\n{}",
                            String::from_utf8_lossy(&res.stdout),
                            String::from_utf8_lossy(&res.stderr)
                        ),

View on GitHub (pinned to 24f6a829df)