Skip to content

Fix Windows 8.3 short path and symlink handling in file_packager.py - #28192

Merged
dschuff merged 2 commits into
emscripten-core:mainfrom
dschuff:packager
Nov 6, 2026
Merged

dschuff merged 2 commits into
emscripten-core:mainfrom
dschuff:packager

Conversation

@dschuff

@dschuff dschuff commented Nov 6, 2026

Copy link
Copy Markdown
Member

Use os.path.realpath(os.getcwd()) instead of os.path.abspath(os.getcwd()) when computing curr_abspath so it matches other abspath checks below.

On Windows, os.getcwd() preserves directory junctions and 8.3 short path names (such as C:\Users\RUNNER~1\AppData\Local\Temp for user runneradmin), whereas os.path.realpath() expands them via GetFinalPathNameByHandleW. That mismatch caused abspath.startswith(curr_abspath) to reject valid --embed-file and --preload-file inputs inside the current working directory.

Use os.path.realpath(os.getcwd()) instead of os.path.abspath(os.getcwd()) when computing curr_abspath so it matches other abspath checks below.

On Windows, os.getcwd() preserves directory junctions and 8.3 short path names (such as C:\Users\RUNNER~1\AppData\Local\Temp for user runneradmin), whereas os.path.realpath() expands them via GetFinalPathNameByHandleW. That mismatch caused abspath.startswith(curr_abspath) to reject valid --embed-file and --preload-file inputs inside the current working directory.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Code Review

This pull request updates tools/file_packager.py to use os.path.realpath(os.getcwd()) instead of os.path.abspath(os.getcwd()) to ensure directory junctions, symlinks, and 8.3 short names are properly resolved on Windows. There are no review comments, so we have no feedback to provide.

@dschuff
dschuff requested a review from sbc100 November 6, 2026 18:38

@sbc100 sbc100 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Anywhere else in the codebase we need to do this too?

Comment thread tools/file_packager.py Resolved
@dschuff

dschuff commented Nov 6, 2026

Copy link
Copy Markdown
Member Author

Anywhere else in the codebase we need to do this too?

Along with #28195 all the tests pass on the GHA runner where %TEMP% has the 8.3 shortname. (It's possible that there could be even more issues with running the compiler from such a directory, but it also seems likely that some of our users are running emcc from such a directory already). This issue is probably pretty obscure as well, since the file package is not frequently used.

@dschuff
dschuff enabled auto-merge (squash) November 6, 2026 19:17
@dschuff
dschuff merged commit 27f7458 into emscripten-core:main Nov 6, 2026
43 checks passed
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.

2 participants