Skip to content

gitutil: fix HOME=NUL failure on Windows ARM64#6734

Open
rzlink wants to merge 1 commit intomoby:masterfrom
rzlink:fix/gitutil-windows-arm64-nul
Open

gitutil: fix HOME=NUL failure on Windows ARM64#6734
rzlink wants to merge 1 commit intomoby:masterfrom
rzlink:fix/gitutil-windows-arm64-nul

Conversation

@rzlink
Copy link
Copy Markdown
Collaborator

@rzlink rzlink commented Apr 30, 2026

Problem

PR #6639 (commit e6e6026) changed HOME=/dev/null to HOME=os.DevNull for cross-platform
compatibility. On Windows, os.DevNull resolves to NUL. While this works on Windows AMD64,
Git on Windows ARM64 cannot use NUL as a HOME directory path:

fatal: unable to access 'NUL': Invalid argument

Git attempts to access NUL/.gitconfig, which fails on ARM64 Windows.

Fix

Add platform-specific helpers (noConfigHome() / noConfigGlobal()):

  • Unix (git_noconfig_unix.go): continues using /dev/null (unchanged behavior)
  • Windows (git_noconfig_windows.go): lazily creates an empty temp directory for HOME
    (so ~/.gitconfig is absent) and an empty temp file for GIT_CONFIG_GLOBAL (a valid
    empty gitconfig). Uses sync.Once to create these once per process.

Falls back to os.DevNull if temp creation fails, maintaining compatibility on AMD64.

Testing

  • Existing TestGitCLIConfigEnv tests updated to use the new helpers
  • Verified on Windows ARM64 (VMSS-based CI runners running Windows Server 2025 ARM64)
  • No behavioral change on Unix or Windows AMD64

On Windows ARM64, git cannot use the NUL device as HOME or
GIT_CONFIG_GLOBAL path, failing with "fatal: unable to access
'NUL': Invalid argument". This was introduced by e6e6026
(PR moby#6639) which changed HOME=/dev/null to HOME=os.DevNull.

Add platform-specific helpers: on Unix, continue using /dev/null;
on Windows, lazily create an empty temp directory for HOME and an
empty temp file for GIT_CONFIG_GLOBAL.

Signed-off-by: Dawei Wei <wei.dawei.cn@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant