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.

Development tree command