{"record":{"id":"260113250f35a028","repo":"GoogleContainerTools/jib","slug":"unable-to-move-s-to-s-such-failures-are-often","errorCode":null,"errorMessage":"unable to move: %s to %s; such failures are often caused by interference from antivirus (https://github.com/GoogleContainerTools/jib/issues/3127#issuecomment-796838294), or rarely if the operation is not supported by the file system (for example: special non-local file system)","messagePattern":"unable to move: (.+?) to (.+?); such failures are often caused by interference from antivirus \\(https://github\\.com/GoogleContainerTools/jib/issues/3127#issuecomment-796838294\\), or rarely if the operation is not supported by the file system \\(for example: special non-local file system\\)","errorType":"exception","errorClass":"IOException","httpStatus":null,"severity":"error","filePath":"jib-core/src/main/java/com/google/cloud/tools/jib/cache/CacheStorageWriter.java","lineNumber":146,"sourceCode":"          () -> {\n            if (Files.exists(destination)) {\n              // If the file already exists, we skip renaming and use the existing file.\n              // This happens, e.g., if a new layer happens to have the same content as a\n              // previously-cached layer or the same layer is being cached concurrently.\n              return true;\n            }\n            Files.move(source, destination);\n            return Files.exists(destination);\n          };\n      // Some Windows users report java.nio.file.AccessDeniedException that we suspect is caused\n      // by anti-virus programs, like Windows Defender, that open new files for scanning.\n      // Retry the rename up to 10 times, with 15ms pause between each retry.\n      if (!Retry.action(rename)\n          .maximumRetries(10)\n          .retryOnException(ex -> ex instanceof FileSystemException)\n          .sleep(15, TimeUnit.MILLISECONDS)\n          .run()) {\n        throw new IOException(errorMessage);\n      }\n\n    } catch (IOException ex) {\n      throw new IOException(errorMessage, ex);\n    }\n  }\n\n  /**\n   * Decompresses the file to obtain the diff ID.\n   *\n   * @param compressedFile the file containing the compressed contents\n   * @return the digest of the decompressed file\n   * @throws IOException if an I/O exception occurs\n   */\n  private static DescriptorDigest getDiffIdByDecompressingFile(Path compressedFile)\n      throws IOException {\n    try (InputStream in =\n        new CompressorStreamFactory(true)","sourceCodeStart":128,"sourceCodeEnd":164,"githubUrl":"https://github.com/GoogleContainerTools/jib/blob/fb949e2676afbbd7dd7a1ef61e20251931325654/jib-core/src/main/java/com/google/cloud/tools/jib/cache/CacheStorageWriter.java#L128-L164","documentation":"CacheStorageWriter.moveIfDoesNotExist() renames a fully written temp file into its final cache location. After retrying the rename 10 times with 15ms pauses (on FileSystemException), a persistent failure throws IOException with a detailed message noting that antivirus interference or unsupported (non-local) file systems are the usual causes. This is the first throw site, after the retry loop exhausts.","triggerScenarios":"Files.move/ATOMIC_MOVE from source to destination keeps failing (e.g. FileAccessRetriedException / FileSystemException) through all 10 retries — typically while writeCompressed, writeUncompressed, writeTarLayer, or the layer blob writers move a temp layer file.","commonSituations":"Antivirus (Windows Defender etc.) locking freshly written files during scan, cache directory on NFS/SMB/network drives lacking atomic rename, another process holding the destination file open.","solutions":["Move the Jib cache to a local disk (set <cache>/jib.cacheDirectory to a local path)","Add the cache directory to antivirus exclusions","Close processes holding files in the cache and rebuild","Re-run the build — transient AV locks often disappear on retry"],"exampleFix":"// before (cache on network share)\n<configuration><cache>/mnt/nfs/jib-cache</cache></configuration>\n// after\n<configuration><cache>/home/user/.cache/google-cloud-tools-java/jib</cache></configuration>","handlingStrategy":"retry","validationCode":"// Cache must be on a local filesystem supporting atomic rename\nif (!Files.getFileStore(cacheDir).supportsFileAttributeView(\"basic\")) {\n  System.err.println(\"Jib cache should be on a local disk\");\n}","typeGuard":null,"tryCatchPattern":"try {\n  build();\n} catch (IOException e) {\n  if (e.getMessage().startsWith(\"unable to move\")) {\n    // antivirus or non-local FS; relocate cache and retry\n    setCacheDirectory(Path.of(System.getProperty(\"user.home\"), \".cache/jib\"));\n    build();\n  } else throw e;\n}","preventionTips":["Keep the Jib cache on a local disk, never NFS/SMB","Add the cache directory to antivirus exclusions","Avoid cleanup daemons touching the cache during builds"],"tags":["filesystem","io","antivirus"],"backgroundTag":"file-write-failed","analyzedSha":"fb949e2676afbbd7dd7a1ef61e20251931325654","analyzedAt":"2026-09-06T14:04:09.491Z","contentChangedAt":"2026-09-06T14:04:09.491Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}