facebook/flow · error
File_key: flowlib_root has not been set
Error message
File_key: flowlib_root has not been set
What it means
Same pattern as the project root: get_flowlib_root expects Some from the global FLOWLIB_ROOT RwLock and panics when set_flowlib_root was never called. The flowlib root anchors resolution of flowlib/ and tslib/ imports, so FileKey operations on lib files hit this getter immediately when uninitialized.
Source
Thrown at rust_port/crates/flow_parser/src/file_key.rs:194
}
// Retrieve a root, crashing immediately if not set. Following Hack's
// Relative_path convention: an unset root is a programmer error that
// should be caught at the call site, not masked downstream.
pub fn get_project_root() -> String {
PROJECT_ROOT
.read()
.unwrap()
.clone()
.expect("File_key: project_root has not been set")
}
pub fn get_flowlib_root() -> String {
FLOWLIB_ROOT
.read()
.unwrap()
.clone()
.expect("File_key: flowlib_root has not been set")
}
fn is_relative(path: &str) -> bool {
std::path::Path::new(path).is_relative()
}
// libs, then source and json files at the same priority since JSON files are
// basically source files. We don't actually read resource files so they come
// last
fn order_of_inner(inner: &FileKeyInner) -> i32 {
match inner {
FileKeyInner::LibFile(_) => 1,
FileKeyInner::SourceFile(_) => 2,
FileKeyInner::JsonFile(_) => 2,
FileKeyInner::ResourceFile(_) => 3,
}
}
View on GitHub (pinned to f88ac94bcf)
Solutions
- Call set_flowlib_root right after set_project_root in the shared init function
- Add a startup assertion (call get_flowlib_root once at boot) so misconfiguration fails fast with your own message
- Review every binary/test entry point after moving initialization code
Example fix
// before — panics: flowlib root never set
let fk = FileKey::flowlib_file(&name);
// after — set both roots during startup
flow_parser::file_key::set_project_root(&format!("{}/", root.display()));
flow_parser::file_key::set_flowlib_root(&flowlib_dir.to_string_lossy());
let fk = FileKey::flowlib_file(&name); Defensive patterns
Strategy: validation
Validate before calling
// Both roots, one init — call before creating any FileKey
pub fn init_file_keys(project_root: &str, flowlib_root: &str) {
flow_parser::file_key::set_project_root(project_root);
flow_parser::file_key::set_flowlib_root(flowlib_root);
} Prevention
- Always set flowlib_root together with project_root in the shared init function
- Exercise get_flowlib_root during startup to surface misconfiguration immediately
- Audit test harnesses that only configure one of the two roots
When it happens
Trigger: Constructing or relativizing lib-file FileKeys (flowlib imports, tslib resolution) before set_flowlib_root; tests that set only the project root; binaries reusing parser APIs without the full startup sequence.
Common situations: New test binaries wired up with half the initialization; refactors that dropped the flowlib setup call; embedding flow_parser where the caller only configured a project root.
Related errors
- File_key: project_root has not been set
- failed to write flowlib file
- init failed: {:?}
- lock file is already held
- invalid line
AI-assisted analysis of facebook/flow@f88ac94bcf (2026-08-20).
Data as JSON: /api/errors/d87aefbb325d3b4f.
Report an issue: GitHub.