Skip to content

[BUG] scribe: "ts_parse" fails to compile on non-Unix targets (use of "secs" before its definition) #233

Description

@comzeon

Bug description

ts_parse() in system/scribe/src/lib.rs fails to compile on any non-Unix target (e.g. Windows MSVC, aarch64-linux-android). The line that consumes secs:

let ts_ns = secs.checked_mul(1_000_000_000)?.checked_add(nsec as u64)?;

sits between the two #[cfg]-gated bindings of secs:

#[cfg(unix)]
let secs = { … };          // only compiled when target_family = "unix"
let ts_ns = secs.checked_mul(1_000_000_000)?.checked_add(nsec as u64)?;  // ← uses secs
#[cfg(not(unix))]
let secs = { … };          // only compiled when target_family != "unix"

When cfg(unix) is false, the #[cfg(unix)] let secs = {…} binding is removed by the compiler, so secs is undefined at the point where it's used (this line). Meanwhile, the #[cfg(not(unix))] let secs = {…} binding that should provide this value is declared after the use — Rust resolves #[cfg] before name resolution, so a binding cannot satisfy a use that appears before it. The result is error[E0425]: cannot find value 'secs' in this scope. The compiler hint (help: a local variable with a similar name exists: 'sec') is a red herring — this is an ordering bug, not a typo.

Affected component

Tick the closest match — maintainers confirm the final comp:* label.

System (core OS services)

  • atlas (capability registry)
  • executor
  • pilot (planner / VLM)
  • liaison (voice / user I/O)
  • scene (semantic + spatial map)
  • sentinel (safety) / soma (body model) / scribe (logging) / chronos / keystone / vitals / nexus

Service (scene-level capabilities)

  • mapping (service/map)
  • navigation
  • speech (ASR / TTS)
  • voiceprint
  • memory

Skill / Primitive

  • skill: __________ (e.g. explore)
  • primitive: __________ (camera / chassis / lidar / audio / arm)

Tooling / cross-cutting

  • rbnx (CLI) / codegen / robonix-api (pylib) / capabilities & contracts / docs / ci
  • Other / not sure

Steps to reproduce

  1. On a non-Unix host (confirmed on Windows 11 + MSVC toolchain, building for aarch64-linux-android):

    cargo build -p robonix-scribe

  2. Alternatively, from a Unix host, cross-compile to any non-Unix target to reproduce in isolation:

    rustup target install aarch64-linux-android
    cargo check -p robonix-scribe --target aarch64-linux-android

Expected behavior

robonix-scribe compiles on both Unix and non-Unix targets without error — each #[cfg]-gated secs binding should provide the value for the downstream ts_ns computation.

Actual behavior

Compilation aborts with:

error[E0425]: cannot find value `secs` in this scope
  --> system\scribe\src\lib.rs:173:17
   |
173|     let ts_ns = secs.checked_mul(1_000_000_000)?.checked_add(nsec as u64)?;
   |                 ^^^ cannot find value `secs`
   |
help: a local variable with a similar name exists: `sec`

error: could not compile `robonix-scribe` (lib) due to 1 previous error

Root cause & suggested fix

The let ts_ns = secs.checked_mul(…) line was placed between the two #[cfg] bindings of secs. Because Rust resolves #[cfg] before name resolution, the consumer of secs must appear after both bindings, not between them.

Move the let ts_ns = … line to after the #[cfg(not(unix))] block (one-line reorder, no logic change):

     };
-    let ts_ns = secs.checked_mul(1_000_000_000)?.checked_add(nsec as u64)?;
     #[cfg(not(unix))]
     let secs = {
         // …
     };
+    let ts_ns = secs.checked_mul(1_000_000_000)?.checked_add(nsec as u64)?;
     Some(ts_ns)

Note: ts_fmt() (the reverse function) uses the same #[cfg(unix)] / #[cfg(not(unix))] pattern but only consumes secs inside each cfg block separately, so it does not hit this issue.

Environment

  • rbnx version / commit: upstream dev at af7f2281 (latest as of 2026-08-13)
  • Bug present since scribe was introduced (d7d1ecaafeat: add Scribe logs)
  • Host: Windows 11 + MSVC (also reproducible cross-compiling to aarch64-linux-android from Unix)
  • Package: robonix-scribe v0.1.0

Logs

Full compile error trace (Windows MSVC, target aarch64-linux-android):

Compile output
Compiling tonic-build v0.14.6
Compiling tokio-macros v2.7.0
Compiling prost-derive v0.14.4
Compiling futures-macro v0.3.32
Compiling tracing-attributes v0.1.31
Compiling serde_derive v1.0.228
Compiling thiserror-impl v2.0.18
Compiling clap_derive v4.6.1
Compiling pin-project-internal v1.1.13
Compiling async-trait v0.1.89
Compiling futures-util v0.3.32
Compiling tokio v1.52.3
Compiling pin-project v1.1.13
Compiling tracing v0.1.44
Compiling clap v4.6.1
Compiling prost v0.14.4
Compiling robonix-scribe v0.1.0 (D:\DeepRobotics\robonix-thor\system\scribe)
Compiling futures-executor v0.3.32
error[E0425]: cannot find value `secs` in this scope
  --> system\scribe\src\lib.rs:173:17
   |
173|     let ts_ns = secs.checked_mul(1_000_000_000)?.checked_add(nsec as u64)?;
   |                 ^^^
   |
help: a local variable with a similar name exists: `sec`

error: could not compile `robonix-scribe` (lib) due to 1 previous error
warning: build failed, waiting for other jobs to finish...
note: … rustup target install aarch64-linux-android …

Additional context

  • Searched existing issues — no prior report for this.
  • The companion function ts_fmt() in the same file is unaffected (see Root cause).

Activity

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

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions