8
require "utils.lua"
stdin:1: module 'utils.lua' not found:
        no field package.preload['utils.lua']
        no file 'D:\blizzard\Projects\Lua'
        no file '.\utils\lua.dll'
        no file 'D:\blizzard\Projects\Lua\utils\lua.dll'
        no file 'D:\blizzard\Projects\Lua\loadall.dll'
        no file '.\utils.dll'
        no file 'D:\blizzard\Projects\Lua\utils.dll'
        no file 'D:\blizzard\Projects\Lua\loadall.dll'

Why LuaJIT searches for .dll instead of .lua and how to fix this behavior?

Jamie Hutton
  • 260
  • 3
  • 13
DSblizzard
  • 4,007
  • 7
  • 48
  • 76

1 Answers1

12

You should require utils (ditch the .lua) , and utils.lua should be on your package.path variable, or passed as the LUA_PATH environment variable.

More info in the Lua Reference Manual about package.loaders, require() and package.path

jpjacobs
  • 9,359
  • 36
  • 45
  • "and utils . lus should be ... passed as the LUA_PATH". I haven't understood this. Directory where I placed utils.lua is in the LUA_PATH env. variable and I omitted ".lua" but this doesn't help. – DSblizzard Jul 20 '11 at 10:41
  • utils.lua. Sorry typo. So your package.path variable contains a lot of directories where Lua looks for libraries. utils.lua should be in one of them. – jpjacobs Jul 20 '11 at 10:53
  • OK, I changed LUA_PATH to D:\blizzard\Projects\Lua\?.lua and it worked. – DSblizzard Jul 20 '11 at 11:06
  • How do I make lua search for .\file.lua instead of .\file.dll? I just want to require some files in my project directory without having to set LUA_PATH each time. – Phrozen Oct 04 '12 at 23:53
  • 1
    you can use `package.path=package.path..'./?.lua;'` before using `require`. Also note the difference between package.path and package.cpath (and LUA_PATH and LUA_CPATH). Ther former concerns Lua files, while the latter concerns compiled C libraries. – jpjacobs Oct 05 '12 at 09:03