Skip to content

Fix symlink spec on Windows machines that can create symlinks - #2510

Open
Ayoubhm07 wants to merge 1 commit into
huggingface:mainfrom
Ayoubhm07:fix/hub-symlink-spec-windows
Open

Ayoubhm07 wants to merge 1 commit into
huggingface:mainfrom
Ayoubhm07:fix/hub-symlink-spec-windows

Conversation

@Ayoubhm07

@Ayoubhm07 Ayoubhm07 commented Sep 19, 2026 •

Copy link
Copy Markdown

createSymlink falls back to copying when fs.symlink throws, and the spec encoded that fallback as a platform rule. Windows does create symlinks with Developer Mode on, so on those machines createSymlink takes the symlink path and two assertions fail while nothing is broken. CI never caught it because the runners have no symlink privilege, which is also why the platform check looked right.

The node:fs/promises mock in this file already wraps symlink, so it now records whether the real call went through and the assertions follow that. Six lines, no probing, no new helper.

npx vitest run src/utils/symlink.spec.ts --root packages/hub

Before, on main (Windows 11, Developer Mode on):

 × should create a symlink
   → expected true to be false
 × should work when symlinking twice
   → expected true to be false
 ✓ should work when symlink doesn't work (windows)

 Tests  2 failed | 1 passed (3)

After:

 ✓ should create a symlink
 ✓ should work when symlinking twice
 ✓ should work when symlink doesn't work (windows)

 Tests  3 passed (3)

One thing this gives up: the old assertion demanded true unconditionally on Linux, so it would have failed if fs.symlink ever stopped working there. Keeping that guard would mean putting a process.platform branch back in, and the copy path is already covered by the third test.

Test file only. No source change, no dependency.

@Ayoubhm07
Ayoubhm07 force-pushed the fix/hub-symlink-spec-windows branch from 3d014d7 to 462dede Compare October 3, 2026 00:29
@Ayoubhm07 Ayoubhm07 changed the title Fix symlink spec on Windows machines that can create symlinks:: Fix symlink spec on Windows machines that can create symlinks Oct 3, 2026
The spec asserted that createSymlink never produces a symlink on win32, but Windows
creates them with Developer Mode or admin rights, so two tests failed on those machines
even though createSymlink worked.

The node:fs/promises mock in this file already wraps symlink, so it now records whether
the real call succeeded and the two assertions compare against that instead of guessing
from the platform.
@Ayoubhm07
Ayoubhm07 force-pushed the fix/hub-symlink-spec-windows branch from 462dede to 599b862 Compare October 3, 2026 00:34
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.

1 participant