attempt to index a nil value (field 'appWatcher')
ngriffin7a opened this issue · comments
Hi, my Hammerspoon console is reporting the following error:
stack traceback:
.hammerspoon/Spoons/VimMode.spoon/lib/vim.lua:112: in function 'VimMode.disableForApp'
/Users/ngriffin/.hammerspoon/init.lua:11: in main chunk
[C]: in function 'xpcall'
...app/Contents/Resources/extensions/hs/_coresetup/init.lua:648: in function 'hs._coresetup.setup'
(...tail calls...)```
Would appreciate any insights anyone might have. Thanks!
@ngriffin7a hi - i've been trying to track this down as well. Question: does this happen on a laptop that goes to sleep/wakes a bunch?
Hi @dbalatero thanks so much for the quick response. The laptop is closed each night, and then reopened each morning.
@dbalatero Sorry for the delay in responding. Hammerspoon gives me the error under all circumstances:
- When I cold start my laptop
- When I restart hammerspoon
- When I reload the hammerspoon config
- When I close the laptop lid, let it go to sleep, open the lid, and reload the hammerspoon config
Have you made any progress in determining what might be the cause? Thanks!
@ngriffin7a I'm circling back on this. Would you mind giving me your config?
@andycmaj you also thumbs up'd this - do you have extra insights to share with me to help track this down?
I'm wondering if 99cb78f fixes it?
@dbalatero I applied your patch for 99cb78f locally to ~/.hammerspoon/Spoons/VimMode.spoon/lib/app_watcher.lua but I get the same error.
Which config file did you want me to send?
@dbalatero this is silly, but i forgot to switch my local clone of your repo to vim-mode-v2
before i enabled it in my spoon config 🤦♂
thanks for following up! and maybe it's as simple as that for others :)
I've been using the vim-mode-v2
branch the whole time and still have the problem. I just rebased and the error is the same.
Here is the config file:
vim = hs.loadSpoon('VimMode')
-- Basic key binding to ctrl+;
-- You can choose any key binding you want here, see:
-- https://www.hammerspoon.org/docs/hs.hotkey.html#bind
hs.hotkey.bind({}, 'escape', function()
vim:enter()
end)
vim:disableForApp('iTerm2')
vim:disableForApp('MacVim')
vim:disableForApp('Terminal')
@ngriffin7a Ugh, I think the documentation is broken between v1 and v2.
Can you replace vim = hs.loadSpoon('VimMode')
with:
local VimMode = hs.loadSpoon('VimMode')
local vim = VimMode:new()
In v1 I was exporting an already instantiated object, but in v2 I switched to exporting the class definition instead of an instance. Blah.
@dbalatero That fixed it, thanks!