{"record":{"id":"3f4c3ccb7f306697","repo":"gleam-lang/gleam","slug":"directory-name","errorCode":null,"errorMessage":"Directory name","messagePattern":"Directory name","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"compiler-cli/src/export.rs","lineNumber":164,"sourceCode":"            codegen: Codegen::All,\n            compile: Compile::All,\n            mode,\n            target: Some(target),\n            no_print_progress: false,\n            erlang_output: ErlangOutput::Binary,\n        },\n        crate::build::download_dependencies(paths, crate::cli::Reporter::new())?,\n    )?;\n\n    for entry in fs::read_dir(&build)?.filter_map(Result::ok) {\n        let path = entry.path();\n\n        // We are only interested in package directories\n        if !path.is_dir() {\n            continue;\n        }\n\n        let name = path.file_name().expect(\"Directory name\");\n        let build = build.join(name);\n        let out = out.join(name);\n        fs::mkdir(&out)?;\n\n        // Copy desired package subdirectories\n        for subdirectory in [\"ebin\", \"priv\", \"include\"] {\n            let source = build.join(subdirectory);\n            if source.is_dir() {\n                let source = fs::canonicalise(&source)?;\n                let out = out.join(subdirectory);\n                fs::copy_dir(source, &out)?;\n            }\n        }\n    }\n\n    // PowerShell entry point script.\n    write_entrypoint_script(\n        &out.join(ENTRYPOINT_FILENAME_POWERSHELL),","sourceCodeStart":146,"sourceCodeEnd":182,"githubUrl":"https://github.com/gleam-lang/gleam/blob/15b07c783065c92bb016b1b74ed0995a5259850f/compiler-cli/src/export.rs#L146-L182","documentation":"During `gleam export erlang-shipment`, the code iterates build-directory entries, and for each directory calls path.file_name().expect(\"Directory name\"). file_name() returns None only for paths ending in '..' or the filesystem root, so this panics if a directory entry in build/packages has no final path component.","triggerScenarios":"Exporting an Erlang shipment when a package subdirectory path under the build directory resolves to a path with no file_name — practically caused by unusual symlinks, a directory literally at a root-like path, or a corrupted build tree.","commonSituations":"Symlinked or bind-mounted build directories on unusual filesystems; corrupted build output after interrupted builds; running the export with a redirected build path pointing at an odd location.","solutions":["Delete the build directory and re-run `gleam build` before `gleam export erlang-shipment`","Check for symlinks or mounts inside build/ that produce root-like paths and replace them with real directories","Run the export from the project root with default paths so the build directory layout is standard","Report to the Gleam repo — the code should skip unnamed entries instead of panicking"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Validate build tree before export\nfor entry in fs::read_dir(\"build/packages\")? {\n    let p = entry?.path();\n    if p.is_dir() && p.file_name().is_none() {\n        return Err(\"corrupt build directory entry; delete build/ and rebuild\".into());\n    }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Delete the build directory if a build was interrupted, then rebuild before exporting","Avoid symlinking or bind-mounting directories inside build/","Always run export from the project root with standard project layout"],"tags":["filesystem","export","erlang","panic"],"backgroundTag":"file-not-found","analyzedSha":"15b07c783065c92bb016b1b74ed0995a5259850f","analyzedAt":"2026-09-14T11:14:59.388Z","contentChangedAt":"2026-09-14T11:14:59.388Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}