Skip to content

fix(builder): --work set to the checkout's own work folder no longer stops with SameFileError - #2285

Merged
hckrman101 merged 1 commit into
NotRexed:mainfrom
mooki000:fix/make-game-samefile
Nov 11, 2026
Merged

hckrman101 merged 1 commit into
NotRexed:mainfrom
mooki000:fix/make-game-samefile

Conversation

@mooki000

@mooki000 mooki000 commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

A build from a clone stops within seconds when --work is the clone's own work/ folder, where the development guide
puts everything made from the dump and CONTRIBUTING.md has developers put the play profile:
shutil.SameFileError: '<clone>/work/image/chunks.txt' and '<clone>/work/image/chunks.txt' are the same file.

Fixes #2331.

What changed

  • nx2/make_game.py copy_writable: when the destination already exists and is the source itself
    (os.path.samefile: the same path, or a hard or symbolic link to it), nothing is copied. Before every lift make_game
    copies work/image/chunks.txt from the checkout into the build's work folder with this function, and with --work
    the checkout's own work/ both are one file. The four profile files copied just before it were already safe: they are
    copied only when they differ (filecmp.cmp).
  • tests/test_copy_writable.py: also copies a file onto itself and onto a hard link of itself, and checks its bytes
    stay.

An earlier pull request, #1577, carried a guard for the same copy (comparing the two paths) beside an unrelated switch;
its author closed it the same day to finish testing. This one is the guard alone, with a test.

How it was tested

Linux (Arch, Python 3.12.16 and 3.14), no GPU involved:

  • The test fails on main with shutil.SameFileError and passes with the change.
  • make_game.py --romfs ... --exefs ... --work <clone>/work, the clone's work/ holding the v2.1.0 play profile (hot
    list, link order, PGO profile, image/chunks.txt), on a real dump, stopped at the lift's start (the lift's command
    replaced by a stop, so nothing was translated or compiled): main stops at work/image/chunks.txt with
    SameFileError after reading the game files; with the change it reaches @@stage lift in 4 s, and chunks.txt is
    unchanged (same SHA-256 before and after).
  • python -I -B tests/run_all.py on main 49f75dc with this change (2026-11-11, load 6 to over 100): 360 passed, 4 failed,
    10 skipped; tests/test_copy_writable.py passes. Three of the failures are this machine's and fail on main as well:
    tests/test_make_game_cache.py (it fails wherever work/ holds the play profile), tests/test_wayland_libdecor_hint.py
    (Clang 23) and tests/test_updater_asset_digest.py (only a .NET 10 SDK here); each has a pull request of its own. The
    fourth, nx2/test_depth_sample_types.py, lost its compiler to a SIGKILL while the load was over 100; run alone
    afterwards it passes (13 s).

Not tested

Assisted-by: Claude Opus 5.5
Co-Authored-By: Claude Opus 5.5 noreply@anthropic.com

…stops with SameFileError

make_game copies the play profile's work/image/chunks.txt from the checkout into the build's work folder before every
lift. With --work the checkout's own work folder, the place the development guide sends everything made from the dump,
source and destination are the same file, and shutil.copyfile stopped the build at once with SameFileError. The four
files copied just before it were already safe (they are copied only when they differ).

copy_writable now leaves a file alone when the destination is the source itself (os.path.samefile: the same path, a
hard link or a symbolic link to it). tests/test_copy_writable.py copies a file onto itself and onto a hard link of it.

Assisted-by: Claude Opus 5.5
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@mooki000

Copy link
Copy Markdown
Contributor Author

Rebased onto main b29967bf so the workflows run here: they had waited for an approval on the old head, and main's game-free tests are green again since #2380. The patch is unchanged (git range-diff: the commit is equal), and its test passes on the new base.

@mooki000
mooki000 force-pushed the fix/make-game-samefile branch from adabf1a to 3d4ce7e Compare November 11, 2026 17:08

@Joey-Magnus Joey-Magnus left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. copy_writable is only reached for work/image/chunks.txt (nx2/make_game.py:1698), the four profile files (:1694, already skipped by filecmp.cmp when they're the same file) and the window icon (:1887, a different folder). So returning early when os.path.samefile(src, dst) (:1170-1171) is the whole fix for #2331. Comparing by file identity rather than by path, as #1577 did, also covers a symlinked or hard-linked work/ and differences in case on Windows. The early return happens before the chmod, so a read-only profile file the user owns doesn't have its mode changed either.

The extended tests/test_copy_writable.py fails on main with SameFileError and checks that the bytes survive. os.link there works on the Windows runners' NTFS temp folder, and the Windows shard that runs this test passed.

On the red checks: neither comes from this PR. Python source checks (windows-2022, part 1/2) failed only in tests/test_native_astc_texture_count.py (the fixture's scanf deprecation warning under -Werror), which #2397 has since fixed on main. appimage stopped in its System packages step on network timeouts. A rerun, or a rebase onto current main, should turn both green.

@hckrman101
hckrman101 merged commit d6dc45b into NotRexed:main Nov 11, 2026
11 of 13 checks passed
@mooki000

Copy link
Copy Markdown
Contributor Author

Thanks for checking the file-identity cases and the Windows result. This is now merged as d6dc45bf.

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.

make_game.py stops with SameFileError when --work is the clone's own work folder

3 participants