{"record":{"id":"9f4642a909b86d91","repo":"gleam-lang/gleam","slug":"invalid-folder","errorCode":null,"errorMessage":"invalid folder","messagePattern":"invalid folder","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"compiler-cli/src/new.rs","lineNumber":491,"sourceCode":"                decided: suggested_name,\n            },\n            None => ProjectName::Derived {\n                folder: initial_name,\n                decided: suggested_name,\n            },\n        });\n    }\n\n    Err(Error::InvalidProjectName {\n        name: initial_name,\n        reason: invalid_reason,\n    })\n}\n\nfn get_foldername(path: &str) -> Result<String, Error> {\n    match path {\n        \".\" => env::current_dir()\n            .expect(\"invalid folder\")\n            .file_name()\n            .and_then(|x| x.to_str())\n            .map(ToString::to_string)\n            .ok_or(Error::UnableToFindProjectRoot {\n                path: path.to_string(),\n            }),\n        _ => Utf8Path::new(path)\n            .file_name()\n            .map(ToString::to_string)\n            .ok_or(Error::UnableToFindProjectRoot {\n                path: path.to_string(),\n            }),\n    }\n}\n\n#[derive(Debug, Clone)]\nenum ProjectName {\n    Provided { decided: String },","sourceCodeStart":473,"sourceCodeEnd":509,"githubUrl":"https://github.com/gleam-lang/gleam/blob/15b07c783065c92bb016b1b74ed0995a5259850f/compiler-cli/src/new.rs#L473-L509","documentation":"In get_foldername, when the project root path is \".\", env::current_dir() is unwrapped with .expect(\"invalid folder\"). If the current directory cannot be read (deleted, no permission) the process panics; if the directory has no valid file_name or is not UTF-8-representable, it returns UnableToFindProjectRoot instead.","triggerScenarios":"Running `gleam new .` (get_valid_project_name -> get_foldername) from a working directory that no longer exists or is inaccessible to the process.","commonSituations":"Starting gleam from a directory removed by another process/terminal; ephemeral CI containers with vanished cwd; directories with permission changes mid-session; using a cwd path outside the UTF-8 domain on some platforms.","solutions":["cd into an existing, readable directory before running the command","Recreate the deleted directory or restart the shell","Check permissions on the current directory","Pass an explicit project path instead of `.` (e.g. `gleam new my_app`)"],"exampleFix":"// before (cwd deleted)\n$ cd /tmp/gone && gleam new .\n// after\n$ cd /tmp && gleam new my_app","handlingStrategy":"validation","validationCode":"// check cwd before `gleam new .`\nmatch std::env::current_dir() {\n    Ok(d) => println!(\"cwd ok: {}\", d.display()),\n    Err(e) => eprintln!(\"fix cwd first: {}\", e),\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Don't delete the directory you are cd'd into","Pass explicit names instead of `.` when scripting","Check permissions on the target directory","Restart the shell if cwd state is questionable"],"tags":["filesystem","panic","cli","cwd"],"backgroundTag":"directory-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"}