Skip to content

fix: support tmpdir: false when the out dir is inside the project dir#1927

Open
claude[bot] wants to merge 1 commit into
mainfrom
fix/tmpdir-false-out-inside-project
Open

fix: support tmpdir: false when the out dir is inside the project dir#1927
claude[bot] wants to merge 1 commit into
mainfrom
fix/tmpdir-false-out-inside-project

Conversation

@claude

@claude claude Bot commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

Requested by Samuel Attard · Slack thread

  • I have read the contribution documentation for this project.
  • I agree to follow the code of conduct that this project follows, as appropriate.
  • The changes are appropriately documented (if applicable).
  • The changes have sufficient test coverage (if applicable).
  • The testsuite passes successfully on my local machine (if applicable).

Summarize your changes:

Before: packaging with tmpdir: false fails with ERR_FS_CP_EINVAL ("cannot copy ... to a subdirectory of self") whenever the out dir is inside the project dir — including the default ./out used by Electron Forge.

After: the same options package successfully, and the out dir is still excluded from the copied app.

How: with tmpdir: false the staging path is the final out path, so copyTemplate()'s single fs.cp(opts.dir, resources/app) has a destination inside its source. Node's cp rejects dest-inside-src up front, before the copy filter (which already ignores out dirs) ever runs. When the resolved destination is inside opts.dir, copyTemplate() now copies each top-level entry of opts.dir individually, applying the same userPathFilter to the top-level entries themselves — so ignored entries like the out dir are skipped. All other cases keep the existing single cp call.

Includes a regression test that packages with tmpdir: false and out inside dir, and asserts the out dir is not copied into resources/app.

Fixes #1679

Supersedes #1657 — this reimplements the per-entry copy approach from that PR (credit to @ianho, who is credited as commit co-author) on top of the current fs.promises.cp-based code.


Generated by Claude Code

@MarshallOfSound MarshallOfSound marked this pull request as ready for review July 3, 2026 19:21
@MarshallOfSound MarshallOfSound requested a review from a team as a code owner July 3, 2026 19:21
Node's fs.cp rejects copying a directory into a subdirectory of itself
before the copy filter runs, so packaging with tmpdir: false and an out
dir inside the project dir (e.g. Electron Forge's default ./out) failed
with ERR_FS_CP_EINVAL. When the staging path is inside the app dir, copy
each top-level entry individually instead, still applying the same
filter so ignored paths (including the out dir itself) are skipped.

Fixes #1679

Co-authored-by: ianho <anho.zhang@gmail.com>
@claude claude Bot force-pushed the fix/tmpdir-false-out-inside-project branch from 508a875 to fa6e95c Compare July 3, 2026 19:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

error when packageConfig.tmpdir set to false

2 participants