Skip to content

fix: handle paths on different drives in Windows for zap-gui#597

Merged
ArekBalysNordic merged 1 commit into
nrfconnect:masterfrom
WangHunZi:fix-zap-gui-windows-path
May 9, 2025
Merged

fix: handle paths on different drives in Windows for zap-gui#597
ArekBalysNordic merged 1 commit into
nrfconnect:masterfrom
WangHunZi:fix-zap-gui-windows-path

Conversation

@WangHunZi
Copy link
Copy Markdown
Contributor

Fix zap-gui path handling on Windows systems with different drives

Issue

When using west zap-gui on Windows, if the ZAP file and any of the required files (ZCL or app templates) are located on different drives, the command fails with: ValueError: 'c:\\ncs\\v3.0.0-rc1\\modules\\lib\\matter\\src\\app\\zap-templates\\zcl\\zcl.json' and 'D:\\Code\\project\\src\\default_zap' have different anchors

This occurs because pathlib.Path.relative_to() method cannot compute relative paths between different drives in Windows. The issue happens in both scenarios:

  1. With default ZCL path from SDK (C: drive) and project on another drive (D: drive)
  2. Even when specifying a custom ZCL file with -j option, if app-templates.json remains on a different drive

Root cause

In update_zcl_in_zap() function, the code attempts to calculate relative paths using relative_to() but doesn't handle the case when paths are on different drives in Windows.

Solution

This PR fixes the issue by:

  1. Adding try/except blocks to properly catch ValueError exceptions where relative_to() is called
  2. Providing absolute paths as a fallback when relative paths cannot be computed

This ensures that west zap-gui works correctly on Windows regardless of drive locations while maintaining the original behavior on Linux and macOS.

Testing

Tested on Windows 11 with:

  • Project on D: drive with SDK on C: drive
  • Both with default ZCL path and with custom ZCL file specified via -j option

The fix also works correctly on Linux as before, where this issue doesn't occur.

@WangHunZi WangHunZi requested a review from a team as a code owner April 17, 2025 12:44
@NordicBuilder
Copy link
Copy Markdown

none

Note: This comment is automatically posted and updated by the Contribs GitHub Action.

Copy link
Copy Markdown
Contributor

@kkasperczyk-no kkasperczyk-no left a comment

Choose a reason for hiding this comment

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

LGTM 👍 Thank you for the contribution!

@adigie
Copy link
Copy Markdown
Member

adigie commented Apr 25, 2025

Hi @WangHunZi, you have to sign Contributor License Agreement before we can merge this. Please force push to this PR to trigger the CLAassistant.

Signed-off-by: wanower <suguguan@qq.com>
@CLAassistant
Copy link
Copy Markdown

CLAassistant commented Apr 26, 2025

CLA assistant check
All committers have signed the CLA.

@WangHunZi
Copy link
Copy Markdown
Contributor Author

Hi @WangHunZi, you have to sign Contributor License Agreement before we can merge this. Please force push to this PR to trigger the CLAassistant.

Hi @adigie , thank you for the reminder! I've signed the CLA and addressed the requested changes. Could you please help approve the pending workflows so we can proceed? Let me know if there's anything else I need to do. Thanks again for your assistance!

@ArekBalysNordic ArekBalysNordic merged commit 67c7c6d into nrfconnect:master May 9, 2025
8 of 9 checks passed
ArekBalysNordic pushed a commit to ArekBalysNordic/sdk-connectedhomeip that referenced this pull request Oct 27, 2025
* [SL-UP] Updating the performance profile API to v2 (nrfconnect#639)

* [SL-UP] Adds improvements on the join and scan logic based on WiseConnect feedback (nrfconnect#596)

Co-authored-by: Restyled.io <commits@restyled.io>
Co-authored-by: Mathieu Kardous <84793247+mkardous-silabs@users.noreply.github.com>

* [SL-UP] Custom board part build fix (nrfconnect#597)

* [SL-UP] Rejoin fix after power cycle for sleepy 917 devices

* Fix matter_shell include path argument

* [SL-UP] Adding the changes for the Wi-Fi which were done after the merge (nrfconnect#569)

Co-authored-by: Mathieu Kardous <84793247+mkardous-silabs@users.noreply.github.com>

* [SL-UP] Revert the Task priorities for the 917SoC (nrfconnect#538)

* [SL-UP] Rejoin fix after power cycle for sleepy 917 devices

* [SL-UP] Add an implementation of GetOtaTlvEncryptionKeyId

* fix typo

---------

Co-authored-by: chirag-silabs <100861685+chirag-silabs@users.noreply.github.com>
Co-authored-by: Rohan Sahay <103027015+rosahay-silabs@users.noreply.github.com>
Co-authored-by: Restyled.io <commits@restyled.io>
Co-authored-by: chirag-silabs <chirag.bansal@silabs.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.

6 participants