ChatGPT.nvim
ChatGPT.nvim copied to clipboard
Unable to open chat
I keep running into errors when I try to open the chat window using any of the commands. for example:
ChatGPT
:
Error executing Lua callback: ...l/nvim-data/lazy/lazy.nvim/lua/lazy/core/handler/cmd.lua:32: Vim:Error executing Lua callback: ...cal/nvim-data/lazy/ChatGPT.nvim/lua/chatgpt/settings.lua:45: attempt to concatenate a nil value
stack traceback:
...cal/nvim-data/lazy/ChatGPT.nvim/lua/chatgpt/settings.lua:45: in function 'read_config'
...cal/nvim-data/lazy/ChatGPT.nvim/lua/chatgpt/settings.lua:69: in function 'get_settings_panel'
...Local/nvim-data/lazy/ChatGPT.nvim/lua/chatgpt/module.lua:89: in function 'open_chat'
...Local/nvim-data/lazy/ChatGPT.nvim/lua/chatgpt/module.lua:209: in function 'openChat'
...ppData/Local/nvim-data/lazy/ChatGPT.nvim/lua/chatgpt.lua:25: in function 'openChat'
...ata/Local/nvim-data/lazy/ChatGPT.nvim/plugin/chatgpt.lua:2: in function <...ata/Local/nvim-data/lazy/ChatGPT.nvim/plugin/chatgpt.lua:1>
[C]: in function 'cmd'
...l/nvim-data/lazy/lazy.nvim/lua/lazy/core/handler/cmd.lua:32: in function <...l/nvim-data/lazy/lazy.nvim/lua/lazy/core/handler/cmd.lua:16>
stack traceback:
[C]: in function 'cmd'
...l/nvim-data/lazy/lazy.nvim/lua/lazy/core/handler/cmd.lua:32: in function <...l/nvim-data/lazy/lazy.nvim/lua/lazy/core/handler/cmd.lua:16>
and ChatGPTEditWithInstructions
:
Error executing Lua callback: ...cal/nvim-data/lazy/ChatGPT.nvim/lua/chatgpt/settings.lua:45: attempt to concatenate a nil value
stack traceback:
...cal/nvim-data/lazy/ChatGPT.nvim/lua/chatgpt/settings.lua:45: in function 'read_config'
...cal/nvim-data/lazy/ChatGPT.nvim/lua/chatgpt/settings.lua:69: in function 'get_settings_panel'
...l/nvim-data/lazy/ChatGPT.nvim/lua/chatgpt/code_edits.lua:83: in function 'edit_with_instructions'
...ppData/Local/nvim-data/lazy/ChatGPT.nvim/lua/chatgpt.lua:33: in function 'edit_with_instructions'
...ata/Local/nvim-data/lazy/ChatGPT.nvim/plugin/chatgpt.lua:10: in function <...ata/Local/nvim-data/lazy/ChatGPT.nvim/plugin/chatgpt.lua:9>
The other ones error in a similar fashion
(this is on windows 11, if relevant)
Did you know how to resolve that yet? 🤔
You're probably running into the problem that Windows does usually not have a HOME
environment variable set. There are two pull requests that address this (and some other problems concerning invalid names of session files under Windows), see #45 and #51.
@pitkling when you say "Windows does not usually have a Home
env var set" are you referring to Windows Subsystem for Linux or Windows specifically?
@pitkling when you say "Windows does not usually have a
Home
env var set" are you referring to Windows Subsystem for Linux or Windows specifically?
Specifically Windows (the OS). Standard Linux systems should have these variables set.
Is there a reason those two PRs weren't accepted yet? 🙏 they have been open for months and seem pretty simple
making this change to the read_config function worked for me
M.read_config = function()
local home = os.getenv("HOME") or os.getenv("USERPROFILE")
local filename = home .. "/.chatgpt-" .. M.type .. "-params.json"
local file = io.open(filename, "rb")
if not file then
return nil
end
local jsonString = file:read("*a")
file:close()
return vim.json.decode(jsonString)
end