Reputation: 195
I have a directory laid out :
-parent
-target
-current
-firstChild
-secondChild
I am trying to direct my package.path from inside "secondChild" to "target" to retrieve other .lua folders stashed there. I have this set up currently
package.path = package.path .. ';../?.lua;../?.lua;../?.lua;target/?.lua'
That doesn't find what I'm looking for and I'm sure that part of my problem is that I do not understand all of the syntaxes. ";../?.lua" says, to me, that I am dropping back to "firstChild" and checking to see if there are lua files?
What am I missing here?
Upvotes: 5
Views: 1657
Reputation: 26794
Given your (updated) directory structure you need to have ../../../target/?.lua
in package.path
to reference modules in target
folder from secondChild
. ?.lua
will search in secondChild
, ../?.lua
will search in firstChild
, ../../?.lua
will search in current
, ../../../?.lua
will search in parent
and ../../../target/?.lua
will search in target
(assuming your current directory is secondChild
when you start your script and also assuming that -
is not part of the directory name). Having ../?.lua
only makes the search to happen in the parent of secondChild
and having target/?.lua
makes the search to happen in secondChild/target/
folder, which doesn't exist.
The error message you get when you try to "require" a module includes all the paths that have been checked by the search, which usually provides a clue as to how the search path should be modified.
Upvotes: 2