Skip to content

[BUG] Package content hash differs on Windows for packages with in-repo symlinks, so --frozen fails #3457

Description

Describe the bug

A package that contains in-repo symbolic links gets a different content hash on Windows from the one recorded on Linux or macOS, so apm install --frozen fails on Windows with a lockfile generated elsewhere. Enabling symlinks for Git on Windows (Developer Mode plus core.symlinks=true in the user's global config) doesn't help.

microsoft/aspire-skills@v0.0.4 (commit 851c8c1f6d059462853da6d9434e3e1375c9e23d) shows it: it has 74 mode-120000 entries (70 under .github/plugins/, plus four skills/*/evals/fixtures directory links).

  • On Linux, the cache checkout has real links, and copying the tree into apm_modules without preserving symlinks turns each one into a real copy of its target. The recorded hash is sha256:9328e637230ce4c0f615e619254a3545dcaa8d36f446551fd436f0e4a4c90d8a.
  • On Windows, the cache checkout's own .git/config holds symlinks = false, so Git writes each link as a small text file holding the target path (for example .github/plugins/aspire-skills/.claude-plugin/plugin.json contains ../../../../.claude-plugin/plugin.json). The hash is sha256:5ef3cc66f64719c5ddad3e67f1bfd1bccd9760020e416a8797ed9d8a486e1ed3.

The cause appears to be that APM's Git environment hides the user's global and system config (GIT_CONFIG_GLOBAL/GIT_CONFIG_SYSTEM set to the null device). With no visible core.symlinks, Git for Windows writes symlinks = false into every repository it creates. Reproduced outside APM:

rem Global config has core.symlinks=true.
rem t1 gets no local core.symlinks, so it inherits true.
git init t1
set GIT_CONFIG_NOSYSTEM=1
set GIT_CONFIG_GLOBAL=NUL
rem t2 gets symlinks = false in its local config.
git init t2

A command-scope value does survive. Setting GIT_CONFIG_COUNT=1, GIT_CONFIG_KEY_0=core.symlinks, GIT_CONFIG_VALUE_0=true before apm install makes Windows produce the Linux hash. A repository-local core.symlinks=true in the consuming project does not.

To Reproduce

On Windows with Developer Mode on and git config --global core.symlinks true:

  1. Create a project whose apm.yml has only microsoft/aspire-skills#v0.0.4 under dependencies.apm.
  2. Run apm install with an empty cache (APM_CACHE_DIR pointed at a new folder).
  3. The lockfile records content_hash: sha256:5ef3cc66…. On Linux the same steps record sha256:9328e637….
  4. With a lockfile from Linux, apm install --frozen on Windows fails:
[x] Failed to install APM dependencies: Content hash mismatch for microsoft/aspire-skills: expected sha256:9328e637230ce4c0f615e619254a3545dcaa8d36f446551fd436f0e4a4c90d8a, got sha256:5ef3cc66f64719c5ddad3e67f1bfd1bccd9760020e416a8797ed9d8a486e1ed3. ...
  1. Repeat step 2 in a fresh cache with the three GIT_CONFIG_* variables above set: the hash is sha256:9328e637….

apm install --update fails with the same mismatch on Windows.

Expected behavior

The package content hash is the same on every platform for the same commit, so a lockfile generated on Linux (for example by Renovate) verifies on Windows. Either of these would do it:

  • Keep the user's core.symlinks setting when isolating Git config, as is already done for command-scope entries.
  • Make the materialised tree, or the hash, independent of whether Git wrote links. For example, resolve in-package links from the Git tree rather than the working copy, or hash mode-120000 entries by their target content.

There's also no APM option or APM_* environment variable to control this today, so the GIT_CONFIG_* variables are the only workaround.

Environment

  • OS: Windows 11 (build 26300), Git 2.56.0.windows.4. Linux comparison on Ubuntu 24.04 (WSL2).
  • APM Version: 0.35.0 on both
  • Python Version: bundled binary

Additional context

The lockfile was generated on Linux. Possibly related to #3110, which is also about repositories with in-repo symlinks.

Activity

  1. danielmeppiel commented on Nov 10, 2026

    @danielmeppiel
    Collaborator

    Decision: approve
    Area: project
    Scope: Make packages with in-repo symlinks materialize to the same bytes and content_hash on Windows as on POSIX by pinning core.symlinks=true in APM's isolated Git clone and checkout configuration, and when the host cannot create a symlink, fail with a clear diagnostic naming the package and the Windows symlink requirement instead of a later content-hash mismatch.
    Done when: Tests show APM's Git invocations for clone, checkout and the uncached fallback carry core.symlinks=true; on Windows with symlink capability a fixture package with an in-repo symlink yields the POSIX content_hash; when link creation is not possible the install fails before hashing with the diagnostic and a nonzero exit; packages without symlinks are unaffected; docs state the Windows requirement; the tests fail on current main.
    Out of scope: APM-owned dereferencing of links from Git objects; content-hash normalization; changes to user or system Git configuration; links that escape the package; line-ending determinism (#3270, #3368).
    Review contact: Daniel Meppiel (@danielmeppiel)

  2. danielmeppiel commented on Nov 10, 2026

    @danielmeppiel
    Collaborator

    The apm-scope:v1 record above was approved by Daniel Meppiel (@danielmeppiel) at Gate B on 2026-11-10 in the coordinator session of the issue-reduction program. It is the scope a fix for this issue will be reviewed against.

    Review contact: Daniel Meppiel (@danielmeppiel).


    Generated by autopilot-issue-triage-worker. This comment is AI-generated and may contain errors.

  3. added
    status/accepted
    on Nov 10, 2026
  4. danielmeppiel commented on Nov 12, 2026

    @danielmeppiel
    Collaborator

    Decision: approve
    Area: project
    Scope: Extend the #3457 repair so packages with in-repo symlinks materialize identically on every host without requiring OS symlink capability: resolve each tracked symlink whose target stays inside the package from the locked commit's Git objects (link target read from the commit tree, resolved inside that tree, contained and cycle-bounded) and write the target's bytes and mode; reject escaping, broken or cyclic links with the existing diagnostic; keep the core.symlinks=true pin and its diagnostic only where still needed.
    Done when: On Windows without symlink privilege, Linux and macOS, a fixture package with contained file and directory links yields byte-identical materialized trees and the same content_hash as today's POSIX result; apm install --frozen with a lockfile from another platform succeeds on a non-admin Windows host; escaping, broken and cyclic links fail before hashing with a clear diagnostic; packages without links are unaffected; docs state that contained links are copied as their content; the new tests fail on main.
    Out of scope: Following symlinks for source discovery in authoring layouts (#2913, #2802); archive or proxy symlink extraction (#3110); changes to user or system Git configuration; content_hash algorithm changes; links that escape the package; line-ending determinism (#3270, #3368).
    Review contact: Daniel Meppiel (@danielmeppiel)

  5. danielmeppiel commented on Nov 12, 2026

    @danielmeppiel
    Collaborator

    The apm-scope:v1 record above was approved by Daniel Meppiel (@danielmeppiel) on 2026-11-12. It extends the earlier record on this issue: contained symlinks are package content on every platform (same bytes and content_hash everywhere), and resolving them from Git objects removes the Windows Developer Mode requirement introduced by #3545. Links that escape the package stay rejected.


    Posted with AI assistance on behalf of Daniel Meppiel (@danielmeppiel).

  6. danielmeppiel commented on Nov 12, 2026

    @danielmeppiel
    Collaborator

    Reopening: #3545 landed the first slice (pinned core.symlinks=true, contained symlinks are content). The extended scope recorded on 2026-11-12 for Git-object link resolution remains open.

  7. added a commit that references this issue on Nov 12, 2026
    cbd9f2b
  8. added
    pillar/govern
    on Nov 12, 2026
  9. added a commit that references this issue on Nov 12, 2026
    90e76bf
  10. moved this from In Progress to Done in APM Roadmapon Nov 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

pillar/governstatus/accepted

Type

No type

Projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions