{"record":{"id":"b83747935492b14d","repo":"astral-sh/ruff","slug":"flame-layer-to-be-created","errorCode":null,"errorMessage":"Flame layer to be created","messagePattern":"Flame layer to be created","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/ty/src/logging.rs","lineNumber":201,"sourceCode":"        subscriber.init();\n    }\n\n    Ok(TracingGuard {\n        _flame_guard: guard,\n    })\n}\n\n#[expect(clippy::type_complexity)]\nfn setup_profile<S>() -> (\n    Option<tracing_flame::FlameLayer<S, BufWriter<File>>>,\n    Option<tracing_flame::FlushGuard<BufWriter<File>>>,\n)\nwhere\n    S: Subscriber + for<'span> LookupSpan<'span>,\n{\n    if let Ok(\"1\" | \"true\") = std::env::var(EnvVars::TY_LOG_PROFILE).as_deref() {\n        let (layer, guard) = tracing_flame::FlameLayer::with_file(\"tracing.folded\")\n            .expect(\"Flame layer to be created\");\n        (Some(layer), Some(guard))\n    } else {\n        (None, None)\n    }\n}\n\npub(crate) struct TracingGuard {\n    _flame_guard: Option<tracing_flame::FlushGuard<BufWriter<File>>>,\n}\n\nstruct TyFormat {\n    display_timestamp: bool,\n    display_level: bool,\n    show_spans: bool,\n}\n\n/// See <https://docs.rs/tracing-subscriber/0.3.18/src/tracing_subscriber/fmt/format/mod.rs.html#1026-1156>\nimpl<S, N> FormatEvent<S, N> for TyFormat","sourceCodeStart":183,"sourceCodeEnd":219,"githubUrl":"https://github.com/astral-sh/ruff/blob/d1087a4b9e03d253a88703f34e0869ee4b805456/crates/ty/src/logging.rs#L183-L219","documentation":"When TY_LOG_PROFILE is '1' or 'true', ty attaches a tracing_flame FlameLayer writing 'tracing.folded' relative to the current directory. FlameLayer::with_files creation failure is turned into a panic by .expect(\"Flame layer to be created\").","triggerScenarios":"Starting ty with TY_LOG_PROFILE=1 from a directory where 'tracing.folded' cannot be created: read-only filesystem, missing permissions, or a container/sandbox without a writable cwd.","commonSituations":"Profiling inside containers with read-only root filesystems; CI runners with restricted write access; a stray TY_LOG_PROFILE left exported in the environment.","solutions":["Unset TY_LOG_PROFILE if flame profiling was not intended","Run ty from a writable directory so tracing.folded can be created","Fix filesystem permissions or mount a writable path in containers before enabling profiling"],"exampleFix":"# before (read-only cwd -> panic on startup)\nTY_LOG_PROFILE=1 ty check .\n\n# after\ncd /tmp/writable && TY_LOG_PROFILE=1 ty check /src","handlingStrategy":"validation","validationCode":"if [[ \"${TY_LOG_PROFILE:-}\" == 1 || \"${TY_LOG_PROFILE:-}\" == true ]]; then\n  [ -w . ] || { echo 'cwd not writable; unsetting TY_LOG_PROFILE'; unset TY_LOG_PROFILE; }\nfi","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Check the environment for stray TY_LOG_PROFILE before launching ty","In containers, run ty from a writable workdir or mount one","Confirm write permission on the directory that will hold tracing.folded"],"tags":["logging","profiling","env-var","panic","file-permissions"],"backgroundTag":"log-file-creation-failed","analyzedSha":"d1087a4b9e03d253a88703f34e0869ee4b805456","analyzedAt":"2026-08-20T16:33:49.445Z","contentChangedAt":"2026-08-20T16:33:49.445Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}