Package Path

lua-users home

When you type

whatever = require "whatever"       

Lua tries to find a package named whatever in many places, mostly having whatever somewhere in their names. If none of these is found, Lua gives an error message listing them all, something like

stdin:1: module 'whatever' not found:
	no field package.preload['whatever']
	no file '/usr/local/share/lua/5.2/whatever.lua'
	no file '/usr/local/share/lua/5.2/whatever/init.lua'
	no file '/usr/local/lib/lua/5.2/whatever.lua'
	no file '/usr/local/lib/lua/5.2/whatever/init.lua'
	no file './whatever.lua'
	no file '/usr/local/lib/lua/5.2/'
	no file '/usr/local/lib/lua/5.2/'
	no file './'
stack traceback:
	[C]: in function 'require'
	stdin:1: in main chunk
	[C]: in ?

A schematic representation of that list is kept in the variable package.path. For the above list, that variable contains


RecentChanges · preferences
edit · history
Last edited February 23, 2013 3:21 pm GMT (diff)