{"record":{"id":"7d2aebfbef74de5b","repo":"yamadashy/repomix","slug":"wl-copy-failed-msg-falling-back","errorCode":null,"errorMessage":"wl-copy failed (${msg}); falling back.","messagePattern":"wl-copy failed \\((.+?)\\); falling back\\.","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"src/core/packager/copyToClipboardIfEnabled.ts","lineNumber":28,"sourceCode":"  config: RepomixConfigMerged,\n): Promise<void> => {\n  if (!config.output.copyToClipboard) return;\n  progressCallback('Copying to clipboard...');\n\n  if (process.env.NODE_ENV !== 'test' && process.env.WAYLAND_DISPLAY) {\n    logger.trace('Wayland detected; attempting wl-copy.');\n    try {\n      await new Promise<void>((resolve, reject) => {\n        const proc = spawn('wl-copy', [], { stdio: ['pipe', 'ignore', 'ignore'] });\n        proc.on('error', (err) => reject(new Error(`Failed to execute wl-copy: ${err.message}`)));\n        proc.on('close', (code) => (code ? reject(new Error(`wl-copy exited with code ${code}`)) : resolve()));\n        proc.stdin.end(output);\n      });\n      logger.trace('Copied using wl-copy.');\n      return;\n    } catch (err: unknown) {\n      const msg = err instanceof Error ? err.message : 'unknown error';\n      logger.warn(`wl-copy failed (${msg}); falling back.`);\n    }\n  }\n\n  try {\n    logger.trace('Using tinyclip.');\n    await clipboard.writeText(output);\n    logger.trace('Copied using tinyclip.');\n  } catch (err: unknown) {\n    const msg = err instanceof Error ? err.message : 'unknown error';\n    logger.error(`tinyclip failed: ${msg}`);\n  }\n};\n","sourceCodeStart":10,"sourceCodeEnd":41,"githubUrl":"https://github.com/yamadashy/repomix/blob/f465ad909315a22120636baf03fa5e28701a50cb/src/core/packager/copyToClipboardIfEnabled.ts#L10-L41","documentation":"copyToClipboardIfEnabled tries wl-copy (Wayland clipboard) first and logs this warning if spawning/piping to it fails, then falls back to the tinyclipboard library. The copy still succeeds through the fallback; this is a diagnostic only.","triggerScenarios":"Spawning wl-copy rejects: wl-clipboard not installed, running under X11 with no Wayland compositor/socket (WAYLAND_DISPLAY unset), wl-copy exiting nonzero, or stdin.write/EPIPE errors.","commonSituations":"Users on X11 or macOS sessions where wl-copy is missing or useless; minimal containers/CI without a clipboard; wl-clipboard version changes breaking the CLI args.","solutions":["Nothing to fix if the fallback works — confirm the output was copied and ignore the warning.","Install wl-clipboard (e.g. `sudo apt install wl-clipboard`) when on Wayland to use the native path.","On X11, expect the fallback; optionally unset/inhibit the wl-copy attempt by running in a proper session or configuring the environment.","Check WAYLAND_DISPLAY / XDG_SESSION_TYPE to confirm which clipboard protocol your session supports."],"exampleFix":"// before: X11 session, wl-copy missing\n$ repomix --copy\n// after: install Wayland tooling (Wayland sessions only)\n$ sudo apt install wl-clipboard && $ repomix --copy","handlingStrategy":"fallback","validationCode":"const has = (cmd) => require('child_process').spawnSync(cmd, ['-v'], { stdio: 'ignore' }).status === 0 || require('child_process').spawnSync('which', [cmd]).status === 0;\nif (!has('wl-copy')) console.warn('wl-copy unavailable; clipboard lib will be used');","typeGuard":"const isWayland = () => !!process.env.WAYLAND_DISPLAY;","tryCatchPattern":"try { await copyToClipboardIfEnabled(output, config); } catch (e) { logger.warn(`clipboard copy failed: ${e.message}`); }","preventionTips":["Install wl-clipboard on Wayland sessions; rely on the built-in fallback elsewhere.","Verify WAYLAND_DISPLAY/XDG_SESSION_TYPE match the installed clipboard tooling.","Treat the warning as informational when --copy output lands successfully."],"tags":["clipboard","wayland","fallback","process-spawn"],"backgroundTag":"clipboard-command-failed","analyzedSha":"f465ad909315a22120636baf03fa5e28701a50cb","analyzedAt":"2026-08-29T01:27:42.024Z","schemaVersion":2},"datasetVersion":"2026-08-29T02:17:18.158Z"}