We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 7adcf89 commit f0730a8Copy full SHA for f0730a8
1 file changed
cmdstanpy/utils.py
@@ -1001,6 +1001,7 @@ def do_command(
1001
1002
"""
1003
get_logger().debug('cmd: %s\ncwd: %s', ' '.join(cmd), cwd)
1004
+ restore_cwd = os.getcwd() if cwd is not None else None
1005
try:
1006
# NB: Using this rather than cwd arg to Popen due to windows behavior
1007
with pushd(cwd if cwd is not None else '.'):
@@ -1042,6 +1043,8 @@ def do_command(
1042
1043
raise RuntimeError(msg)
1044
except OSError as e:
1045
msg = 'Command: {}\nfailed with error {}\n'.format(cmd, str(e))
1046
+ if restore_cwd is not None:
1047
+ os.chdir(restore_cwd)
1048
raise RuntimeError(msg) from e
1049
1050
0 commit comments