astral-sh/ruff · error
Flame layer to be created
Error message
Flame layer to be created
What it means
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").
Source
Thrown at crates/ty/src/logging.rs:201
subscriber.init();
}
Ok(TracingGuard {
_flame_guard: guard,
})
}
#[expect(clippy::type_complexity)]
fn setup_profile<S>() -> (
Option<tracing_flame::FlameLayer<S, BufWriter<File>>>,
Option<tracing_flame::FlushGuard<BufWriter<File>>>,
)
where
S: Subscriber + for<'span> LookupSpan<'span>,
{
if let Ok("1" | "true") = std::env::var(EnvVars::TY_LOG_PROFILE).as_deref() {
let (layer, guard) = tracing_flame::FlameLayer::with_file("tracing.folded")
.expect("Flame layer to be created");
(Some(layer), Some(guard))
} else {
(None, None)
}
}
pub(crate) struct TracingGuard {
_flame_guard: Option<tracing_flame::FlushGuard<BufWriter<File>>>,
}
struct TyFormat {
display_timestamp: bool,
display_level: bool,
show_spans: bool,
}
/// See <https://docs.rs/tracing-subscriber/0.3.18/src/tracing_subscriber/fmt/format/mod.rs.html#1026-1156>
impl<S, N> FormatEvent<S, N> for TyFormatView on GitHub (pinned to d1087a4b9e)
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
Example fix
# before (read-only cwd -> panic on startup) TY_LOG_PROFILE=1 ty check . # after cd /tmp/writable && TY_LOG_PROFILE=1 ty check /src
Defensive patterns
Strategy: validation
Validate before calling
if [[ "${TY_LOG_PROFILE:-}" == 1 || "${TY_LOG_PROFILE:-}" == true ]]; then
[ -w . ] || { echo 'cwd not writable; unsetting TY_LOG_PROFILE'; unset TY_LOG_PROFILE; }
fi Prevention
- 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
When it happens
Trigger: 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.
Common situations: Profiling inside containers with read-only root filesystems; CI runners with restricted write access; a stray TY_LOG_PROFILE left exported in the environment.
Related errors
- `initLogging` to only be called at most once.
- `initLogging` to only be called at most once.
- extra use-def data should have been retained
- Expected a Title
- unexpected annotation type: {annotation:?}
AI-assisted analysis of astral-sh/ruff@d1087a4b9e (2026-08-20).
Data as JSON: /api/errors/b83747935492b14d.
Report an issue: GitHub.