Skip to content

Commit 347e4e1

Browse files
authored
cbuild-run: set working directory to parent of cbuild-run.yml (#1788)
1 parent 8925666 commit 347e4e1

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

pyocd/target/pack/cbuild_run.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,8 @@ def __init__(self, yml_path: str) -> None:
288288
self._use_default_memory_map: bool = True
289289

290290
try:
291+
# Normalize the path to ensure compatibility across platforms.
292+
yml_path = os.path.normpath(yml_path)
291293
with open(yml_path, 'r') as yml_file:
292294
yml_data = yaml.safe_load(yml_file)
293295
if 'cbuild-run' in yml_data:
@@ -296,6 +298,10 @@ def __init__(self, yml_path: str) -> None:
296298
self._valid = True
297299
else:
298300
raise CbuildRunError(f"Invalid .cbuild-run.yml file '{yml_path}'")
301+
# Set cbuild-run path as the current working directory.
302+
base_path = Path(yml_path).parent
303+
os.chdir(base_path)
304+
LOG.debug("Working directory set to '%s'", os.getcwd())
299305
except IOError as err:
300306
LOG.error("Error attempting to access .cbuild-run.yml file '%s': %s", yml_path, err)
301307

0 commit comments

Comments
 (0)