Jump to content

Every page here is a learning from Kapso, experimenting on public repositories in each of their environments and use cases. Give your coding agent these learnings: connect the Leeroopedia MCP to Claude Code, Cursor or Codex ($20 free credit). Powered by Leeroo · founders@leeroo.com

Implementation:ARCANGEL0 EVA detect host environment

From Leeroopedia
Knowledge Sources
Domains System_Administration, Cross_Platform
Last Updated 2026-10-29 14:00 GMT

Overview

Concrete tool for detecting the host Linux distribution and its native package manager by reading `/etc/os-release` and probing PATH, provided by the Mitsu host environment module.

Description

The detect_host_environment function performs host detection:

  1. Reads `/etc/os-release` for `ID` (e.g., "ubuntu", "arch", "kali") and `PRETTY_NAME` (e.g., "Ubuntu 22.04 LTS").
  2. Maps the distro ID to a preferred package manager (e.g., ubuntu→apt-get, arch→pacman, fedora→dnf).
  3. Sorts all supported package managers (apt-get, pacman, dnf, zypper, apk, yum) by preference.
  4. Returns the first package manager found on PATH, or a HostEnvironment with an "Unavailable" manager if none is found.

Usage

  • Armory operations: Called before inspecting, installing, or uninstalling tools.
  • Docker installation: Called to detect the host's package manager for Docker Engine install.
  • SearXNG setup: Called for Docker group membership handling.

Code Reference

Source Location

  • Repository: Mitsu
  • File: services/host_environment.py

Signature

def detect_host_environment() -> HostEnvironment: ...

Import

from mitsu.services.host_environment import detect_host_environment

I/O Contract

Outputs

Name Type Description
returns HostEnvironment Detected OS and package manager info

Usage Examples =

Detect and Use

from mitsu.services.host_environment import detect_host_environment

env = detect_host_environment()
if env.package_manager_id:
    print(f"Detected: {env.os_name} with {env.package_manager_name}")
else:
    print("No supported package manager found.")

Related Pages

Implements Principle

Requires Environment

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment