ray run
Inject secrets directly into a command environment without writing files
Inject secrets directly into a command environment without writing files
Synopsis
ray run [options] [-- <command...>]Positional Arguments
| Argument | Required | Description |
|---|---|---|
[args...] | Optional | The command and arguments to execute with injected secrets in process memory (passed after '--'). |
Flags & Options
| Flag / Option | Type | Description |
|---|---|---|
-e, --env <name>(--environment <name>) | string | Target environment name (e.g. development, staging, production) to read or modify |
-c, --command <string> | string | Execute a shell command string with injected secrets instead of trailing arguments |
-s, --scope <path> | string | Subdirectory path or workspace scope to target instead of auto-detecting from the working directory (e.g. apps/web or packages/backend) |
--no-inherit | boolean | Prevent child process from inheriting host workstation shell variables; inject vault secrets into a clean environment |
-k, --keep-env(--no-override) | boolean | Preserve existing workstation environment variables when a key collides with an injected vault secret |
-b, --base(-t, --team) | boolean | Fetch canonical team environment secrets, ignoring personal workstation overrides (recommended for CI/CD) |
--only <keys> | string | Restrict injection to a comma-separated list of secret keys (e.g. API_KEY,DATABASE_URL) |
--exclude <keys> | string | Exclude specific comma-separated secret keys from being injected into the child process |
--no-mask | boolean | Disable automated masking of secret values in terminal logs and child process standard output |
--mount <path> | string | Write secrets temporarily to an ephemeral in-memory or filesystem file path during process execution |
-p, --project <id_or_name> | string | Target project ID or slug to link or query, bypassing interactive selection |
--name-transformer <type> | string | Transform injected secret key casing or formatting conventions (e.g. tf-var, camelCase, dotnet) |
-q, --quiet | boolean | Silence banners, progress spinners, and status output; only print process output and critical errors |
--verbose | boolean | Enable debug logging showing environment resolution, injected key names, and execution metadata |
--offline | boolean | Run using encrypted local disk cache without connecting to the remote Ray Secrets API server |
--strict(--exit-code) | boolean | Abort execution immediately with an exit code if any required secret is missing, empty, or drifting |
-y, --yes(--force) | boolean | Automatically answer yes to all confirmation prompts (ideal for automated CI/CD scripts) |
--overwrite | boolean | Force overwrite of existing secrets or local files without interactive confirmation prompts |
--include-children | boolean | Include nested secret folder keys using double-underscore delimiter (e.g. DATABASE__URL) |
--ci | boolean | Optimize execution for headless CI/CD runners (disables spinners, prompts, colors, and update checks) |
Common Examples
1. Inject secrets into local dev server
Injects all decrypted credentials into the spawned child process memory without creating plaintext files on disk.
ray run -- npm run dev2. Target a specific environment
Explicitly targets the staging vault environment instead of the local workspace default.
ray run --env staging -- npm run dev3. Execute a shell command string with secret interpolation
Passes an inline shell string using -c to safely evaluate commands referencing injected variables.
ray run -- sh -c 'echo Current database: $DATABASE_HOST'4. Mount temporary .env file for legacy filesystem tools
Temporarily mounts secrets to an ephemeral .env file, removing it automatically as soon as the child process exits.
ray run --mount .env -- npm run build:legacy5. Run in clean environment without workstation shell variables
Prevents host workstation environment variables from leaking into the child process runtime.
ray run --no-inherit -- npm run dev6. Headless CI execution with strict fail-fast validation
Optimized for automated CI runners: disables interactive spinners and exits with code 1 if any secret is missing.
ray run --base --strict --ci -- npm testExit Codes
| Code | Meaning | Recommended Action |
|---|---|---|
| 0 | Success. The command completed with no errors. | None required. |
| 1 | Runtime or execution failure. A child process returned non-zero status or a general error occurred. | Inspect process output or run with --verbose. |
| 2 | Authentication failed. Token is missing, expired, or invalid. | Run `ray login` or update `RAY_TOKEN`. |
| 3 | Configuration or binding error. Project or environment context was not found. | Run `ray init` or specify `--project` and `--env`. |
| 4 | Network or API failure. Failed to reach the Ray Secrets vault. | Check internet connection or run `ray doctor`. |
Ready to eliminate plaintext secrets?
Create a workspace to organize environments, invite your team, and generate scoped Service Tokens for CI/CD.