{"record":{"id":"d4d761f719419918","repo":"gleam-lang/gleam","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":"compiler-cli/src/lib.rs","lineNumber":1047,"sourceCode":"\nfn initialise_logger() {\n    let enable_colours = std::env::var(\"GLEAM_LOG_NOCOLOUR\").is_err();\n    tracing_subscriber::fmt()\n        .with_writer(std::io::stderr)\n        .with_env_filter(std::env::var(\"GLEAM_LOG\").unwrap_or_else(|_| \"off\".into()))\n        .with_target(false)\n        .with_ansi(enable_colours)\n        .without_time()\n        .init();\n}\n\nfn find_project_paths(current_dir: Utf8PathBuf) -> Result<ProjectPaths> {\n    get_project_root(current_dir).map(ProjectPaths::new)\n}\n\n#[cfg(test)]\nfn project_paths_at_current_directory_without_toml() -> ProjectPaths {\n    let current_dir = get_current_directory().expect(\"Failed to get current directory\");\n    ProjectPaths::new(current_dir)\n}\n\nfn download_dependencies(paths: &ProjectPaths) -> Result<()> {\n    _ = dependencies::resolve_and_download(\n        paths,\n        cli::Reporter::new(),\n        None,\n        Vec::new(),\n        dependencies::DependencyManagerConfig {\n            use_manifest: dependencies::UseManifest::Yes,\n            check_major_versions: dependencies::CheckMajorVersions::No,\n        },\n    )?;\n    Ok(())\n}\n","sourceCodeStart":1029,"sourceCodeEnd":1064,"githubUrl":"https://github.com/gleam-lang/gleam/blob/49f8762da595eb3c8f576656a4200a142ca188c9/compiler-cli/src/lib.rs#L1029-L1064","documentation":"In test-only helper project_paths_at_current_directory_without_toml, get_current_directory() is unwrapped with the message 'Failed to get current directory'. It fires when the process' current working directory cannot be read, usually because it was deleted or is unreadable. It is returned by/used from the build_lock test functions locking_global, locking_dev_erlang, etc.","triggerScenarios":"Calling any of the BuildLock tests (locking_global, locking_dev_erlang, locking_prod_erlang, locking_dev_javascript, locking_prod_javascript, locking_lsp_erlang) while the shell's cwd no longer exists (deleted directory, stale container mount).","commonSituations":"Running `cargo test` from a directory that was removed or replaced by another process; test runners launched in ephemeral containers whose working dir vanished; sandboxed environments denying access to the cwd.","solutions":["cd into an existing directory before running the tests","Recreate the deleted working directory or restart your shell/terminal","In sandboxed/CI environments ensure the test working directory exists and is readable","If it persists, check filesystem permissions on the directory"],"exampleFix":"// before (cwd deleted)\n$ rm -rf ../some-dir && cd ../some-dir && cargo test\n// after\n$ cd /path/to/gleam && cargo test -p gleam-cli build_lock","handlingStrategy":"validation","validationCode":"// run from a directory that exists\nassert!(std::env::current_dir().is_ok(), \"cwd missing\");","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always run tests from an existing directory","Restart shells after deleting directories","Ensure CI containers seed a valid working dir","Avoid removing the directory your shell sits in"],"tags":["filesystem","test","panic","cwd"],"backgroundTag":"directory-not-found","analyzedSha":"49f8762da595eb3c8f576656a4200a142ca188c9","analyzedAt":"2026-09-14T11:14:59.388Z","contentChangedAt":"2026-09-14T11:14:59.388Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}