GoogleContainerTools/skaffold · error
unable to generate skaffold config file automatically - try
Error message
unable to generate skaffold config file automatically - try running `skaffold init`: %w
What it means
When skaffold.yaml is missing and auto-creation is enabled, Skaffold tries to generate one via initializer.Transparent. If that generator fails, this error tells the user to fall back to running `skaffold init` manually.
Source
Thrown at cmd/skaffold/app/cmd/runner.go:119
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) {
output.Default.Fprintf(out, "Skaffold config file %s not found - Trying to create one for you...\n", opts.ConfigurationFile)
config, err := initializer.Transparent(context.Background(), out, initConfig.Config{Opts: opts, EnableManifestGeneration: opts.AutoInit})
if err != nil {
return nil, fmt.Errorf("unable to generate skaffold config file automatically - try running `skaffold init`: %w", err)
}
if config == nil {
return nil, fmt.Errorf("unable to generate skaffold config file automatically - try running `skaffold init`: action cancelled by user")
}
defaults.Set(config)
return parser.SkaffoldConfigSet{
&parser.SkaffoldConfigEntry{SkaffoldConfig: config, IsRootConfig: true},
}, nil
}
return nil, fmt.Errorf("skaffold config file %s not found - check your current working directory, or try running `skaffold init`", opts.ConfigurationFile)
}
// If the error is NOT that the file doesn't exist, then we warn the user
// that maybe they are using an outdated version of Skaffold that's unable to read
// the configuration.View on GitHub (pinned to a1189de023)
Solutions
- Run `skaffold init` explicitly and answer its prompts to generate skaffold.yaml
- Ensure the repo has a detectable Dockerfile and Kubernetes manifests
- Use --force to let init generate a config in a directory it considers ambiguous
- Create a minimal skaffold.yaml by hand if auto-detection cannot classify the project
Example fix
// before: running skaffold run with no skaffold.yaml, auto-init fails // after skaffold init --force # then skaffold run
Defensive patterns
Strategy: fallback
Validate before calling
[ -f skaffold.yaml ] || { [ -f Dockerfile ] && echo 'detectable project'; } || echo 'run skaffold init manually - auto-generation will fail' Try / catch
config, err := initializer.Transparent(ctx, out, cfg)
if err != nil {
// fall back to explicit init instructions for the user
fmt.Fprintln(out, "auto-generation failed; run `skaffold init` interactively")
return err
} Prevention
- Commit a skaffold.yaml so auto-generation is never needed
- Ensure projects have a standard Dockerfile and k8s manifests the initializer can detect
- Prefer running `skaffold init` interactively once during project setup
- In CI, always ship the config instead of relying on --auto-init
When it happens
Trigger: Running `skaffold run`/`dev` in a directory without skaffold.yaml where CONFIG_FILE_NOT_FOUND is raised and auto config creation (--auto-create-config / --auto-init, or defaults) is on, but initializer.Transparent errors: unrecognized project layout, unparseable build files, or manifest detection failure.
Common situations: Project structure not recognizable (no Dockerfile, no k8s manifests); ambiguous multi-module repo; Dockerfile with unusual name/layout the initializer cannot map.
Related errors
- unable to generate skaffold config file automatically - try
- `apply` requires at least one manifest argument
- `exec` requires exactly one action to execute
- `config-dependencies add` requires exactly one file path arg
- `jobManifestPaths modify` requires exactly one manifest file
AI-assisted analysis of GoogleContainerTools/skaffold@a1189de023 (2026-09-05).
Data as JSON: /api/errors/c2f823120e890bc3.
Report an issue: GitHub.