hindsight icon indicating copy to clipboard operation
hindsight copied to clipboard

hindsight-embed: CLI install path uses `bash -c "curl … | bash"` with text=True — UnicodeDecodeError on Windows, and get-cli has no Windows branch, so every forwarded command fails

Open JSJ189 opened this issue 3 weeks ago • 1 comments

Summary

On Windows, every hindsight-embed command that forwards to the CLI (memory retain, memory recall, bank list, even --version) fails, because the "install the CLI" step is a POSIX shell pipeline.

hindsight_embed/daemon_client.py:205-211:

result = subprocess.run(
    ["bash", "-c", f"curl -fsSL {CLI_INSTALLER_URL} | bash"],
    capture_output=True,
    text=True,        # no encoding= → locale codec (cp936/GBK) on Windows
    env=env,
)

Two independent defects:

  1. text=True without encoding=. The reader thread decodes the installer's output with the console codec and dies: UnicodeDecodeError: 'gbk' codec can't decode byte 0xff in position 383 (raised in subprocess._readerthread). result.stdout/result.stderr are then never populated, so the wrapper can only report a bare CLI installation failed (exit code 1) with no diagnostics.
  2. The installer has no Windows branch. https://hindsight.vectorize.io/get-cli is POSIX-only: its uname -s case matches Darwin and Linux only (205 lines, no MINGW/MSYS/CYGWIN/Windows_NT, no .exe, no PowerShell). So even with the decoding fixed, the step cannot install on Windows — despite #5258 publishing native Windows x64 CLI binaries.

Environment

  • Windows 11 (build 26300); git-bash present on PATH, so bash resolves and "bash", "-c" does run
  • Node v24.19.0, npm 12.1.0
  • hindsight-embed 1.2.1 (via uvx hindsight-embed@latest)

Steps to reproduce

hindsight-embed -p coding-agent memory retain ov-test "hello"

Output:

Exception in thread Thread-2 (_readerthread):
  ...
  File "subprocess.py", line 1599, in _readerthread
    buffer.append(fh.read())
UnicodeDecodeError: 'gbk' codec can't decode byte 0xff in position 383: illegal multibyte sequence
CLI installation failed (exit code 1):
Installing hindsight CLI (version 1.2.1)...
  Installer URL: https://hindsight.vectorize.io/get-cli

PYTHONUTF8=1 / PYTHONIOENCODING=utf-8 do not help — switching the codec only changes the error to 'utf-8' codec can't decode byte 0xc0, because the installer writes non-UTF-8 bytes. On a machine without bash on PATH the same branch fails earlier with a caught FileNotFoundError and the same generic message.

Impact

The CLI is the documented surface for memory retain/recall/reflect, bank list, daemon logs and ui *. On Windows all of those are unusable, and the daemon being healthy and reachable on 127.0.0.1:9077 does not help. The only working surface is the HTTP API directly.

Suggested fixes

  1. On Windows, install through PowerShell (powershell -NoProfile -Command "irm <url> | iex") or Invoke-WebRequest, rather than bash -c
  2. Always pass encoding="utf-8", errors="replace" alongside text=True (the same class of bug was already fixed in #3747, #3837 and #4344)
  3. When the CLI genuinely cannot be installed on a platform, say so explicitly ("the bundled CLI installer does not support Windows; use the HTTP API") instead of reporting an exit code

Workaround

Talk to the daemon over HTTP:

curl -X POST http://127.0.0.1:9077/v1/default/banks/<bank>/memories \
  -H "Content-Type: application/json" \
  -d '{"items":[{"content":"..."}]}'

and start the control plane with npx @vectorize-io/hindsight-control-plane.

JSJ189 avatar Nov 13 '26 02:11 JSJ189

Confirmed workaround that avoids the installer entirely:

hindsight-embed looks for the binary before installing (daemon_client.py:154 find_cli_binary(), :242 is_cli_installed()), and CLI_INSTALL_DIRS includes ~/.local/bin. The release does ship a native Windows binary (hindsight-windows-amd64.exe, 3.6 MB, PE32+ x86-64), so dropping it in by hand makes every forwarded command work:

# from https://github.com/vectorize-io/hindsight/releases/download/v1.2.1/hindsight-windows-amd64.exe
mkdir -Force $HOME\.local\bin
Invoke-WebRequest -Uri <release-url> -OutFile $HOME\.local\bin\hindsight.exe

Verified afterwards on Windows 11 / embed 1.2.1:

$ hindsight-embed -p coding-agent bank list
Found 1 bank(s)
  - ov-zh-test

$ hindsight-embed -p coding-agent memory retain ov-zh-test "..." --context "..."
Memory retained successfully (document: cli_put_20261113_104818)
  Stored count: 1

So the gap is only in the installer step, not in the CLI binaries or in find_cli_binary(). Points 1 and 2 above still stand for making that step work unattended: PowerShell instead of bash -c, and encoding="utf-8", errors="replace" on the subprocess.run(..., text=True) call.

JSJ189 avatar Nov 13 '26 02:11 JSJ189