yamadashy/repomix · error · RepomixError

--watch cannot be used with --copy. Watch mode re-packs on e

Error message

--watch cannot be used with --copy. Watch mode re-packs on every change, which would repeatedly overwrite the clipboard.

What it means

Watch mode re-packs on every file change; with `--copy` (copyToClipboard) each re-pack would overwrite the clipboard repeatedly. `runWatchAction` rejects this combination.

Source

Thrown at src/cli/actions/watchAction.ts:98

  // checked individually rather than via the shared validateConflictingOptions so the error
  // always names --watch instead of a (potentially confusing) pairwise conflict.
  if (config.output.splitOutput !== undefined) {
    // Split output would create numbered files that the watcher then picks up, looping.
    throw new RepomixError(
      '--watch cannot be used with split output. Watch mode does not yet support split output files.',
    );
  }
  // `output: "-"` resolves to stdout mode via filePath === '-', the same as --stdout.
  if (config.output.stdout || config.output.filePath === '-') {
    throw new RepomixError('--watch cannot be used with stdout output. Watch mode writes to a file.');
  }
  if (config.skillGenerate !== undefined) {
    throw new RepomixError(
      '--watch cannot be used with --skill-generate. Watch mode does not support skill generation.',
    );
  }
  if (config.output.copyToClipboard) {
    throw new RepomixError(
      '--watch cannot be used with --copy. Watch mode re-packs on every change, which would repeatedly overwrite the clipboard.',
    );
  }

  const targetPaths = directories.map((directory) => path.resolve(cwd, directory));

  // Run initial pack
  const packResult = await runPack(targetPaths, config, cliOptions);
  reportResults(cwd, packResult, config, cliOptions);
  logger.log(pc.dim(`\nWatching ${packResult.safeFilePaths.length} files for changes... (Ctrl+C to stop)\n`));

  // Watch target directories instead of individual files so new files are detected.
  // The ignore predicate mirrors the packer so chokidar stays out of node_modules/.git
  // and gitignored trees (prevents EMFILE on large projects) and avoids wasted rebuilds.
  const buildIgnoreFilter = resolvedDeps.buildIgnoreFilter ?? buildWatchIgnoreFilter;
  const watchIgnoreFilter = await buildIgnoreFilter(targetPaths, config);
  const watcher = resolvedDeps.watch(targetPaths, {
    ignoreInitial: true,

View on GitHub (pinned to f465ad9093)

Solutions

  1. Drop `--copy` when using `--watch`
  2. Set `output.copyToClipboard: false` in repomix.config.json for watch runs
  3. Run a one-shot `repomix --copy` when you actually want the clipboard content

Example fix

// before
repomix --watch --copy
// after
repomix --watch
# when needed: repomix --copy
Defensive patterns

Strategy: validation

Validate before calling

if (watch && (argv.includes('--copy') || cfg.output?.copyToClipboard === true)) {
  throw new Error('Disable clipboard copy when using --watch');
}

Type guard

null

Try / catch

try {
  await runRepomix({ watch: true });
} catch (e) {
  if (e instanceof RepomixError && e.message.includes('--watch cannot be used with --copy')) {
    console.error('Remove --copy (and copyToClipboard from config) for watch mode.');
  }
  throw e;
}

Prevention

When it happens

Trigger: Running `repomix --watch --copy`, or `--watch` with `output.copyToClipboard: true` in the config file.

Common situations: A user whose config enables `copyToClipboard: true` by default adds `--watch` and hits the conflict even without passing `--copy` explicitly.

Related errors


AI-assisted analysis of yamadashy/repomix@f465ad9093 (2026-08-29). Data as JSON: /api/errors/49f9cf476b0598f5. Report an issue: GitHub.