ThePrimeagen / harpoon

MIT License
6.99k stars 376 forks source link

Lua error after installing harpoon #4

Closed gpcureton closed 3 years ago

gpcureton commented 3 years ago

After installing harpoon, I get the following error when running :bnext, :bprev, :CocCommand explorer etc...

Error detected while processing BufLeave Autocommands for "*":
E5108: Error executing lua ...onfig/nvim/autoload/plugged/harpoon/lua/harpoon/mark.lua:34: attempt to get length of field 'marks' (a nil value)

I'm using Neovim nightly v0.5.0-dev+1097-g18f90336c.

ThePrimeagen commented 3 years ago

interesting.

So this is obvi bad. This shouldn't happen.

Let me try to figure out what is going on, as I think that its to do with an empty projct with no config :)

My very big sorries for not getting back sooner. I didn't have noti's turned on and missed it :(

ThePrimeagen commented 3 years ago

I am unable to repro, are you on the latest version?

I have been making tons of changes. We are not quite at 1.0, so expect some churn in the immediate future.

I'll make a quick change that could help, but unsure why its required (as I don't know why its happening for you). Effectively your cache, for your project, is present, but doesn't have a marks list. This puzzles me :)

gpcureton commented 3 years ago

I was on the latest version of harpoon at the time. I just did an update and had the same issue, which threw up as soon as PlugUpdate finished running and I tried to leave the vim-plug buffer. I'm going to consider your comment about the marks list and see of I can figure out if there's something in my neovim config which is borking things in that respect. Feel free to close as un-repro, I'll loiter around in the discord, and re-post if I discover something actionable.

ThePrimeagen commented 3 years ago

Let me create a quick PR to make sure this all works. Somehow, some state got goofed. I really appreciate you taking the time at all. Its very kind to do so.

gpcureton commented 3 years ago

NP, I just wish I understood the guts of neovim better so I could be a bit more constructive than "stuff's broken" :-)

ThePrimeagen commented 3 years ago

REPRO'D! Selection_019

ThePrimeagen commented 3 years ago

Give me a moment to fix this.

ThePrimeagen commented 3 years ago

Ok, I believe I have officially fixed it. Could you verify @gpcureton ?

gpcureton commented 3 years ago

@ThePrimeagen Sorry, I'm still getting the same error.

ThePrimeagen commented 3 years ago

F

ThePrimeagen commented 3 years ago

@gpcureton did you :PlugUpdate? Do you know the hash? Does it match the current hash of master?

ThePrimeagen commented 3 years ago

The problem was new projects or previous configured projects. And I thought I addressed it. But alas and alack. I must of screwed up.

ThePrimeagen commented 3 years ago

Dang it, I should take more time in answering things. Could you link me the newly moved error? (It sohuld of at least moved lines).

ThePrimeagen commented 3 years ago

Ohh! I may have found it!

Is this what you are seeing? Selection_021

gpcureton commented 3 years ago

@ThePrimeagen I did a :PlugClean and PlugUpdate a few times to make sure I was getting the latest. I'm getting the error

Error detected while processing BufLeave Autocommands for "*":
E5108: Error executing lua ...onfig/nvim/autoload/plugged/harpoon/lua/harpoon/mark.lua:34: attempt to get length of field 'marks' (a nil value)

for the hash a48aa25.

ThePrimeagen commented 3 years ago

@gpcureton So sorry for this churn.

I believe I have it solved now. I have tried new projects with both terminal and marking with no errors. Mind you trying one more time?

ThePrimeagen commented 3 years ago

Also, this shows me how important it is for me to create a logging mechanism

gpcureton commented 3 years ago

NP, glad to help. For posterity, some actions which trigger the error:

Just tried a41b1c9, getting

Error detected while processing BufLeave Autocommands for "*":
E5108: Error executing lua ...onfig/nvim/autoload/plugged/harpoon/lua/harpoon/mark.lua:40: attempt to get length of fiel
d 'marks' (a nil value)

It moved at least :-)

My config is at https://gitlab.ssec.wisc.edu/geoffc/neovim_config , if that's something that proves useful.

ThePrimeagen commented 3 years ago

Thank you thank you! Let me play around with this.

I assume it must be something unique here.

ThePrimeagen commented 3 years ago

Could you also cat your ~/.local/shared/nvim/harpoon.json (or wherever your XDG_DATA_PATH is (i think thtas the path))

echo stdpath("data")

ThePrimeagen commented 3 years ago

btw, your config is just a blank repo for me. Selection_022

Do I need permissions?

ThePrimeagen commented 3 years ago

Got it!

It turns out I call require('harpoon').setup({ ... }) You must not!

I have the error now. Thank you!

gpcureton commented 3 years ago

That repo is supposed to be public. I have it mirrored at https://github.com/gpcureton/neovim-config , try that.

My XDG_DATA_PATH isn't defined, but I have the following in ~/.local/share/nvim/harpoon.json

{"projects": {"/home/geoffc/tmp/test_proj": {"mark": {"marks": []}, "term": {"cmds": []}}, "/home/geoffc": {"mark": {"marks": []}, "term": {"cmds": []}}, "/home/geoffc/SSEC/git/neovim_config": {"mark": {"marks": []}, "term": {"cmds": []}}}}

I should add that I haven't actually tried using harpoon yet, I was wondering if I was doing something off-label, but I hadn't gotten to that point yet.

ThePrimeagen commented 3 years ago

@gpcureton Its not your fault. Its mine.

I literally made the init flow run through setup. This is problematic as you may never call setup. Obviously I need to make things more robust. I'll have to fix this tonight. Its a bit more involved.

gpcureton commented 3 years ago

I put...

lua << EOF
require('harpoon').setup {}
EOF

into a file which is sourced by my init.vim, and BOOM! Error went away. Because I hadn't started fiddling with harpoon yet my config for it was blank.

Teamwork makes the dream work ;-)

ThePrimeagen commented 3 years ago

I believe its fixed. Closing with supreme confidence.

reed9999 commented 5 months ago

I've been getting a very similar error message from a new standard (afaik) attempt to follow the complete nvim setup video. In an attempt to reinstall Harpoon without going completely back to square one, I've done the basics:

To no avail. Also tried the same general approach to remove harpoon and plenary, and then all three of harpoon, plenary, and telescope. On that last try, I uncommented it only in the packer.lua, leaving the entire after/plugin/harpoon.lua still commented. A simple :lua require("harpoon.mark") on the vim command line was enough to put it back in this bad state.

My full error message:

Error detected while processing BufLeave Autocommands for "*":                                                                               
Error executing lua callback: ...nvim/site/pack/packer/start/harpoon/lua/harpoon/init.lua:115: attempt to index local 'projects' (a nil value)
stack traceback:
        ...nvim/site/pack/packer/start/harpoon/lua/harpoon/init.lua:115: in function 'ensure_correct_config'
        ...nvim/site/pack/packer/start/harpoon/lua/harpoon/init.lua:248: in function 'refresh_projects_b4update'
        ...nvim/site/pack/packer/start/harpoon/lua/harpoon/init.lua:171: in function 'save'
        ...nvim/site/pack/packer/start/harpoon/lua/harpoon/mark.lua:18: in function 'emit_changed'
        ...nvim/site/pack/packer/start/harpoon/lua/harpoon/mark.lua:281: in function 'store_offset'
        ...nvim/site/pack/packer/start/harpoon/lua/harpoon/init.lua:20: in function <...nvim/site/pack/packer/start/harpoon/lua/harpoon/init.lua:19>

By comparison I set up another Mac (personal vs. work) going back to the beginning and got it working fine. There the projects attribute is populated. I'll have to dig to find out why there is this discrepancy.

reed9999 commented 5 months ago

Eventually I got harpoon working but only after removing (actually stashing away on a different path) the entirety of .local/share/nvim and doing the config from scratch. My nvim intuition isn't good but my guess is something under site/pack/packer/start was retaining whatever it was that was causing the problem.

Anyway all good for harpoon but I may never know the root cause. Good thing the video made it so fast to reconfig!