Skip to content

Release builds: a shipped app parses Rune's dev flags and starts interaction timing from an ambient OTEL variable; a fix is on a fork #589

Done

Description

@Entrpi

A native app that passes no list to App::args parses its command line with Rune's dev parser in every build. App::try_run calls Args::parse(). extra_args, is_headless, run_windows and the hot path read the process's arguments the same way. So a release binary:

  • obeys --snap, --script, --trace and --help;
  • exits with code 2 on a malformed value, such as --size large, or a file named like a flag that a launcher or shell passes.

Separately, tooling::interaction::gate turns interaction timing on in any build when OTEL_EXPORTER_OTLP_ENDPOINT names a loopback address. A collector set up for another tool on the user's machine then starts stack sampling and span export in a shipped app that never asked for it.

Fix

096405f0 is one commit on dev 14e3c5d, on branch safety-release-dev-surface of Entrpi/rune.

  • One decision. tooling::dev_surface decides whether Rune's dev surface is on. A debug build always has it. A build without debug assertions has it only when one of these is true:
    • the app calls the new rune::dev_tooling() first in main, so it holds for run, run_windows, extra_args and is_headless alike;
    • RUNE_DEV=1 is set. This is Rune's own variable, and nothing sets it by accident.
  • Without it, Rune parses no process argument: every argument goes to extra_args untouched, so nothing Rune reads can exit the process. With it, the parser is unchanged, including --help and exit code 2.
  • An app's own list passed with App::args or run_windows_with_args is Rune's in any build, because the app chose it.
  • Interaction timing. The gate reads its environment through a pure gate::wanted_in(var, debug, opted_in, headless). Without the dev surface it ignores the OTEL endpoint. RUNE_PERF=1 still turns timing on in any build, and RUNE_PERF=0 still wins.
  • Non-UTF-8 arguments. The process's arguments are read with args_os, so one that isn't valid UTF-8 reaches the app with replacement characters instead of panicking.
  • The repo's own tooling drives optimised builds with Rune's flags, so it now sets RUNE_DEV=1. That covers:
    • perf_binary, and through it the bench and native-pacing scripts;
    • kit-diff, motion-audit, snap-ui, text-goldens and real-frames;
    • the cursed-settings capture scripts;
    • the release and perf commands in the READMEs, and the site snippet cut from one.
  • Examples that guessed headless mode by scanning the arguments themselves now ask rune::is_headless(): live-values, overlay, video-tiles and launcher.
  • README. The rune README says how to drive an optimised build, and it has one table of every RUNE_* variable read outside tests, with its effect and the builds that read it. A changelog fragment is added.

RUNE_DEV=1 is the one deviation from "the app opts in": without it, the repo's benchmark and snapshot scripts could not drive a --profile perf build of an app that doesn't call dev_tooling().

Tests

  • tooling/dev_surface_tests.rs covers:
    • the decision for each build kind, environment and opt-in;
    • gate::wanted_in over a fake environment;
    • the argument split with and without the dev surface.
  • tests/dev_surface_release.rs is ignored by default, because it builds examples/dev_surface.rs in release. It checks that:
    • the release binary keeps --snap, a malformed flag and --help for the app, and exits 0;
    • RUNE_DEV=1 makes --snap render, and so does rune::dev_tooling() with both App::run and run_windows;
    • opted in, a malformed flag exits with code 2, as in a debug build.

On macOS (Apple silicon), the documented test command, cargo test -p rune -p rune-kit --features rune-kit/markdown --no-fail-fast, passes with this branch and the other three safety branches merged on dev 14e3c5d: 2,786 passed, 0 failed. Dev alone gives 2,749 passed, 0 failed. The four branches are safety-secure-fields, safety-hostile-content, safety-gpu-failures and safety-release-dev-surface; they merge cleanly except for one import line in image.rs. cargo check --workspace --all-targets and scripts/file-size.sh pass. The ignored tests/dev_surface_release.rs passes too.

Filed together with #586, #587 and #588, the other safety fixes from the same review.

Activity

  1. Hona commented on Nov 24, 2026

    @Hona
    Member

    Fixed on dev in #1775 (652950bb1).

    Popular Rust UI frameworks gate developer tooling behind a compile-time switch (debug_assertions or an off-by-default Cargo feature) rather than parsing host CLI flags or ambient environment variables in shipped release builds: Tauri (crates/tauri-runtime-wry/src/lib.rs, any(debug_assertions, feature = "devtools")), GPUI (crates/gpui/src/element.rs, any(feature = "inspector", debug_assertions)), Iced (debug / tester features), Bevy (dev / trace_* features), and Electron's build-time fuses all follow this pattern, and OpenTelemetry's OTEL_EXPORTER_OTLP_ENDPOINT configures an enabled exporter rather than auto-starting tracing in a shipped app.

    Release builds without Rune's tooling (or hot) feature now skip process flag parsing in crates/rune/src/tooling/args.rs (passing every argument untouched to extra_args(), decoding OS arguments lossily so non-UTF-8 arguments do not panic, and returning false from is_headless()) and ignore an ambient OTEL_EXPORTER_OTLP_ENDPOINT in crates/rune/src/tooling/interaction/gate.rs unless RUNE_PERF=1 is set. Debug builds, release builds with tooling, and explicit App::args / run_windows_with_args lists keep parsing Rune's flags.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions