Skip to content

Fix false repo relocation warning on macOS due to NFC/NFD path differences (#2913)#9940

Merged
ThomasWaldmann merged 1 commit into
borgbackup:masterfrom
ThomasWaldmann:fix-macos-nfd-repo-relocation-2913
Jul 26, 2026
Merged

Fix false repo relocation warning on macOS due to NFC/NFD path differences (#2913)#9940
ThomasWaldmann merged 1 commit into
borgbackup:masterfrom
ThomasWaldmann:fix-macos-nfd-repo-relocation-2913

Conversation

@ThomasWaldmann

Copy link
Copy Markdown
Member

Fixes #2913.

Problem

On macOS the filesystem returns paths in NFD (decomposed) unicode form, while a path typed as a command line argument is usually in NFC (composed) form. These render identically but are byte-different. So accessing a repo whose path contains non-ASCII characters via a relative path / . / $(pwd) after cd made borg believe the repository had been relocated:

cd /tmp && mkdir empty
borg init -e none tëst
borg create tëst::test1 /tmp/empty
cd tëst
borg create .::test2 /tmp/empty
>> Warning: The repository at location /private/tmp/tëst was previously located at /private/tmp/tëst
>> Do you want to continue? [yN]

The two locations are visually identical because one is NFC and the other NFD.

Fix

  • Add helpers.normalize_local_path() — normalizes to NFD on macOS (the form the filesystem itself uses, matching what patterns.normalize_path() already does), a no-op on other platforms.
  • Run local file locations through it in Location.canonical_path().
  • Normalize both sides of the comparison in SecurityManager.assert_location_matches(), so existing NFC-form security location files still match after upgrade (no one-time spurious prompt) and remote (rest/ssh/borgstore) URLs stay consistent (normalization is idempotent and applied symmetrically).

Scope / safety

  • No-op on non-macOS platforms (is_darwin is fixed at import time).
  • Only affects the repository location string used for the security/relocation check and its display — archived file paths are unaffected.

Tests

Added test_normalize_local_path and test_canonical_path_unicode_normalization (both platform-aware). Full parseformat + archiver checks suites pass locally.

🤖 Generated with Claude Code

@codecov

codecov Bot commented Jul 23, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 85.68%. Comparing base (7bfd489) to head (4a25abc).
⚠️ Report is 15 commits behind head on master.
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #9940      +/-   ##
==========================================
- Coverage   85.68%   85.68%   -0.01%     
==========================================
  Files          95       95              
  Lines       16794    16799       +5     
  Branches     2574     2574              
==========================================
+ Hits        14390    14394       +4     
- Misses       1668     1669       +1     
  Partials      736      736              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

…rning on macOS (borgbackup#2913)

On macOS the filesystem returns paths in NFD (decomposed) form, while a
path typed as a command line argument is usually in NFC (composed) form.
These look identical but are byte-different, so accessing a repo via a
relative path / `.` / `$(pwd)` after `cd` made borg believe the repository
had been relocated and prompt for confirmation.

Add helpers.normalize_local_path() (NFD on macOS, no-op elsewhere) and run
local file locations through it in Location.canonical_path(). Also normalize
both sides of the location comparison in SecurityManager.assert_location_matches()
so existing NFC-form security "location" files keep matching after upgrade.

This only affects the repository *location* string used for the security /
relocation check (and its display); archived file paths are unaffected, and
the change is a no-op on non-macOS platforms.
@ThomasWaldmann
ThomasWaldmann force-pushed the fix-macos-nfd-repo-relocation-2913 branch from 0f98f35 to 4a25abc Compare July 26, 2026 14:25
@ThomasWaldmann
ThomasWaldmann merged commit 4bd1859 into borgbackup:master Jul 26, 2026
19 checks passed
@ThomasWaldmann
ThomasWaldmann deleted the fix-macos-nfd-repo-relocation-2913 branch July 26, 2026 16:27
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.

macOS NFD normalization confuses repo move check

1 participant