Skip to content

archiver: warn about MSYS2 path translation, fixes #9339#9348

Open
trxvorr wants to merge 1 commit intoborgbackup:masterfrom
trxvorr:fix-9339-msys2-paths
Open

archiver: warn about MSYS2 path translation, fixes #9339#9348
trxvorr wants to merge 1 commit intoborgbackup:masterfrom
trxvorr:fix-9339-msys2-paths

Conversation

@trxvorr
Copy link
Contributor

@trxvorr trxvorr commented Feb 15, 2026

This PR addresses issue #9339 by adding a runtime warning when Borg detects it is running under an MSYS2/Git Bash environment without the necessary configuration to prevent path translation.

In MSYS2 environments, POSIX-style paths (e.g., /tmp) are automatically translated to Windows paths (e.g., C:/msys64/tmp) by the shell before being passed to the application. This causes unintended absolute Windows paths to be stored in archives, reducing portability.

Validated that the warning triggers when running in an unmodified MSYS2 shell.
Validated that setting the environment variables suppresses the warning.

@codecov
Copy link

codecov bot commented Feb 15, 2026

Codecov Report

❌ Patch coverage is 42.85714% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 76.02%. Comparing base (3349cdc) to head (f203dcf).
⚠️ Report is 17 commits behind head on master.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
src/borg/archiver/__init__.py 20.00% 4 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #9348      +/-   ##
==========================================
- Coverage   76.03%   76.02%   -0.02%     
==========================================
  Files          85       85              
  Lines       14744    14751       +7     
  Branches     2194     2197       +3     
==========================================
+ Hits        11211    11214       +3     
- Misses       2856     2860       +4     
  Partials      677      677              

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

This adds a runtime warning when running under MSYS2/Git Bash without the necessary environment variables to disable automatic path translation. The documentation is also updated to explain this behavior and how to mitigate it.
@trxvorr trxvorr force-pushed the fix-9339-msys2-paths branch from 3c858c2 to f203dcf Compare February 15, 2026 21:38
MSYS2 Path Translation
++++++++++++++++++++++

When running Borg within an MSYS2 (including Git Bash) environment, the shell
Copy link
Member

Choose a reason for hiding this comment

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

not sure why "Git Bash" is mentioned here?

++++++++++++++++++++++

When running Borg within an MSYS2 (including Git Bash) environment, the shell
automatically translates POSIX-style paths (like ``/tmp`` or ``/c/Users``) to
Copy link
Member

Choose a reason for hiding this comment

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

is msys2 normalizing to always lowercase "/c" ?

is_haiku = sys.platform.startswith("haiku")

# MSYS2/Git Bash (on Windows)
is_msystem = "MSYSTEM" in os.environ
Copy link
Member

Choose a reason for hiding this comment

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

hmm, shall we add "is_win32 and ..." here?

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