Baike.dev
All toolsAI codingTrendingOpen sourceNewsSubmit
Log in
Back to tool/Back to issues
#1837·OpenSandbox

SDK: Add commands.setEnv syntactic sugar for runtime environment variable injection

Author: PangjipingCreated Sep 14, 2026Updated Sep 16, 2026
Labelshelp wantedsdks

Problem

Updating environment variables at runtime currently requires a raw shell command manipulating the internal $EXECD_ENVS file: await sandbox.commands.run("""printf '%s=%s\n' 'MY_TOKEN' 'value' >> "$EXECD_ENVS" """) Issues:

  1. Shell escaping risk — values with single quotes, backslashes, or special chars break the printf format string
  2. Implementation detail leak — users must know $EXECD_ENVS (internal execd concept)
  3. Inconsistent across languages — the shell snippet differs subtly between Python/Java/TS
  4. No validation — keys/values are raw strings in a shell command

Proposal

Add a setEnv method under the commands namespace:

python
await sandbox.commands.set_env("MY_TOKEN", "value")
java
sandbox.commands().setEnv("MY_TOKEN", "value");
typescript
await sandbox.commands.setEnv("MY_TOKEN", "value");

Internally the SDK would: • Resolve $EXECD_ENVS path • Properly escape key/value (handle quotes, backslashes, newlines, = in values) • Append KEY=VALUE\n to the file via commands.run

Source: opensandbox-group/OpenSandbox

View original on GitHubView discussion on GitHub