rubberduck-ai / rubberduck-vscode

Use AI-powered code edits, explanations, code generation, error diagnosis, and chat in Visual Studio Code with the official OpenAI API.
https://marketplace.visualstudio.com/items?itemName=Rubberduck.rubberduck-vscode
MIT License
582 stars 70 forks source link

'Enter OpenAI key' resulted in an error (Not enough memory resources...) #54

Open tfguinan opened 1 year ago

tfguinan commented 1 year ago

When entering an OpenAI API key, the Rubberduck extension returns the error:

Command 'Rubberduck: Enter OpenAI key' resulted in an error (Not enough memory resources are available to process this command)

To recreate: through the CTRL+SHIFT+P menu, select 'Rubberduck: Enter OpenAI key' and type your key. After hitting enter, the error message will pop up. Interestingly, entering the API key through the 'Enter Key' button doesn't result in an error pop up, though doesn't appear to do much at all. Initially I though this was a result of using VScodium, but got the same error when trying in VScode.

I would expect this command to function correctly without error, as there is ~5gb RAM available on the machine as the error occurs.

image

Furthermore, would I be correct in assuming there should be something in the logs at: "C:\*\AppData\Roaming\Code\logs\*\window1\exthost\outputlogging\\3-Rubberduck.log"? As the file present is 0kb.

Version impacted: 1.12.0

lgrammel commented 1 year ago

Thanks for the bug report!

I could not reproduce it, but I'm on Mac and it seems that you are using Windows. Did it show the "OpenAI API key stored." message popup when you entered the key (either successfully or unsuccessfully?

tfguinan commented 1 year ago

That's correct, here is the 'about' from VScodium:

Version: 1.75.1 (user setup) Release: 23040 Commit: c6a9727b801542499d2b59cb7db4224e060fc578 Date: 2023-02-09T22:46:15.410Z Electron: 19.1.9 Chromium: 102.0.5005.167 Node.js: 16.14.2 V8: 10.2.154.15-electron.0 OS: Windows_NT x64 10.0.19044 Sandboxed: No

Unfortunately no pop up when entering the key into either the command palette, or the button (textbox).

That said, I can get popups from Rubberduck, for example clearing the key I get 'OpenAI API key cleared.', or CTRL+ALT+E: 'Variable 'selectedText' is too short'.

lgrammel commented 1 year ago

I suspect it could be an infinite loop cause by an event mechanism we introduced recently to update the UI when you have entered your key: https://github.com/rubberduck-ai/rubberduck-vscode/blob/main/lib/extension/src/openai/ApiKeyManager.ts#L60

How comfortable would you be building Rubberduck yourself with that line disabled, to see if that fixes the issue on Windows?

tfguinan commented 1 year ago

Ah, interesting. Probably a little shaky!

https://fedidat.com/320-installing-vscode-extensions-from-source/ Would the .vsix method as above be suitable? After disabling the 'messagEmitter' line?

lgrammel commented 1 year ago

Yes, you'd need to install the vsix after you package the extension.

You can find the basic build steps here: https://github.com/rubberduck-ai/rubberduck-vscode/blob/main/CONTRIBUTING.md

pnpm nx run vscode:package‍ packages the extension and creates the .vsix file.

Please let me know if you have any questions. Your help is much appreciated!

randomsnowflake commented 1 year ago

I encounter the same issue with a new VSCode "portable" installation on macOS while trying to enter the OpenAI API Key in Rubberduck settings (access via the command prompt). The alert mentioned earlier appeared. The plugin workes fine in my main VSCode installation.