GoogleContainerTools/skaffold · error

failed to initialize sync state for %q: %w

Error message

failed to initialize sync state for %q: %w

What it means

Skaffold failed to initialize the incremental sync state for a Jib artifact. When an artifact has `sync.auto` set and is a Jib build, `jib.InitSync` inspects the Jib build to compute which files can be synced; a failure there is wrapped with the artifact's image name. Without init sync, the dev loop cannot sync this artifact's changes.

Source

Thrown at pkg/skaffold/sync/sync.go:389

	}

	if numSynced == 0 {
		log.Entry(ctx).Warnf("sync failed for artifact %q", image)
		return errors.New("didn't sync any files")
	}
	return nil
}

func Init(ctx context.Context, artifacts []*latest.Artifact) error {
	for _, a := range artifacts {
		if a.Sync == nil {
			continue
		}

		if a.Sync.Auto != nil && a.JibArtifact != nil {
			err := jib.InitSync(ctx, a.Workspace, a.JibArtifact)
			if err != nil {
				return fmt.Errorf("failed to initialize sync state for %q: %w", a.ImageName, err)
			}
		}
	}
	return nil
}

View on GitHub (pinned to a1189de023)

Solutions

  1. Build the project once before dev (`./mvnw package` / `./gradlew assemble`) so jib artifacts exist
  2. Validate jib configuration in pom.xml/build.gradle and jib plugin version
  3. Read the wrapped cause for the specific jib failure and fix it in the build file
  4. If auto-sync of a Jib artifact is not required, remove `sync.auto` for that artifact

Example fix

// before: skaffold.yaml
sync:
  auto: true
// after: ensure jib built first, or use manual sync rules
sync:
  manual:
    - src: 'src/main/**'
      dest: /app
Defensive patterns

Strategy: validation

Validate before calling

// pre-validate jib artifact state before Init
if a.Sync.Auto != nil && a.JibArtifact != nil {
    if _, err := os.Stat(filepath.Join(a.Workspace, "target")); os.IsNotExist(err) {
        return fmt.Errorf("build jib artifact for %q before dev", a.ImageName)
    }
}

Try / catch

if err := jib.InitSync(ctx, a.Workspace, a.JibArtifact); err != nil {
    return fmt.Errorf("jib init for %s failed, run mvn package / gradlew assemble first: %w", a.ImageName, err)
}

Prevention

When it happens

Trigger: `Init` iterates artifacts where `a.Sync.Auto != nil && a.JibArtifact != nil` and calls `jib.InitSync(ctx, a.Workspace, a.JibArtifact)`; the Jib JAR inspection fails (e.g. malformed/unbuilt jar, jib config missing, unsupported jib version).

Common situations: Jib jar not built yet before `skaffold dev` starts; pom.xml/build.gradle jib configuration missing or malformed; multi-module Gradle workspace misconfigured; corrupted build output in the workspace.

Related errors


AI-assisted analysis of GoogleContainerTools/skaffold@a1189de023 (2026-09-05). Data as JSON: /api/errors/30d57fa152e66bf3. Report an issue: GitHub.