ShellGPT icon indicating copy to clipboard operation
ShellGPT copied to clipboard

Install script, `--repl` issues on Windows

Open pseudosavant opened this issue 2 years ago • 5 comments
trafficstars

Deno.run has been deprecated and replaced with Deno.command. See https://deno.land/[email protected]?s=Deno.Command

I did try fixing it in a fork, but when I checked the current code out it would give me this error message even before I changed any code:

(No message passed)

{
  "error": {
    "message": "[] is too short - 'messages'",
    "type": "invalid_request_error",
    "param": null,
    "code": null
  }
}

Failed to parse message TypeError: Cannot read properties of undefined (reading '0')
    at Object.next (file:///C:/Users/paul/Downloads/shellgpt/ShellGPT/lib/ai.ts:150:31)
    at eventLoopTick (ext:core/01_core.js:183:11)
    at async file:///C:/Users/paul/Downloads/shellgpt/ShellGPT/mod.ts:537:34

pseudosavant avatar Jul 24 '23 23:07 pseudosavant

I did notice that the getExecPrefix() tests for Powershell and cmd.exe will always be false as SHELL is not set in the environment for cmd.exe or Powershell. You can check for cmd.exe by checking Deno.env.get('comSpec');

pseudosavant avatar Jul 24 '23 23:07 pseudosavant

Ah sorry, @pseudosavant, I have never tested on Windows.

A few clarifying questions:

  • Is this a new issue on the most recent version – it was working on Windows before?

  • I was under the impression Deno.run still is available until Deno 2.0. Can you share the error message related to this that led you to forking?

the current code out it would give me this error message even before I changed any code

  • This error is typically shown if you run gpt without any arguments. Did you try running something like gpt hello world to make sure it's working?

mattvr avatar Jul 25 '23 02:07 mattvr

  1. Installing on Windows always seemed to error on the last step but was easily overcome with by just running the command it showed: deno install -frA -n gpt https://deno.land/x/shellgpt/mod.ts. Everything worked fine once installed that way. I assumed it probably hadn't been tested on Windows much.

  2. It seemed that 0.33 worked fine initially when I upgraded to it. But once I removed it and tried to install from local (to try making it work with Deno.command but at some point it started throwing the errors below. I typically use it with --repl and that doesn't work at all. These screenshots show it being installed and then invoked a few ways:

image image

  1. I had assumed from the error message I was seeing around the Deno.run invocation that it was related to the deprecation. I didn't see where it is still going to be available until 2.0.

pseudosavant avatar Jul 25 '23 17:07 pseudosavant

Ah okay. Very sorry for breaking things. @pseudosavant

It looks like the issue is Deno.stdin.setRaw does not support Windows. This is used to support newline pasting. But since that's not available, I think unfortunately this functionality can't easily work for Windows.

Any reason not to use cygwin, ConEmu, git bash, WSL, etc. for terminal instead of cmd.exe? I think everything should work fine with those.

You can also install an earlier working version with deno run -rA https://deno.land/x/[email protected]/install.ts until I get around to fixing it.

mattvr avatar Jul 26 '23 05:07 mattvr

I will use the previous version when in cmd.exe until there is a fix. It looks like Deno may be working in this area (setRaw + Windows): https://github.com/denoland/deno/blob/806137bb96c6f7e4b359a6e979c4e22d3a04a55c/Releases.md?plain=1#L533.

It would seem like that method only working on Linux and Mac OS would mean it should throw an error on Windows. At least then you could fall back to the previous prompt() behavior.

cmd.exe is just always there, and starts the fastest. It depends what I want to do. I have ShellGPT installed in Windows/cmd and WSL/bash.

pseudosavant avatar Jul 27 '23 02:07 pseudosavant