DioxusLabs/dioxus · error
Failed to get current dir
Error message
Failed to get current dir
What it means
`run_rustc` reads the current working directory to record it with the captured rustc args; this panic fires if `std::env::current_dir` fails, which happens when the process's working directory has been deleted or is otherwise inaccessible.
Source
Thrown at packages/cli/src/rustcwrapper.rs:66
std::env::var(DX_RUSTC_WRAPPER_ENV_VAR).is_ok()
}
/// Run rustc directly, but output the result to a per-crate file in the args directory.
///
/// <https://doc.rust-lang.org/cargo/reference/config.html#buildrustc>
pub fn run_rustc() -> ExitCode {
let args_dir: PathBuf = std::env::var(DX_RUSTC_WRAPPER_ENV_VAR)
.expect("DX_RUSTC env var must be set")
.into();
// Cargo invokes a workspace wrapper like: `wrapper-name rustc [args...]`
// We skip our own executable name (`wrapper-name`) to get the args passed to us.
let captured_args = args().skip(1).collect::<Vec<_>>();
let rustc_args = RustcArgs {
args: captured_args.clone(),
envs: vars().collect::<_>(),
cwd: std::env::current_dir().expect("Failed to get current dir"),
};
// Always persist the captured rustc invocation, even for link steps.
// The tip crate's bin target is typically only observed during the final link invocation,
// so returning early before writing would lose the exact args/envs we need for fat-link replay.
write_rustc_args(&args_dir, &rustc_args);
// If we are being asked to link, delegate to the linker action after capturing.
if has_linking_args() {
return crate::link::LinkAction::from_env()
.expect("Linker action not found")
.run_link();
}
// Run the actual rustc command.
// We want all stdout/stderr to be inherited, so the user sees the compiler output.
let mut cmd = std::process::Command::new("rustc");
View on GitHub (pinned to 24f6a829df)
Solutions
- Run the command from a directory that still exists and is accessible; recreate or cd into a valid working directory if it was deleted.
Defensive patterns
Strategy: fallback
When it happens
Trigger: Thrown at packages/cli/src/rustcwrapper.rs:66 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/2f45dfa006f33442.
Report an issue: GitHub.