jtackaberry / reaticulate

An articulation management system for REAPER
Other
101 stars 46 forks source link

utils.lua:66: attempt to index a nil value (local 'f') #40

Closed Wezuvius closed 6 years ago

Wezuvius commented 6 years ago

Just installed via Reapack using method stated on the site.

When I run the main.lua I recieve a reascript error saying: \Scripts\Reaticulate\app\lib\utils.lua:66: attempt to index a nil value (local 'f')

reaper 5.78/x64 windows10

jtackaberry commented 6 years ago

Thanks for the report. I'm sure it won't surprise you to learn I've not run into this myself. :)

Is this a portable install or a standard system install? Do you have the same problem if you try a fresh portable install in some different path?

Is this the very first time you ran the main action? Or did it run successfully before, but now it's failing?

Wezuvius commented 6 years ago

Its a standard reaper install and yeah it never ran from first attempt, just showed the error above.

I ran the reaper portable install on another HHD and the main.lua ran fine with the portable install 😕

jtackaberry commented 6 years ago

If you execute the action "Show REAPER resource path in explorer" from Reaper's actions list, can you check the Data subdirectory there and tell me if you have a file called Reaticulate-tmp1.reabank? (It's possible the number may be different than 1 but I doubt it.)

Wezuvius commented 6 years ago

Yeah the file exists in the data sub directory for my standard reaper install (I assumed you didnt mean the portable one, if you did I apolagise)

jtackaberry commented 6 years ago

Thanks -- I did mean your standard Reaper install (the one where Reaticulate doesn't work).

Any change if you delete that Reaticulate-tmp1.reabank file? Secondly, can you confirm if reaper.ini exists in the resource path (the one containing the Data directory)?

I'm a bit stymied by this one so I need a bit more debugging information. Not sure if this is asking a bit much, but would you be able to edit the Scripts\Reaticulate\app\lib\utils.lua file and replace the whole write_file() function from lines 64-68 with the code below?

With that updated, when you rerun the Reaticulate_Main action, it should hopefully pop up a console window with the error message that should help us find root cause.

function write_file(fname, contents)
    local f, err = io.open(fname, "w")
    if not f then
        reaper.ShowConsoleMsg("Error writing file " .. tostring(fname) .. ": " .. tostring(err) .. "\n")
    else
        f:write(contents)
        f:close()
    end
end
Wezuvius commented 6 years ago

Deleting the tmp1.reabank file didnt change anything.

Reaper.ini does exist in the resource path one folder up from data.

After putting in your code into a copied utils, reaper error kicked back a error writing file reaper.ini permission denied however reaticulate did run after pressing ok for the error:

I checked the permissions and my user account has full control over reaperi.ni as does the administrators group and SYSTEM.

I put the original utils.lua back to see If i could generate the original error message from my first comment however reaticulate now runs with the original utils.lua. Swapping back to the edited utils.lua now also runs without generating the permissions issue.

I then uninstalled it via reapack and reinstalled it, however it ran first time with no error after the reinstall. and putting the edited utils back didnt produce the permissions error either on starting the script. I can however reproduce both errors with their respective utils.lua's by pressing the refresh button on the gui.

jtackaberry commented 6 years ago

Well, bizarre. But this at least gives me an idea of how I can reproduce something similar to your original issue. Minimally I need to make Reaticulate handle this kind of failure more robustly and give the user some idea of what's wrong.

So I'll leave this issue open until I fix that.

Thanks!