{"record":{"id":"c2a2fdef2b7079f7","repo":"windmill-labs/windmill","slug":"windmill-dir-must-not-end-with-a-trailing-slash-g","errorCode":null,"errorMessage":"WINDMILL_DIR must not end with a trailing slash, got: {dir}","messagePattern":"WINDMILL_DIR must not end with a trailing slash, got: (.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"backend/windmill-common/src/worker.rs","lineNumber":834,"sourceCode":"lazy_static::lazy_static! {\n    pub static ref WINDMILL_DIR: String = {\n        let dir = std::env::var(\"WINDMILL_DIR\")\n            .unwrap_or_else(|_| {\n                #[cfg(not(windows))]\n                { \"/tmp/windmill\".to_string() }\n                #[cfg(windows)]\n                {\n                    let temp = std::env::temp_dir();\n                    let temp_str = temp.to_string_lossy();\n                    let normalized = temp_str.trim_end_matches(&['/', '\\\\'][..]).replace('\\\\', \"/\");\n                    format!(\"{}/windmill\", normalized)\n                }\n            });\n        if dir.is_empty() {\n            panic!(\"WINDMILL_DIR must not be empty\");\n        }\n        if dir.ends_with('/') || dir.ends_with('\\\\') {\n            panic!(\"WINDMILL_DIR must not end with a trailing slash, got: {dir}\");\n        }\n        dir\n    };\n    pub static ref TMP_LOGS_DIR: String = format!(\"{}/logs\", *WINDMILL_DIR);\n    pub static ref ROOT_CACHE_DIR: String = format!(\"{}/cache/\", *WINDMILL_DIR);\n    pub static ref HUB_CACHE_DIR: String = format!(\"{}hub\", *ROOT_CACHE_DIR);\n    pub static ref HUB_RT_CACHE_DIR: String = format!(\"{}hub_rt\", *ROOT_CACHE_DIR);\n}\n\npub fn write_file(dir: &str, path: &str, content: &str) -> error::Result<File> {\n    let path = format!(\"{}/{}\", dir, path);\n    let mut file = File::create(&path).map_err(|e| {\n        tracing::error!(\"Failed to create file at {path}: {:?}\", &e);\n        e\n    })?;\n    file.write_all(content.as_bytes())?;\n    file.flush()?;\n    Ok(file)","sourceCodeStart":816,"sourceCodeEnd":852,"githubUrl":"https://github.com/windmill-labs/windmill/blob/e474e8803ce2ff5c2df09a58dab51d45f5c922ca/backend/windmill-common/src/worker.rs#L816-L852","documentation":"After resolving WINDMILL_DIR (env var or normalized temp dir), Windmill validates its shape because it later appends paths like `{dir}/windmill`, `{dir}/logs`, `{dir}/cache/`. A trailing slash would yield double slashes and break assumptions about the path format, so the process panics at initialization if WINDMILL_DIR ends with '/' or '\\\\'.","triggerScenarios":"Setting `WINDMILL_DIR=/tmp/windmill/` (trailing slash) or a Windows path ending in a backslash in the environment of any Windmill binary.","commonSituations":"Copy-pasting a path with a trailing slash from a file manager; templating `WINDMILL_DIR: \"{{ .Values.dir }}/\"`; Windows bind mount paths like `C:\\\\windmill\\\\`.","solutions":["Remove the trailing slash from the WINDMILL_DIR value (e.g. /tmp/windmill instead of /tmp/windmill/)","Sanitize the value in your Helm chart / config template before injecting it","Note that the temp-dir default path already normalizes this for you — unset the var if you don't need a custom dir"],"exampleFix":"// before\nWINDMILL_DIR=/tmp/windmill/\n// after\nWINDMILL_DIR=/tmp/windmill","handlingStrategy":"validation","validationCode":"const dir = process.env.WINDMILL_DIR;\nif (dir && /[\\\\/]$/.test(dir)) throw new Error(`WINDMILL_DIR must not end with a slash: ${dir}`);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Normalize user-supplied paths (strip trailing slashes) before writing env config","Add a lint check on Helm/compose templates for trailing slashes in path values","On Windows, generate paths with a helper that omits the trailing separator"],"tags":["rust","configuration","env-var","path"],"backgroundTag":"invalid-env-var","analyzedSha":"e474e8803ce2ff5c2df09a58dab51d45f5c922ca","analyzedAt":"2026-09-03T12:38:19.024Z","contentChangedAt":"2026-09-03T12:38:19.024Z","schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}