monome / norns

norns is many sound instruments.
http://monome.org
GNU General Public License v3.0
614 stars 144 forks source link

Errors on button presses/navigation: attempt to call a nil value (field 'save_mix') #672

Closed jaredpereira closed 5 years ago

jaredpereira commented 5 years ago

The full traceback:

lua: /home/we/norns/lua/state.lua:50: attempt to call a nil value (field 'save_mix')
stack traceback:
    /home/we/norns/lua/state.lua:50: in function 'state.save'
    /home/we/norns/lua/menu.lua:1032: in field 'key'
    /home/we/norns/lua/menu.lua:144: in function </home/we/norns/lua/menu.lua:121>

I can't start scripts, and I also can't go back (button 2) in certain menus. For example if i'm in the "Devices" menu I can't go back to "System" but I can go forward to "MIDI" and then back to "Devices".

Reproducing

I can't actually tell what's causing this. It seems to be if I just wait for a couple minutes, or after I do any changes, like loading a script or changes to the wifi.

Possibly related

I've been syncing my scripts over via rsync over ssh. I also sshed into the norns and restarted matron to get a console on my machine. Unsure how they'd be related but these are the only things I've changed recently.

jaredpereira commented 5 years ago

I think I can replicate by running this script I wrote: https://gitlab.com/jaredpereira/norns-scripts/blob/master/sequencer/sequencer.lua

Still digging through it but I'm not sure what the root cause is. I'll try to make a smaller reproduction.

jaredpereira commented 5 years ago

Ah, I'm pretty sure it's because I have a variable named state in my script that I should've made local :man_facepalming:. Perhaps one takeaway could be having a more explanatory error for name conflicts? But that's probably a lua problem. If so I'm happy to close this issue :)


EDIT: Perhaps another solution could be using the tab.readonly utility function I just saw merged in on this line.

Which also includes the comment :

---- ... whaaat?? why are all of these made global here?


EDIT 2: Just realized what day I'm posting to github :sweat_smile: I hope you're all enjoying your holidays and thanks for all the work you do on this lovely system!

tehn commented 5 years ago

we're on a massive undertaking to fix the globals issue: https://github.com/monome/norns/issues/557

i apologize for the perplexing scripting frustration this certainly has caused.

for a list of system vars which your script might break, until the update comes: https://github.com/monome/norns/issues/559

doesn't look like state is on the list??

jaredpereira commented 5 years ago

No apology neccessary :) I'm just kicking myself for not realizing the state variable was the source even when I saw in function 'state.save' in the error.

State's in that list, see state : table: 0x666b0, and is addressed in pq's thorough comment, so happy to close this!