llm icon indicating copy to clipboard operation
llm copied to clipboard

llm 0.14: Can't run <<llm chat>> on Windows 11

Open rsbohn opened this issue 1 month ago • 1 comments

Description: After upgrading from version 0.13, the following lines of code fail to execute on a Windows 11 environment:

readline.parse_and_bind("\\e[D: backward-char")
readline.parse_and_bind("\\e[C: forward-char")

This issue appears to be specific to Windows. On non-Windows platforms, these lines work as expected.

Steps to Reproduce:

  1. Upgrade from version 0.13 to the latest version on a Windows 11 machine.
  2. Execute code containing the lines:
    readline.parse_and_bind("\\e[D: backward-char")
    readline.parse_and_bind("\\e[C: forward-char")
    

Observed Behavior: The code fails on Windows 11, leading to errors or unexpected behavior.

IndexError: Not a valid key: '\e[d'

Workaround Implemented: I have temporarily resolved the issue using a platform check to ensure this code doesn't execute on Windows. Here is the workaround:

import os
import readline

if os.name != 'nt':
    readline.parse_and_bind("\\e[D: backward-char")
    readline.parse_and_bind("\\e[C: forward-char")

Relevant Code: The relevant section of the code can be found at this link to cli.py, line 345.

Environment:

  • OS: Windows 11
  • Version affected: Latest version after 0.13

Expected Behavior: The code should work across all platforms, including Windows 11, without requiring modifications.

rsbohn avatar May 15 '24 11:05 rsbohn

See also https://github.com/simonw/llm/commit/1a4853d80e9543ce93bba1b8cdf45d7201cd7a05

rsbohn avatar May 15 '24 11:05 rsbohn