gatsbyjs/gatsby · error

gatsby-transformer-sharp_20001

gatsby-transformer-sharp_20001

Error message

error copying file from ${details.absolutePath} to ${publicPath}

What it means

Thrown by gatsby-transformer-sharp during customize-schema when fs.copy (fs-extra) fails to copy a source image file to the public output directory. The error uses the MissingResource code (20001) and reports both the absolute source path and the public destination. It runs inside the copy callback, after an existsSync race-guard, so a genuine I/O or permission failure is the cause.

Source

Thrown at packages/gatsby-transformer-sharp/src/customize-schema.js:619

          process.cwd(),
          `public`,
          `static`,
          imageName
        )

        if (!fs.existsSync(publicPath) && !inProgressCopy.has(publicPath)) {
          // keep track of in progress copy, we should rely on `existsSync` but
          // a race condition exists between the exists check and the copy
          inProgressCopy.add(publicPath)
          fs.copy(
            details.absolutePath,
            publicPath,
            { dereference: true },
            err => {
              // this is no longer in progress
              inProgressCopy.delete(publicPath)
              if (err) {
                reporter.panic(
                  {
                    id: prefixId(CODES.MissingResource),
                    context: {
                      sourceMessage: `error copying file from ${details.absolutePath} to ${publicPath}`,
                    },
                  },
                  err
                )
              }
            }
          )
        }

        return {
          width: dimensions.width,
          height: dimensions.height,
          src: `${pathPrefix}/static/${imageName}`,
        }

View on GitHub (pinned to 8b06340921)

Solutions

  1. Confirm the source file at details.absolutePath still exists and is readable by the build process.
  2. Check write permissions and free space on the volume holding publicPath.
  3. Delete .cache and public, then rebuild to regenerate stale references.
  4. If using Docker/CI, ensure the workspace is bind-mounted read-write and not truncated by image size limits.
Defensive patterns

Strategy: validation

Validate before calling

// Before triggering sharp processing, ensure source files exist:
const fs = require('fs')
for (const node of nodes) {
  if (node.absolutePath && !fs.existsSync(node.absolutePath)) {
    reporter.warn(`Skipping image; missing on disk: ${node.absolutePath}`)
    continue
  }
  // ...createFile / sharp call
}

Prevention

When it happens

Trigger: fs.copy invokes its callback with a non-null err: source file was deleted between discovery and copy, permission denied reading the source or writing publicPath, disk full, path-too-long on Windows, or a cross-device move that copy cannot resolve.

Common situations: A source image referenced in a node was removed from disk between sourcing and image processing; read-only mounts in CI/Docker; .cache/public on a volume that is out of space; symlink loops with dereference:true; Windows path length limits.

Related errors


AI-assisted analysis of gatsbyjs/gatsby@8b06340921 (2026-08-13). Data as JSON: /api/errors/694910b4acbb01f1. Report an issue: GitHub.