siyuan-note/siyuan · error

Conf.Language(14) (copy docx failed: %s)

Error message

Conf.Language(14) (copy docx failed: %s)

What it means

After Pandoc produces a temporary .docx, ExportDocx copies it to the user-chosen save path via filelock.Copy. If that copy fails (target unwritable, path invalid, disk full, file locked), the localized 'Export failed: %s' template is filled with the copy error and returned, clearing fullPath.

Source

Thrown at kernel/model/export.go:1169

			args = append(args, "--reference-doc", pandocRuntime.TemplatePath)
		}

		pandoc := exec.Command(pandocRuntime.BinPath, args...)
		gulu.CmdAttr(pandoc)
		pandoc.Stdin = bytes.NewBufferString(content)
		output, pandocErr := pandoc.CombinedOutput()
		if pandocErr != nil {
			argStr := strings.Join(args, " ")
			msg := gulu.DecodeCmdOutput(output)
			logging.LogErrorf("export docx [%s] failed: %s", argStr, msg)
			return fmt.Errorf(Conf.Language(14), msg)
		}

		fullPath = filepath.Join(savePath, name+".docx")
		fullPath = util.GetUniqueFilename(fullPath)
		if copyErr := filelock.Copy(tmpDocxPath, fullPath); copyErr != nil {
			logging.LogErrorf("export docx failed: %s", copyErr)
			return fmt.Errorf(Conf.Language(14), copyErr)
		}

		if tmpAssets := filepath.Join(tmpDir, "assets"); !removeAssets && gulu.File.IsDir(tmpAssets) {
			if copyErr := filelock.Copy(tmpAssets, filepath.Join(savePath, "assets")); copyErr != nil {
				logging.LogErrorf("export docx failed: %s", copyErr)
				return fmt.Errorf(Conf.Language(14), copyErr)
			}
		}
		return nil
	})
	if err != nil {
		fullPath = ""
	}
	return
}

func ExportMarkdownHTML(id, savePath string, docx, merge bool, mergeHeadingOptions ...MergeHeadingOptions) (name, dom string) {
	if err := prepareExportBlockAssets(id, merge); err != nil {

View on GitHub (pinned to 8641553a1f)

Solutions

  1. Close the destination .docx in any open application and retry the export.
  2. Verify the save directory exists and is writable; choose a different save path if needed.
  3. Check free disk space on the target volume.
  4. Check kernel logs for the exact copyErr to distinguish permission vs. lock vs. space issues.
Defensive patterns

Strategy: try-catch

Validate before calling

// preflight: destination must be writable and not locked
const target = savePath + "/" + name + ".docx";
if (await fileExists(target)) await ensureNotOpenInEditor(target);

Try / catch

try {
  await exportDocx({id, savePath});
} catch (e) {
  if (String(e.msg).includes('copy')) {
    suggestAlternateSavePath();
  }
}

Prevention

When it happens

Trigger: filelock.Copy(tmpDocxPath, fullPath) fails: savePath does not exist or is read-only, the target .docx is open/locked by another program (e.g. Word), or insufficient disk space.

Common situations: User exporting to a network drive that is offline; the destination .docx is currently open in Word causing a lock; exporting to a cloud-synced folder with sync locks; permission-denied on the target directory.

Understand the failure class

Background: "failed to write file", "Could not save figure", "Error saving remote file" — file write failed: causes and fixes across languages and libraries — this error's family across 38 libraries.

Related errors


AI-assisted analysis of siyuan-note/siyuan@8641553a1f (2026-09-11). Data as JSON: /api/errors/117aeeea78f1c356. Report an issue: GitHub.