Skip to Content
RcmadeDocs
Ray SecretsReferenceCLI ReferenceSecrets

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

ArgumentRequiredDescription
[args...]OptionalThe command and arguments to execute with injected secrets in process memory (passed after '--').

Flags & Options

Flag / OptionTypeDescription
-e, --env <name>(--environment <name>)stringTarget environment name (e.g. development, staging, production) to read or modify
-c, --command <string>stringExecute a shell command string with injected secrets instead of trailing arguments
-s, --scope <path>stringSubdirectory path or workspace scope to target instead of auto-detecting from the working directory (e.g. apps/web or packages/backend)
--no-inheritbooleanPrevent child process from inheriting host workstation shell variables; inject vault secrets into a clean environment
-k, --keep-env(--no-override)booleanPreserve existing workstation environment variables when a key collides with an injected vault secret
-b, --base(-t, --team)booleanFetch canonical team environment secrets, ignoring personal workstation overrides (recommended for CI/CD)
--only <keys>stringRestrict injection to a comma-separated list of secret keys (e.g. API_KEY,DATABASE_URL)
--exclude <keys>stringExclude specific comma-separated secret keys from being injected into the child process
--no-maskbooleanDisable automated masking of secret values in terminal logs and child process standard output
--mount <path>stringWrite secrets temporarily to an ephemeral in-memory or filesystem file path during process execution
-p, --project <id_or_name>stringTarget project ID or slug to link or query, bypassing interactive selection
--name-transformer <type>stringTransform injected secret key casing or formatting conventions (e.g. tf-var, camelCase, dotnet)
-q, --quietbooleanSilence banners, progress spinners, and status output; only print process output and critical errors
--verbosebooleanEnable debug logging showing environment resolution, injected key names, and execution metadata
--offlinebooleanRun using encrypted local disk cache without connecting to the remote Ray Secrets API server
--strict(--exit-code)booleanAbort execution immediately with an exit code if any required secret is missing, empty, or drifting
-y, --yes(--force)booleanAutomatically answer yes to all confirmation prompts (ideal for automated CI/CD scripts)
--overwritebooleanForce overwrite of existing secrets or local files without interactive confirmation prompts
--include-childrenbooleanInclude nested secret folder keys using double-underscore delimiter (e.g. DATABASE__URL)
--cibooleanOptimize 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 dev

2. Target a specific environment

Explicitly targets the staging vault environment instead of the local workspace default.

ray run --env staging -- npm run dev

3. 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:legacy

5. 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 dev

6. 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 test

Exit Codes

CodeMeaningRecommended Action
0Success. The command completed with no errors.None required.
1Runtime or execution failure. A child process returned non-zero status or a general error occurred.Inspect process output or run with --verbose.
2Authentication failed. Token is missing, expired, or invalid.Run `ray login` or update `RAY_TOKEN`.
3Configuration or binding error. Project or environment context was not found.Run `ray init` or specify `--project` and `--env`.
4Network 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.