GoogleContainerTools/skaffold · error
getting run context: %w
Error message
getting run context: %w
What it means
Fires in runContext when runcontext.GetRunContext fails while assembling the run context (pipelines, options, and configs) for a skaffold command. Wraps the run-context construction error, which is usually caused by inconsistent configuration (e.g. conflicting pipeline settings) after config parsing and validation succeeded.
Source
Thrown at cmd/skaffold/app/cmd/runner.go:97
func runContext(ctx context.Context, out io.Writer, opts config.SkaffoldOptions) (*runcontext.RunContext, []util.VersionedConfig, error) {
cfgSet, err := withFallbackConfig(ctx, out, opts, parser.GetConfigSet)
if err != nil {
return nil, nil, err
}
setDefaultRendererAndDeployer(cfgSet)
if err := validation.Process(cfgSet, validation.GetValidationOpts(opts)); err != nil {
return nil, nil, fmt.Errorf("invalid skaffold config: %w", err)
}
var configs []util.VersionedConfig
for _, cfg := range cfgSet {
configs = append(configs, cfg.SkaffoldConfig)
}
runCtx, err := runcontext.GetRunContext(ctx, opts, configs)
if err != nil {
return nil, nil, fmt.Errorf("getting run context: %w", err)
}
if err := validation.ProcessWithRunContext(ctx, runCtx); err != nil {
return nil, nil, fmt.Errorf("invalid skaffold config: %w", err)
}
return runCtx, configs, nil
}
// withFallbackConfig will try to automatically generate a config if root `skaffold.yaml` file does not exist.
func withFallbackConfig(ctx context.Context, out io.Writer, opts config.SkaffoldOptions, getCfgs func(context.Context, config.SkaffoldOptions) (parser.SkaffoldConfigSet, error)) (parser.SkaffoldConfigSet, error) {
configs, err := getCfgs(ctx, opts)
if err == nil {
return configs, nil
}
var e sErrors.Error
if errors.As(err, &e) && e.StatusCode() == proto.StatusCode_CONFIG_FILE_NOT_FOUND_ERR {
if (opts.AutoCreateConfig || opts.AutoInit) && initializer.ValidCmd(opts) {View on GitHub (pinned to a1189de023)
Solutions
- Read the wrapped cause after 'getting run context:' for the specific resolution failure
- Verify profile names with `skaffold inspect profiles`
- Confirm --kube-context matches an entry in kubectl config get-contexts
- Remove conflicting flags (e.g. mutually exclusive run/apply options)
Example fix
// before skaffold run -p prod // profile 'prod' not defined // after skaffold run -p production # matches profile in skaffold.yaml
Defensive patterns
Strategy: validation
Validate before calling
CONTEXT=$(kubectl config current-context) skaffold inspect profiles -f skaffold.yaml | grep -q "$PROFILE" || echo "profile $PROFILE not defined" kubectl config get-contexts | grep -q "$CONTEXT" || echo "kubecontext $CONTEXT missing"
Try / catch
runCtx, configs, err := runContext(ctx, out, opts)
if err != nil {
var runCtxErr = "getting run context"
if strings.Contains(err.Error(), runCtxErr) {
return fmt.Errorf("check -p/--kube-context flags: %w", err)
}
return err
} Prevention
- Confirm profile names with `skaffold inspect profiles` before using -p
- Verify kube-context names exist in kubeconfig before passing --kube-context
- Avoid combining flags unsupported for the command mode (run vs apply vs render)
- Document required profiles in CI pipelines to prevent flag typos
When it happens
Trigger: Any command creating a runner when runcontext.GetRunContext fails: invalid --profile name, incompatible command mode (e.g. using a deployer unsupported for `skaffold run`), bad kubecontext flags, or mismatched config for the requested pipeline mode.
Common situations: Passing -p with a profile name that does not exist; --kube-context pointing to a context not in kubeconfig; configs where the resolved deployer does not support the requested command (e.g. apply vs run).
Related errors
- finding auto-activated profiles: %w
- couldn't find profile %s
- applying profile %q: %w
- value must be one of `always`, `missing`, or `never`
- CONFIG_REMOTE_REPO_CACHE_NOT_FOUND_ERR
AI-assisted analysis of GoogleContainerTools/skaffold@a1189de023 (2026-09-05).
Data as JSON: /api/errors/ccbaf42f83bdc142.
Report an issue: GitHub.