rust-lang/rust-analyzer · error
Unable to convert to an AbsPath
Error message
Unable to convert to an AbsPath
What it means
This panic occurs in rust-analyzer's workspace fetching when a build-file path reported by a project-discovery provider cannot be converted into an AbsPathBuf. AbsPathBuf only represents absolute, canonical filesystem paths, so a relative or otherwise invalid path makes try_from fail and the expect panics. It indicates the build system produced a build_file path that is not absolute.
Source
Thrown at crates/rust-analyzer/src/reload.rs:324
sender
.send(Task::FetchWorkspace(ProjectWorkspaceProgress::Report(msg)))
.unwrap()
}
};
sender.send(Task::FetchWorkspace(ProjectWorkspaceProgress::Begin)).unwrap();
if let (Some(_command), Some(path)) = (&discover_command, &path) {
let build = linked_projects.iter().find_map(|project| match project {
LinkedProject::InlineProjectJson(it) => it.crate_by_buildfile(path),
_ => None,
});
if let Some(build) = build
&& is_quiescent
{
let path = AbsPathBuf::try_from(build.build_file)
.expect("Unable to convert to an AbsPath");
let arg = DiscoverProjectParam::Buildfile(path);
sender.send(Task::DiscoverLinkedProjects(arg)).unwrap();
}
}
let mut workspaces: Vec<_> = linked_projects
.iter()
.map(|project| match project {
LinkedProject::ProjectManifest(manifest) => {
debug!(path = %manifest, "loading project from manifest");
project_model::ProjectWorkspace::load(
manifest.clone(),
&cargo_config,
&progress,
)
}
LinkedProject::InlineProjectJson(it) => {View on GitHub (pinned to e8f7e90aa3)
Solutions
- Find which discovery provider produced the offending build_file and make it emit an absolute path (canonicalize before reporting).
- Check rust-analyzer's project-discovery configuration (rust-analyzer.linkedProjects / workspace layout) for paths specified relatively; convert them to absolute paths.
- Update rust-analyzer to the latest version in case the provider was fixed to canonicalize build-file paths.
- Report a bug with the workspace layout if the build system legitimately emits relative build_file paths.
Example fix
// before (provider emits relative path)
build.build_file = "target/build-file.json";
// after
build.build_file = std::path::absolute("target/build-file.json").unwrap().into(); Defensive patterns
Strategy: validation
Validate before calling
fn ensure_absolute(p: &str) -> Option<AbsPathBuf> {
let pb = std::path::PathBuf::from(p);
if pb.is_absolute() { AbsPathBuf::try_from(pb).ok() } else {
std::path::absolute(p).ok()?.try_into().ok()
}
} Type guard
fn is_absolute_buildfile(p: &str) -> bool { std::path::Path::new(p).is_absolute() } Prevention
- Always canonicalize build-file paths before handing them to rust-analyzer discovery APIs
- Never configure linkedProjects with relative paths
- Pin rust-analyzer versions tested with your build-system plugin
When it happens
Trigger: A workspace-discovery provider (e.g. cargo/JSON project discovery via DiscoverProjectParam::Buildfile) returns a build.build_file that is a relative path or empty/non-UTF8 path, so AbsPathBuf::try_from fails during fetch_workspaces while dispatching linked-project discovery.
Common situations: Custom or third-party build-system discovery emitting relative buildfile paths; running rust-analyzer in environments where the tool that generates build files misreports locations; rust-analyzer config pointing discovery at a project whose build-file path is computed relative to the workspace root.
Related errors
- profiler failed to start
- A receiver has been dropped, something panicked!
- Unable to serialize data
- Unable to write data
- not a BlockExpr
AI-assisted analysis of rust-lang/rust-analyzer@e8f7e90aa3 (2026-09-03).
Data as JSON: /api/errors/56b39f3b66c66710.
Report an issue: GitHub.