diff options
| author | Christophe Besson <cbesson@gmail.com> | 2026-09-04 02:35:41 +0200 |
|---|---|---|
| committer | Christophe Besson <cbesson@gmail.com> | 2026-09-04 02:35:41 +0200 |
| commit | c2620a5b269db75fcadb772e3ae5250886e8814c (patch) | |
| tree | 0920ec826c222bb29978cff9440779ade1fbbc45 /packages/meshbay-node/src/meshbay_node/daemon.py | |
| parent | d11e571c5b6c24b586ef5b8fb2cfcf6a6bfa6d6d (diff) | |
| download | meshbay-c2620a5b269db75fcadb772e3ae5250886e8814c.tar.gz | |
fix(node): make init, node.toml editing and CLI output work on Windows
Found by running the daemon on Windows for the first time:
- `meshbay-node init` wrote `unlock_file = "C:\Users\..."`, and
attach_group / add_root write `path = "C:\..."` — a raw Windows path in a
TOML basic string is a parse error (`\U`, `\a`, ... are escape sequences),
so the config would not load. All now write `Path(...).as_posix()`;
pathlib reads the forward-slash form fine on Windows.
- any `print()` carrying a `->` arrow or em dash (the CLI help and messages
are full of them) raised UnicodeEncodeError on a cp1252 console and took
the command down. New `platform.force_utf8_stdio()` reconfigures
stdout/stderr to UTF-8, called at the top of `main()`.
Verified on Windows: init writes parseable LF node.toml, the keystore
Argon2-decrypts, the loopback control API binds 127.0.0.1, and
`_update_node_toml` reads a CRLF file and rewrites it LF-only with its
standalone comments intact. Two regression tests added in test_ops.py.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Diffstat (limited to 'packages/meshbay-node/src/meshbay_node/daemon.py')
| -rw-r--r-- | packages/meshbay-node/src/meshbay_node/daemon.py | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/packages/meshbay-node/src/meshbay_node/daemon.py b/packages/meshbay-node/src/meshbay_node/daemon.py index 72f7fa4..6bc3bef 100644 --- a/packages/meshbay-node/src/meshbay_node/daemon.py +++ b/packages/meshbay-node/src/meshbay_node/daemon.py @@ -1634,7 +1634,8 @@ def _systemctl_user(verb: str, unit: str, *, not_running_hint: str, def main() -> None: import argparse - from meshbay_node.platform import use_compatible_event_loop + from meshbay_node.platform import force_utf8_stdio, use_compatible_event_loop + force_utf8_stdio() use_compatible_event_loop() parser = argparse.ArgumentParser(description="MeshBay Node daemon") @@ -1738,7 +1739,9 @@ def main() -> None: "ui_port = 18000", "", "[keystore]", - f'unlock_file = "{unlock_file}"', + # Forward slashes: a Windows path in a TOML basic string is a + # parse error (`\U`, `\a`, ... are escape sequences). + f'unlock_file = "{unlock_file.as_posix()}"', "", ] cfg_path.write_text("\n".join(toml_lines) + "\n", encoding="utf-8", newline="\n") |