summaryrefslogtreecommitdiffstats
path: root/packages/meshbay-node/src/meshbay_node/ops.py
diff options
context:
space:
mode:
authorChristophe Besson <cbesson@gmail.com>2026-09-04 02:35:41 +0200
committerChristophe Besson <cbesson@gmail.com>2026-09-04 02:35:41 +0200
commitc2620a5b269db75fcadb772e3ae5250886e8814c (patch)
tree0920ec826c222bb29978cff9440779ade1fbbc45 /packages/meshbay-node/src/meshbay_node/ops.py
parentd11e571c5b6c24b586ef5b8fb2cfcf6a6bfa6d6d (diff)
downloadmeshbay-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/ops.py')
-rw-r--r--packages/meshbay-node/src/meshbay_node/ops.py8
1 files changed, 5 insertions, 3 deletions
diff --git a/packages/meshbay-node/src/meshbay_node/ops.py b/packages/meshbay-node/src/meshbay_node/ops.py
index 40de755..4c20c2a 100644
--- a/packages/meshbay-node/src/meshbay_node/ops.py
+++ b/packages/meshbay-node/src/meshbay_node/ops.py
@@ -447,9 +447,11 @@ async def attach_group(state: dict, name: str, shared_dir: str,
upload_path.mkdir(parents=True, exist_ok=True)
except OSError as e:
raise OpError(f"Cannot create {upload_path}: {e}") from e
- block += f'upload_dir = "{upload_path}"\n'
+ block += f'upload_dir = "{upload_path.as_posix()}"\n'
block += (f'\n [[groups.roots]]\n'
- f' path = "{path}"\n')
+ # Forward slashes: a Windows path in a TOML basic string is a
+ # parse error (`\U`, `\a`, ... are escapes). pathlib reads `/`.
+ f' path = "{path.as_posix()}"\n')
if not separate_upload:
block += f' upload = true\n'
try:
@@ -667,7 +669,7 @@ async def add_root(state: dict, group_id: str, path: str, *,
raise OpError(f"Cannot create {added.path}: {e}") from e
conf_path = Path(state.get("config_path") or DEFAULT_CONFIG_PATH)
- root_block = f' [[groups.roots]]\n path = "{added.path}"'
+ root_block = f' [[groups.roots]]\n path = "{added.path.as_posix()}"'
if name:
root_block += f'\n name = "{added.name}"'
if kind != "generic":