{"record":{"id":"24d193d739583798","repo":"nautechsystems/nautilus_trader","slug":"failed-to-get-current-directory","errorCode":null,"errorMessage":"Failed to get current directory","messagePattern":"Failed to get current directory","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/adapters/tardis/src/replay.rs","lineNumber":104,"sourceCode":"    log::debug!(\"Config filepath: {}\", config_filepath.display());\n\n    // Load and parse the replay configuration\n    let config_data = fs::read_to_string(config_filepath)\n        .with_context(|| format!(\"Failed to read config file: {}\", config_filepath.display()))?;\n    let config: TardisReplayConfig = serde_json::from_str(&config_data)\n        .context(\"failed to parse config JSON into TardisReplayConfig\")?;\n\n    let path = config\n        .output_path\n        .as_deref()\n        .map(Path::new)\n        .map(Path::to_path_buf)\n        .or_else(|| {\n            std::env::var(\"NAUTILUS_PATH\")\n                .ok()\n                .map(|env_path| PathBuf::from(env_path).join(\"catalog\").join(\"data\"))\n        })\n        .unwrap_or_else(|| std::env::current_dir().expect(\"Failed to get current directory\"));\n\n    log::debug!(\"Output path: {}\", path.display());\n\n    let normalize_symbols = config.normalize_symbols.unwrap_or(true);\n    log::debug!(\"normalize_symbols={normalize_symbols}\");\n\n    let book_snapshot_output = config\n        .book_snapshot_output\n        .clone()\n        .unwrap_or(BookSnapshotOutput::Deltas);\n    log::debug!(\"book_snapshot_output={book_snapshot_output:?}\");\n\n    let extract_bbo_as_quotes = config.extract_bbo_as_quotes.unwrap_or(false);\n    log::debug!(\"extract_bbo_as_quotes={extract_bbo_as_quotes}\");\n\n    let compression = config\n        .compression\n        .clone()","sourceCodeStart":86,"sourceCodeEnd":122,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/tardis/src/replay.rs#L86-L122","documentation":"run_tardis_machine_replay_from_config resolves the output data path from config, then the NAUTILUS_PATH env var, and finally falls back to the process current directory. If none are set and std::env::current_dir() fails (working directory deleted or unreadable), the expect panics with 'Failed to get current directory'.","triggerScenarios":"Running py_run_tardis_machine_replay with neither an output path in the config nor NAUTILUS_PATH set, while the process cwd no longer exists (deleted directory) or lacks read permission.","commonSituations":"Launching a replay from a shell whose cwd was removed by another process or a tmpfs cleanup; running inside a container started with a stale workdir; NFS/permission problems.","solutions":["Set NAUTILUS_PATH to a writable root directory so the fallback to cwd is never used.","Pass an explicit output path in the TardisMachineReplayConfig.","Recreate the removed working directory or `cd` to an existing, readable directory before launching."],"exampleFix":"// before\nsubprocess: (cd /tmp/gone-dir && nautilus tardis replay ...) # panics\n\n// after\n$ export NAUTILUS_PATH=/data/nautilus\n$ cd /data/nautilus && nautilus tardis replay ...","handlingStrategy":"validation","validationCode":"# before launching the replay\nimport os\nif not os.environ.get(\"NAUTILUS_PATH\") and config.catalog_path is None:\n    os.chdir(\"/data/nautilus\")  # ensure a valid, existing cwd\nassert os.path.isdir(os.getcwd()), \"working directory missing\"","typeGuard":"fn cwd_is_readable() -> bool {\n    std::env::current_dir().is_ok()\n}","tryCatchPattern":"try:\n    run_tardis_machine_replay(config)\nexcept BaseException as e:\n    print(f\"replay failed (check cwd / NAUTILUS_PATH): {e}\")","preventionTips":["Always set NAUTILUS_PATH or an explicit output path in the replay config.","Launch processes from stable directories that are not subject to cleanup.","Verify the cwd exists and is readable in container/CI entrypoints."],"tags":["rust","panic","tardis","replay","filesystem","working-directory"],"backgroundTag":"directory-not-found","analyzedSha":"18893faf8b356be3320add8de2f861b0b647cf06","analyzedAt":"2026-09-08T20:49:34.690Z","contentChangedAt":"2026-09-08T20:49:34.690Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}