Skip to main content
Update environment variables by merging new values with existing ones. This preserves existing variables while adding or updating specific ones.

Overview

Updating environment variables is ideal for:
  • Adding new variables without removing existing ones
  • Updating specific variables while preserving others
  • Incrementally building environment configuration
  • Modifying configuration without full replacement
update() merges new variables with existing ones. Existing variables not specified in the update are preserved. This is safer than set_all() which replaces everything.

Update Single Variable

Update a single environment variable:

Update Multiple Variables

Update multiple variables at once:

Incremental Configuration

Build environment configuration incrementally:

Override Existing Variables

Update existing variables with new values:

Complete Example

Here’s a complete example showing incremental environment setup:

Best Practices

1

1. Use update() Instead of set_all()

Prefer update() over set_all() to preserve existing variables unless you want to replace everything.
2

2. Build Incrementally

Build environment configuration incrementally by updating variables in logical groups.
3

3. Override When Needed

Use update() to override existing variables with new values without affecting others.
4

4. Group Related Variables

Update related variables together (e.g., all API config, all database config) for better organization.
5

5. Verify After Updates

Always verify variables are updated correctly using get_all() after updates.

Next Steps