improve error checking when loading Lua scripts

This commit adds a missing error check when loading/hashing Lua scripts
from paths specified in the environment.