{"id":3990,"library":"envyaml","title":"EnvYAML","description":"EnvYAML is a Python library that simplifies reading YAML configuration files and seamlessly integrates environment variables. It allows referencing environment variables directly within YAML files using the `${VAR_NAME}` or `$VAR_NAME` syntax, providing a flexible and secure way to manage configurations. The library is currently at version 1.10.211231 and is actively maintained with regular updates, often focusing on bug fixes and minor feature enhancements.","status":"active","version":"1.10.211231","language":"en","source_language":"en","source_url":"https://github.com/thesimj/envyaml","tags":["configuration","yaml","environment variables","config management","secrets"],"install":[{"cmd":"pip install envyaml","lang":"bash","label":"Install EnvYAML"}],"dependencies":[{"reason":"EnvYAML is built on top of PyYAML for core YAML parsing functionality.","package":"PyYAML"}],"imports":[{"symbol":"EnvYAML","correct":"from envyaml import EnvYAML"}],"quickstart":{"code":"import os\nfrom envyaml import EnvYAML\n\n# Create a dummy YAML file\nwith open('config.yaml', 'w') as f:\n    f.write('app:\\n')\n    f.write('  name: \"${APP_NAME}\"\\n')\n    f.write('  version: \"${APP_VERSION|1.0.0}\"\\n')\n    f.write('database:\\n')\n    f.write('  host: $DB_HOST\\n')\n    f.write('  port: $DB_PORT|5432\\n')\n    f.write('  password: $DB_PASSWORD\n')\n\n# Set environment variables (or they will default if specified in YAML)\nos.environ['APP_NAME'] = 'MyAwesomeApp'\nos.environ['DB_HOST'] = 'localhost'\nos.environ['DB_PASSWORD'] = os.environ.get('DB_PASSWORD', 'super_secret_dev')\n\n# Initialize EnvYAML\nenv = EnvYAML('config.yaml')\n\n# Access configuration values\nprint(f\"App Name: {env['app.name']}\")\nprint(f\"App Version: {env['app.version']}\")\nprint(f\"Database Host: {env['database.host']}\")\nprint(f\"Database Port: {env['database.port']}\")\nprint(f\"Database Password: {env['database.password']}\")\n\n# Clean up dummy file\nos.remove('config.yaml')\n","lang":"python","description":"This quickstart demonstrates how to create a simple YAML configuration file that references environment variables, load it using EnvYAML, and access the configuration values. It includes examples for mandatory and optional environment variables with default values."},"warnings":[{"fix":"To disable strict mode, initialize `EnvYAML('config.yaml', strict=False)` or set the `ENVYAML_STRICT_DISABLE` environment variable before initialization. Ensure all referenced environment variables are set if strict mode is active.","message":"Enabling 'strict' mode (which is default) can cause `ValueError` exceptions if environment variables are not defined. Prior to version 1.5.201226, strict mode might have been less stringent about duplicate variable definitions in `.env` files.","severity":"breaking","affected_versions":"<1.5.201226"},{"fix":"Use `$$` for a literal `$` in your YAML configuration.","message":"Single dollar sign (`$VAR_NAME`) is used for environment variable substitution. To use a literal dollar sign in your YAML, it must be escaped with a double dollar sign (`$$`). For example, `escaped: $$.extra` will result in `$.extra`.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Always quote values that should be treated as strings, e.g., `country: \"NO\"` instead of `country: NO`, to prevent unintended boolean conversion.","message":"Parsing of boolean values can be ambiguous in YAML. Strings like `NO`, `ON`, `OFF`, `YES`, `TRUE`, `FALSE` (case-insensitive) can be interpreted as boolean `False` or `True` respectively by underlying YAML parsers (like PyYAML, which EnvYAML uses).","severity":"gotcha","affected_versions":"All versions"},{"fix":"Review configurations using `$` or `$$` notation, especially if upgrading from much older versions, to ensure they parse as intended. The current behavior (1.10.211231+) is more precise for escaped dollar signs.","message":"Older versions of EnvYAML might have handled escaped dollar signs or multiple variable definitions differently. Version 1.10.211231 specifically made a 'specific replacement instead of a general replacement for escaped dollar signs', indicating a refinement in how escaping is processed.","severity":"deprecated","affected_versions":"<1.10.211231"}],"env_vars":null,"last_verified":"2026-04-11T00:00:00.000Z","next_check":"2026-07-10T00:00:00.000Z"}