natural-harmonia-gropius / recent-menu

Recently played menu for mpv-player.
MIT License
33 stars 2 forks source link

Lua error: .../apps/mpv/current/portable_config/scripts/recentmenu.lua:131: bad argument #1 to 'ipairs' (table expected, got nil) #13

Closed SonaliBendre closed 1 year ago

SonaliBendre commented 1 year ago

[recentmenu] [recentmenu] stack traceback: [recentmenu] .../apps/mpv/current/portable_config/scripts/recentmenu.lua:131: in function 'append_item' [recentmenu] .../apps/mpv/current/portable_config/scripts/recentmenu.lua:190: in function 'handler' [recentmenu] mp.defaults:510: in function 'call_event_handlers' [recentmenu] mp.defaults:552: in function 'dispatch_events' [recentmenu] mp.defaults:503: in function [recentmenu] [C]: at 0x7ff721b0de20 [recentmenu] [C]: at 0x7ff721b0e310 [recentmenu] Lua error: .../apps/mpv/current/portable_config/scripts/recentmenu.lua:131: bad argument #1 to 'ipairs' (table expected, got nil)

natural-harmonia-gropius commented 1 year ago

Are you using scripts from this repo? image image

SonaliBendre commented 1 year ago

what does it supposed to mean?

natural-harmonia-gropius commented 1 year ago

Download script from https://raw.githubusercontent.com/natural-harmonia-gropius/recent-menu/master/recentmenu.lua, replace one you are using and try again.

po5 commented 1 year ago

Looks like he's on commit 37e4054872ee201c71ada77af50b71c7a8a53bf5.
What likely happened is that the recent.json write failed somehow (disk full?), leading to a 0-byte file that makes utils.parse_json() return nil.
Confirmed to still be an issue on the latest commit by manually emptying recent.json.

[recentmenu] 
[recentmenu] stack traceback:
[recentmenu]    [C]: in function 'ipairs'
[recentmenu]    /home/eva/.config/mpv/scripts/recentmenu.lua:121: in function 'remove_deleted'
[recentmenu]    /home/eva/.config/mpv/scripts/recentmenu.lua:160: in function 'read_json'
[recentmenu]    /home/eva/.config/mpv/scripts/recentmenu.lua:183: in function 'append_item'
[recentmenu]    /home/eva/.config/mpv/scripts/recentmenu.lua:224: in function 'handler'
[recentmenu]    mp.defaults:510: in function 'call_event_handlers'
[recentmenu]    mp.defaults:552: in function 'dispatch_events'
[recentmenu]    mp.defaults:503: in function <mp.defaults:502>
[recentmenu]    [C]: in ?
[recentmenu]    [C]: in ?
[recentmenu] Lua error: /home/eva/.config/mpv/scripts/recentmenu.lua:121: bad argument #1 to 'ipairs' (table expected, got nil)

utils.parse_json(json) -> utils.parse_json(json) or {} is enough to fix it.

natural-harmonia-gropius commented 1 year ago

You can download latest version to fix this. But this only fixes the crash, I think the script would not work as expected, there must be some deeper reason. If there are still problems, please reopen this issue.

What likely happened is that the recent.json write failed somehow (disk full?)

I didn't expect this to happen. Thanks!

po5 commented 1 year ago

But this only fixes the crash, I think the script would not work as expected

Works fine here, history gets saved and can be displayed.

natural-harmonia-gropius commented 1 year ago

I guess he will encounter another error in write_json, waiting for his feedback.