calesthio/OpenMontage · error · DependencyError
Environment variable {env_name!r} not set. {self.install_ins
Error message
Environment variable {env_name!r} not set. {self.install_instructions} What it means
Raised by BaseTool.check_dependencies when a dependency declared with the env: prefix names an environment variable that is unset or empty in the current process. The DependencyError includes the variable name and the tool's install_instructions. This is the standard gate for API keys and configuration flags (e.g. env:KLING_API_KEY, env:ELEVENLABS_API_KEY).
Source
Thrown at tools/base_tool.py:317
self.check_dependencies()
return ToolStatus.AVAILABLE
except DependencyError:
return ToolStatus.UNAVAILABLE
def check_dependencies(self) -> None:
"""Verify all dependencies are installed. Raises DependencyError if not."""
for dep in self.dependencies:
if dep.startswith(("cmd:", "binary:")):
prefix = "cmd:" if dep.startswith("cmd:") else "binary:"
cmd_name = dep[len(prefix):]
if shutil.which(cmd_name) is None:
raise DependencyError(
f"Command {cmd_name!r} not found. {self.install_instructions}"
)
elif dep.startswith("env:"):
env_name = dep[4:]
if not os.environ.get(env_name):
raise DependencyError(
f"Environment variable {env_name!r} not set. {self.install_instructions}"
)
elif dep.startswith("python:"):
module_name = dep[7:]
try:
__import__(module_name)
except ImportError:
raise DependencyError(
f"Python module {module_name!r} not installed. {self.install_instructions}"
)
def get_info(self) -> dict[str, Any]:
"""Return full tool contract info for registry/discovery."""
usage_location = inspect.getfile(self.__class__)
return {
"name": self.name,
"version": self.version,
"tier": self.tier.value,View on GitHub (pinned to 95e1c3d0ab)
Solutions
- Export the variable in the process that runs the tool (export KLING_API_KEY=... or inject via your secret runner such as devkey run <key> -- <cmd>)
- For services/containers, add the variable to the unit file, compose env, or CI secrets mapping — an empty value also fails
- Never hardcode the key in code; reference it by name and inject at runtime
- Gate with tool.check_available() during preflight so missing keys surface as UNAVAILABLE, not a crash
Defensive patterns
Strategy: validation
Validate before calling
import os
missing_env = [d[4:] for d in tool.dependencies if d.startswith("env:") and not os.environ.get(d[4:])]
if missing_env:
raise SystemExit(f"missing env vars: {missing_env}; inject them via your secret runner")
# or: assert tool.check_available() is ToolStatus.AVAILABLE Type guard
def tool_env_vars_set(tool) -> bool:
import os
return all(os.environ.get(d[4:]) for d in tool.dependencies if d.startswith("env:")) Try / catch
from tools.base_tool import DependencyError
try:
tool.check_dependencies()
except DependencyError as e:
if "Environment variable" in str(e):
raise SystemExit(f"inject the key via devkey, then retry: {e}") from e
raise Prevention
- Inject secrets via the project's secret runner (devkey run <key> -- <cmd>) so child processes inherit them
- Empty-string values also fail the check — verify presence, not just definition
- Map CI/service secret names to the exact env var names tools declare
When it happens
Trigger: Invoking a tool that declares env:SOME_KEY without exporting it; the variable set in the interactive shell but not in the daemon/service/CI process; a .env file that the process never loaded; the variable exported as an empty string, which also fails the check.
Common situations: Keys configured per the project's devkey/secret-management workflow but not injected into the child process; cron/systemd/Docker environments missing exports; CI secrets not mapped to the expected variable name.
Related errors
- Required environment variable {key!r} is not set
- Command {cmd_name!r} not found. {self.install_instructions}
- GOOGLE_APPLICATION_CREDENTIALS is not set or points to a mis
- ARK_BASE_URL must be an https:// URL
- ARK_CNY_PER_USD must be a finite number greater than 0
AI-assisted analysis of calesthio/OpenMontage@95e1c3d0ab (2026-08-15).
Data as JSON: /api/errors/8839bcb012b9ceeb.
Report an issue: GitHub.