GoogleContainerTools/skaffold · error

opening %q in embedded filesystem: %w

Error message

opening %q in embedded filesystem: %w

What it means

Wraps a failure from fs.AssetsFS.Open when `skaffold credits export` tries to read a file out of the embedded (go:embed) assets filesystem and copy it to the export directory. The underlying err is usually fs.ErrNotExist, meaning the embedded asset path was missing, or a permission/IO error from the embed FS. Because assets are compiled into the binary this almost always indicates a bad path in the credits WalkDir iteration or a corrupted/unofficial binary build.

Source

Thrown at cmd/skaffold/app/cmd/credits/export.go:47

	"github.com/GoogleContainerTools/skaffold/v2/fs"
)

var Path string

// Export writes all the licenses and credit files to the `Path` folder.
func Export(ctx context.Context, out io.Writer) error {
	if err := iofs.WalkDir(fs.AssetsFS, "assets/credits_generated", func(filePath string, dirEntry iofs.DirEntry, err error) error {
		newPath := path.Join(Path, strings.Replace(filePath, "assets/credits_generated", "", 1))
		if dirEntry.IsDir() {
			err := os.Mkdir(newPath, 0755)
			if err != nil && !os.IsExist(err) {
				return fmt.Errorf("creating directory %q: %w", newPath, err)
			}
		} else {
			file, err := fs.AssetsFS.Open(filePath)
			if err != nil {
				return fmt.Errorf("opening %q in embedded filesystem: %w", filePath, err)
			}

			buf, err := io.ReadAll(file)
			if err != nil {
				return fmt.Errorf("reading %q in embedded filesystem: %w", filePath, err)
			}

			if err := os.WriteFile(newPath, buf, 0664); err != nil {
				return fmt.Errorf("writing %q to %q: %w", filePath, newPath, err)
			}
		}
		return nil
	}); err != nil {
		return err
	}

	s, err := filepath.Abs(Path)
	if err != nil {

View on GitHub (pinned to a1189de023)

Solutions

  1. Rebuild or reinstall skaffold from official sources so all go:embed assets are present
  2. Check that the file path printed in the error exists in pkg/skaffold/fs assets and the embed pattern includes it
  3. Run `skaffold version` to confirm it is an official release build

Example fix

// before: path constructed manually may not match embedded layout
filePath := filepath.Join(root, name)
// after: use the path as yielded by fs.WalkDir on AssetsFS so it matches the embed tree
return fs.WalkDir(fs.AssetsFS, ".", func(p string, d fs.DirEntry, err error) error {
    if err != nil { return err }
    if !d.IsDir() { return exportFile(p) }
    return nil
})
Defensive patterns

Strategy: validation

Validate before calling

// before export, verify the binary's assets are intact and target is writable
if _, err := os.Stat(exportDir); err != nil {
    return fmt.Errorf("export dir %s unavailable: %w", exportDir, err)
}
if err := skaffoldFS.WalkDir(fs.AssetsFS, ".", func(p string, d fs.DirEntry, err error) error {
    if err != nil { return fmt.Errorf("asset %s missing: %w", p, err) }
    return nil
}); err != nil { return err }

Type guard

func assetExists(fsys fs.FS, path string) bool {
    f, err := fsys.Open(path)
    if err != nil { return false }
    f.Close()
    return true
}

Try / catch

if _, err := fs.AssetsFS.Open(p); err != nil {
    if errors.Is(err, fs.ErrNotExist) { /* skip or rebuild binary */ }
    return err
}

Prevention

When it happens

Trigger: Running `skaffold credits export <dir>` when the embedded asset path listed in fs.AssetsFS cannot be opened — e.g. fs.WalkDir yields a path that no longer exists in the embed mapping, or the binary was built without the embedded assets.

Common situations: Using a locally built skaffold binary where embed directives were stripped or files moved; an outdated third-party mirror of skaffold; a directory entry in AssetsFS being skipped/dropped during a custom build.

Related errors


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