{"record":{"id":"09ceedc39cba670d","repo":"rtk-ai/rtk","slug":"tree-command-not-found-install-it-first-macos","errorCode":null,"errorMessage":"tree command not found. Install it first:\n- macOS: brew install tree\n- Ubuntu/Debian: sudo apt install tree\n- Fedora/RHEL: sudo dnf install tree\n- Arch: sudo pacman -S tree","messagePattern":"tree command not found\\. Install it first:\n- macOS: brew install tree\n- Ubuntu/Debian: sudo apt install tree\n- Fedora/RHEL: sudo dnf install tree\n- Arch: sudo pacman -S tree","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/cmds/system/tree.rs","lineNumber":16,"sourceCode":"//! tree command - proxy to native tree with token-optimized output\n//!\n//! This module proxies to the native `tree` command and filters the output\n//! to reduce token usage while preserving structure visibility.\n//!\n//! Token optimization: automatically excludes noise directories via -I pattern\n//! unless -a flag is present (respecting user intent).\n\nuse super::constants::NOISE_DIRS;\nuse crate::core::runner::{self, RunOptions};\nuse crate::core::utils::{ChildArgExt, resolved_command, tool_exists};\nuse anyhow::Result;\n\npub fn run(args: &[String], verbose: u8) -> Result<i32> {\n    if !tool_exists(\"tree\") {\n        anyhow::bail!(\n            \"tree command not found. Install it first:\\n\\\n             - macOS: brew install tree\\n\\\n             - Ubuntu/Debian: sudo apt install tree\\n\\\n             - Fedora/RHEL: sudo dnf install tree\\n\\\n             - Arch: sudo pacman -S tree\"\n        );\n    }\n\n    let mut cmd = resolved_command(\"tree\");\n\n    let show_all = args.iter().any(|a| a == \"-a\" || a == \"--all\");\n    let has_ignore = args.iter().any(|a| a == \"-I\" || a.starts_with(\"--ignore=\"));\n\n    if !show_all && !has_ignore {\n        let ignore_pattern = NOISE_DIRS.join(\"|\");\n        cmd.arg(\"-I\").arg(&ignore_pattern);\n    }\n","sourceCodeStart":1,"sourceCodeEnd":34,"githubUrl":"https://github.com/rtk-ai/rtk/blob/0924356b4caba4989607227b7c8824d3d8098719/src/cmds/system/tree.rs#L1-L34","documentation":"`rtk tree` delegates to the external `tree` binary and compresses its output. If the binary is not present on PATH (checked via tool_exists), rtk fails fast with a per-platform install hint instead of producing degraded output.","triggerScenarios":"Running `rtk tree <path>` on a machine where the `tree` executable is not installed or not on PATH; calling tree::run in containers/minimal images that lack the package.","commonSituations":"Fresh macOS (tree removed from default installs since Homebrew best practice), minimal Docker images (alpine/slim Debian) without the tree package, CI runners with a bare toolchain, wrong PATH in nix/venv/custom environments.","solutions":["Install tree per the platform in the message: macOS `brew install tree`, Ubuntu/Debian `sudo apt install tree`, Fedora/RHEL `sudo dnf install tree`, Arch `sudo pacman -S tree`.","Verify it is now reachable: `which tree` / `tree --version` (check PATH if still missing).","Use a built-in fallback if you cannot install: `find . -maxdepth 2 | sort` or `ls -R`, or `rtk proxy find ...` for tracked raw output.","Bake the tree package into your Dockerfile/CI setup script so environments are reproducible."],"exampleFix":"// before\nrtk tree .   # fails: tree command not found\n// after\nbrew install tree    # or: sudo apt install tree\nrtk tree .","handlingStrategy":"fallback","validationCode":"command -v tree >/dev/null 2>&1 || { echo 'tree is required: brew/apt/dnf/pacman install tree' >&2; exit 1; }\nrtk tree .","typeGuard":"fn tree_available() -> bool { std::process::Command::new(\"tree\").arg(\"--version\").output().is_ok() }","tryCatchPattern":"match rtk_tree_result {\n    Err(e) if e.to_string().contains(\"tree command not found\") => {\n        eprintln!(\"falling back to find-based listing\");\n        run(\"find . -maxdepth 2 | sort\")?;\n    }\n    other => other?,\n}","preventionTips":["Install `tree` during environment bootstrap (Dockerfile, setup script, CI image).","Run `command -v tree` as an environment sanity check before scripted use.","Keep a find/ls-based fallback in wrappers for minimal containers.","Pin tooling docs so new machines know rtk tree requires the external binary."],"tags":["cli","missing-binary","tree","environment"],"backgroundTag":"command-not-found","analyzedSha":"0924356b4caba4989607227b7c8824d3d8098719","analyzedAt":"2026-09-19T19:25:29.612Z","contentChangedAt":"2026-09-19T19:25:29.612Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}