Skip to content

Commit aea70d6

Browse files
authored
Merge pull request #9224 from bill88t/chdir-always
Always `os.chdir("/")` when reloading
2 parents 781c577 + 77a4e42 commit aea70d6

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

main.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -473,9 +473,6 @@ STATIC bool __attribute__((noinline)) run_code_py(safe_mode_t safe_mode, bool *s
473473
usb_setup_with_vm();
474474
#endif
475475

476-
// Make sure we are in the root directory before looking at files.
477-
common_hal_os_chdir("/");
478-
479476
// Check if a different run file has been allocated
480477
if (next_code_configuration != NULL) {
481478
next_code_configuration->options &= ~SUPERVISOR_NEXT_CODE_OPT_NEWLY_SET;
@@ -1112,6 +1109,10 @@ int __attribute__((used)) main(void) {
11121109
serial_write_compressed(MP_ERROR_TEXT("soft reboot\n"));
11131110
}
11141111
simulate_reset = false;
1112+
1113+
// Always return to root before trying to run files.
1114+
common_hal_os_chdir("/");
1115+
11151116
if (pyexec_mode_kind == PYEXEC_MODE_FRIENDLY_REPL) {
11161117
// If code.py did a fake deep sleep, pretend that we
11171118
// are running code.py for the first time after a hard

0 commit comments

Comments
 (0)