Skip to content

Commit 059c2ee

Browse files
committed
Update webrepl_setup.py
Hello! There are many instances online about people complaining of `OSError: [Errno 2] ENOENT` errors when trying to initialize WebREPL, particularly on the Pico W. It appears that these people are not using `boot.py` in their projects, but `webrepl_setup` relies on its existence to function. However, it does not create the file if it doesn't exist, and fails with `OSError: [Errno 2] ENOENT`. Since there isn't a .py file to easily trace through (as `webrepl_setup` and `webrepl` are usually pre-compiled and included in pre-built Micropython binaries), many users struggle to realize that they're missing a `boot.py` file for `webrepl_setup` to write to. This PR adds a check (new function `validate_boot_file()`) before `get_daemon_status()`, which checks for the existence of `boot.py` and creates the file if it doesn't exist. This solves the `OSError: [Errno 2] ENOENT` error when trying to run `webrepl_setup.py` without a `boot.py` file!
1 parent fbf7e12 commit 059c2ee

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

micropython/net/webrepl/webrepl_setup.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,12 @@ def exists(fname):
3939
return False
4040

4141

42+
def validate_boot_file():
43+
if not exists(RC):
44+
with open(RC, "w") as f:
45+
f.write("# boot.py -- run on boot-up\n")
46+
47+
4248
def get_daemon_status():
4349
with open(RC) as f:
4450
for l in f:
@@ -71,6 +77,7 @@ def change_daemon(action):
7177

7278

7379
def main():
80+
validate_boot_file()
7481
status = get_daemon_status()
7582

7683
print("WebREPL daemon auto-start status:", "enabled" if status else "disabled")

0 commit comments

Comments
 (0)