{"id":3804,"library":"shyaml","title":"shyaml: YAML for the Command Line (Python version)","description":"The original `shyaml` Python library (v0.6.2) is a command-line tool designed for reading and querying YAML files. It enables shell scripts to easily access YAML data using simple dot-notation paths. While it remains available on PyPI, this Python version is in a low-maintenance state with no new features planned. Active development has transitioned to `shyaml-rs`, a Rust rewrite that offers significant performance improvements and additional features like write capabilities, while maintaining command-line interface compatibility.","status":"maintenance","version":"0.6.2","language":"python","source_language":"en","source_url":"https://github.com/0k/shyaml","tags":["yaml","cli","parser","configuration","shell","automation"],"install":[{"cmd":"pip install shyaml","lang":"bash","label":"Install with pip"}],"dependencies":[{"reason":"Used for YAML parsing in the Python version.","package":"PyYAML","optional":false}],"imports":[{"note":"The Python `shyaml` library is primarily intended as a command-line tool. While a Python API exists via `shyaml.do()`, its typical usage involves piping YAML data from standard input to the `shyaml` executable rather than direct Python imports for general-purpose YAML manipulation.","symbol":"shyaml.do","correct":"import shyaml\n# ... then call shyaml.do(stdin_stream, args)"}],"quickstart":{"code":"cat <<EOF > config.yaml\ndatabase:\n  host: localhost\n  port: 5432\n  credentials:\n    username: admin\n    password: ${DB_PASSWORD:-fallback_pass}\nEOF\n\nDB_PASSWORD=\"secure_pass\" \\\n  cat config.yaml | shyaml get-value database.credentials.password","lang":"bash","description":"The primary use of `shyaml` is via the command line to extract values from YAML. It reads YAML from standard input and outputs the requested value to standard output. Paths are specified using dot notation."},"warnings":[{"fix":"Consider migrating to `shyaml-rs` for performance and new features. If you rely solely on CLI parsing, `shyaml-rs` should work seamlessly: `cargo install shyaml-rs` (if Rust is installed) or download a pre-built binary.","message":"The Python `shyaml` library is in maintenance mode. `shyaml-rs`, a Rust rewrite, is the actively developed and recommended replacement. `shyaml-rs` is designed as a drop-in CLI replacement, offering 14-42x faster performance and new write capabilities (e.g., `set-value`, `del`, `apply`) not present in the Python version.","severity":"gotcha","affected_versions":"All versions of Python shyaml"},{"fix":"Always provide a default value as the third argument to `shyaml get-value` if the key might be missing and you don't want an error: `cat file.yaml | shyaml get-value some.path 'my_default_value'`","message":"Handling of missing paths changed significantly in version 0.3. Prior to 0.3, if a specified key was not found, `shyaml` would return an empty string by default. From version 0.3 onwards (inclusive), if a key is not found and no default value is explicitly provided as the third argument, `shyaml` will print an error message and exit.","severity":"breaking","affected_versions":"< 0.3 vs. >= 0.3"},{"fix":"Ensure your scripts do not rely on a specific (or alphabetically sorted) order of keys if using older versions, or upgrade to 0.4.0+ if order preservation is critical. The current version (0.6.2) preserves order.","message":"Ordered mappings behavior changed in version 0.4.0. Before 0.4.0, `shyaml` would alphabetically re-order keys in mappings. While YAML specification considers mappings unordered, this behavior could be unexpected for users. From version 0.4.0 onwards, `shyaml` preserves the order of keys in mappings.","severity":"breaking","affected_versions":"< 0.4.0 vs. >= 0.4.0"},{"fix":"Use `shyaml --yaml get-value ...` or `shyaml -y get-value ...` to ensure strict YAML output for all values.","message":"By default, `shyaml` outputs simple string or number values directly without YAML quotes for convenience. This means the output is not strictly valid YAML in all cases. If you need strict YAML output (e.g., for piping to another YAML processor), you must use the `--yaml` or `-y` option.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"search_vec":"'access':34 'activ':64 'addit':81 'autom':98 'avail':46 'capabl':85 'cli':94 'command':5,18,89 'command-lin':17,88 'compat':92 'configur':96 'data':36 'design':21 'develop':65 'dot':40 'dot-not':39 'easili':33 'enabl':29 'featur':62,82 'file':27 'improv':79 'interfac':91 'librari':13 'like':83 'line':6,19,90 'low':56 'low-mainten':55 'maintain':87 'mainten':57 'new':61 'notat':41 'offer':76 'origin':10 'parser':95 'path':42 'perform':78 'plan':63 'pypi':48 'python':7,12,50 'queri':25 'read':23 'remain':45 'rewrit':74 'rs':71 'rust':73 'script':31 'shell':30,97 'shyaml':1,11,70 'shyaml-r':69 'signific':77 'simpl':38 'state':58 'tool':20 'transit':67 'use':37 'v0.6.2':14 'version':8,51 'write':84 'yaml':2,26,35,93","created_at":"2026-04-11T17:45:24.838347+00:00","updated_at":"2026-04-16T21:42:57.725266+00:00","problems":[{"fix":"Ensure `shyaml` is installed by running `pip install shyaml`. Verify your system's PATH environment variable includes the directory where pip installs scripts (e.g., `~/.local/bin` on Linux or `Scripts` in your Python installation directory).","cause":"The `shyaml` command-line executable is not located in your system's PATH, typically due to an incomplete installation or the Python scripts directory not being added to PATH.","error":"shyaml: command not found"},{"fix":"Double-check the filename and its full or relative path. Confirm that `config.yaml` exists and that `shyaml` has read permissions for the file and its parent directories.","cause":"The specified YAML file, `config.yaml`, does not exist at the given path, or `shyaml` does not have the necessary permissions to access it.","error":"shyaml: ERROR: Cannot find file \"config.yaml\""},{"fix":"Review `data.yaml` for any syntax issues. Use a YAML linter or validator to pinpoint and correct errors in the file's structure.","cause":"The YAML file, `data.yaml`, contains syntax errors (e.g., incorrect indentation, missing colons, or invalid structure) that prevent `shyaml` (which uses PyYAML) from parsing it successfully.","error":"shyaml: ERROR: Cannot parse YAML file \"data.yaml\""},{"fix":"Install the package by running `pip install shyaml` in your terminal. If you are using multiple Python environments, ensure the correct one is activated.","cause":"The `shyaml` Python package is not installed in the currently active Python environment, or the Python interpreter is unable to locate it.","error":"ModuleNotFoundError: No module named 'shyaml'"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":"0.6.2","cli_name":"shyaml","cli_version":"version: 0.6.2","type":"library","homepage":null,"github":"http://github.com/0k/shyaml","docs":null,"changelog":null,"pypi":"https://pypi.org/project/shyaml/","npm":null,"openapi_spec":null,"status_page":null,"smithery":null,"categories":["devops","serialization"],"base_url":null,"auth_type":null,"provenance":{"verified_status":"passing","verified_at":"2026-06-28","last_verified":"2026-08-29","next_check":"2026-07-28","install_tag":null}}