Tree's JSON Output: A Cautionary Tale of Assumptions

2025-07-25
Tree's JSON Output: A Cautionary Tale of Assumptions

The 2.0 release of the `tree` command introduced the ability to output un-indented JSON via file descriptor 3 (Linux only). However, this initial implementation made a dangerous assumption about the user's environment, leading to widespread compatibility issues. Version 2.0.2 rectified this by requiring the `STDDATA_FD` environment variable to be set. This highlights the importance of avoiding assumptions about the user's environment in software development. The improved `tree` command now offers flexible structured data output via `STDDATA_FD`, easily processed with tools like nushell.

Read more
Development tree command

Rust's `#[derive]` Macro Limitations and Workarounds

2025-07-08
Rust's `#[derive]` Macro Limitations and Workarounds

Rust's `#[derive]` macro, when generating implementations for traits like `Clone`, requires all generic parameters to also implement `Clone`. This limits its applicability. The article analyzes two examples showing why this restriction prevents code from compiling. The author proposes two solutions: submitting an RFC to change compiler behavior, and writing a custom macro to circumvent the limitation. The author opts for the latter, planning to implement more flexible derive macros in the `derive_more` crate or a self-created crate to address this issue.

Read more
Development