Set Environment Variable
A global variable bus for your whole ComfyUI session
- any_input
- any_output
- applied
- prev_value
Set Environment Variable writes a string into the ComfyUI process's environment - os.environ[name] = value under the hood - and from that moment any other node in the session can read it, no wire required. It's a named tunnel across your graph, and ComfyUI graphs get big enough that named tunnels earn their keep fast.
The pattern the author built this for is publish/subscribe. A workflow with a sampler and three save nodes, a face detailer, and an upscaler can end up with wires snaking across the whole canvas just to share a seed or a path. Instead you "publish" once with SetEnvVar and "subscribe" anywhere with its sibling Get Environment Variable (GetEnvVar). Same value, multiple consumers, zero clutter. You can even hand state between workflows - set a value in one, read it in another running in the same session. That's genuinely hard to do any other way without a shared file.
The inputs that matter
- name - the variable name. Pick something distinctive (
OVUM_OUTPUT_DIR, notout). You share this namespace with the real OS environment, so collisions are on you. - value - the string to store. If you need a number or a structure, encode it (JSON is the obvious choice) and decode where you read it.
- overwrite - defaults to
true. Flip it tofalseand an existing value is left alone, which makes this a decent "set once" latch.
Two extras worth knowing: an optional any_input passthrough that forwards anything unchanged, and three outputs - any_output (the passthrough), applied (BOOLEAN, did it actually write?), and prev_value (STRING, what was there before).
The passthrough is the important one. ComfyUI runs on connections, not visual proximity - two nodes sitting next to each other on the canvas don't execute in any particular order unless a wire says so. If you need "set before get," thread the passthrough through the part of the graph that runs first, and get yourself an ordering guarantee without inventing data flow.
Installing it
Part of comfy-ovum, sfinktah's utility pack. ComfyUI Manager → search "comfy-ovum", or:
cd ComfyUI/custom_nodes
git clone https://github.com/sfinktah/comfy-ovum
Restart and it's there. No models, no heavy deps. One quirk of the pack: it imports every module in its root on startup, so installing it pulls in a lot of other nodes you didn't ask for. That's the trade for a grab-bag pack.
Gotchas
Nothing survives a restart - environment writes live only for the current process and its children. The pack also blocks writing to a small blocklist of dangerous variable names (the kind that change Python's behavior), and it'll tell you in the console if you hit one. And a real one: don't use this for anything you need to persist. If you want state that survives reboots and browsers, that's what the localStorage nodes in the same pack are for. For in-session coordination, though, this is the cleanest "virtual wire" in the pack.
Inputs (4)
| Name | Type | Default | Description |
|---|---|---|---|
| name | STRING | Environment variable name (e.g., PATH, MY_API_KEY). | |
| value | STRING | Value to assign to the environment variable. | |
| overwrite | BOOLEAN | true | If false, keep an existing value and do not change it. |
| any_inputopt | * | Optional passthrough input to enforce execution order; forwarded unchanged. |
Outputs (3)
| Name | Type | Description |
|---|---|---|
| any_output | * | — |
| applied | BOOLEAN | — |
| prev_value | STRING | — |