8000 application: add --env for spawn environments by tubibibo · Pull Request #213 · frida/frida-tools · GitHub
[go: up one dir, main page]

Skip to content

application: add --env for spawn environments - #213

Merged
oleavr merged 1 commit into
frida:mainfrom
tubibibo:feat/spawn-env
Nov 6, 2026
Merged

oleavr merged 1 commit into
frida:mainfrom
tubibibo:feat/spawn-env

Conversation

@tubibibo
@tubibibo tubibibo commented Nov 6, 2026
Copy link
Copy Markdown
Contributor

Spawning has no way to set environment variables from the CLI today: --aux forwards its options to Device.spawn(), but only as string, bool or int, while env / envp take a mapping. So the workaround in #193 — setting DISABLE_TWAKS=1 so ellekit does not crash the spawned iOS app — cannot be expressed.

This adds a repeatable --env KEY=VALUE that feeds the binding's env parameter, which merges into the environment the spawn would otherwise inherit (unlike envp, which replaces it). Values may contain =: --env OTHER=a=b yields OTHER=a=b. Malformed entries are rejected by the argument parser.

$ frida -f com.example.app --env DISABLE_TWAKS=1

It lives in ConsoleApplication, so every tool that can spawn (frida, frida-trace, …) gets it, and the re-spawn path used when an app restarts goes through the same code, so the environment is applied again.

Tests — seven cases in tests/test_arguments.py:

  • parsing: no --env, a single variable, multiple variables with an embedded = in one value, and a malformed entry
  • wiring: driving the real file spawn path with a fake device and asserting what Device.spawn() receives — env is passed when requested, absent when not, and merged alongside --aux options

Also verified end-to-end on Windows with frida 17.24.1: spawning cmd /c set through the CLI with --env FRIDA_E2E=fromcli shows the variable in the child's environment while the inherited PATH is still there; without the flag the variable is absent. completions/frida.fish updated.

Fixes #193

@tubibibo
tubibibo 8000 force-pushed the feat/spawn-env branch from 84fa7c4 to e32f731 Compare November 6, 2026 06:46
--aux can only pass string, bool and int values to Device.spawn(), while
the env/envp options take a mapping, so there was no way to set an
environment variable when spawning, e.g. DISABLE_TWAKS=1 to work around
ellekit crashes on iOS.

Add a repeatable --env KEY=VALUE that feeds the env parameter, which
merges into the environment the spawn would otherwise inherit.

Fixes frida#193
@oleavr
oleavr merged commit a67ebfd into frida:main Nov 6, 2026
@oleavr
oleavr commented Nov 6, 2026
Copy link
Copy Markdown
Member

Thanks! 🙌

This branch was successfully deployed

2 active deployments
pypi — a67ebfd7 Deployed Nov 6, 2026 by oleavr via Publish to PyPI #13
testpypi — a67ebfd7 Deployed Nov 6, 2026 by oleavr via Publish to TestPyPI #13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Set iOS spawn environments with --aux

2 participants

0