mirror of
https://github.com/platformio/platformio-core.git
synced 2026-08-25 06:23:44 +02:00
Fix: resolve relative -d/--project-dir path in `pio device monitor` `device_monitor_cmd`'s `-d/--project-dir` option accepted a relative path without resolving it to absolute. The command then entered `with fs.cd(options["project_dir"]):`, changing the working directory into that relative subdir. Downstream, a platform monitor filter (e.g. the espressif32 exception decoder) re-enters the same still-relative `project_dir` via `load_build_metadata()`'s own `fs.cd()`, duplicating the path segment onto the already-changed cwd and crashing with FileNotFoundError (platformio/platformio-core#5439). Add `resolve_path=True` to the click.Path type so the path is resolved to absolute once, at the point it enters the system, before any fs.cd() chain runs. This does not change the no-flag default (os.getcwd already returns absolute) or the already-absolute case (passes through unchanged, modulo symlink resolution). Add a regression test mirroring the nested fs.cd() scenario, plus coverage for the default and already-absolute cases.