Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

lua dofile "no such file or directory" in Windows

Tags:

windows

lua

I have the Programming in Lua book and I downloaded the batteries included lua for Windows.

One of the first examples is a function that's saved in a file called lib1.lua. I created this function in the SciTE text editor and saved the file in the directory on my C: drive that contains lua.exe.

But when I type dofile("lib1.lua") in the lua interpreter I get a "no such file or directory". I've looked in several websites and they mention changing the path variable, but they don't say how. Is this a variable in Windows? Or a lua variable somewhere in one of the directories?

Help? Thanks.

like image 946
user3410333 Avatar asked Oct 20 '25 02:10

user3410333


1 Answers

You need to put lib1.lua into the current folder where the script is being executed or use the absolute path dofile([[c:\path\lib1.lua]]). In the case of paths on Windows it's better to use [[]] as string separators as this allows you to not use slash escaping and paths look more "natural".

like image 190
Paul Kulchenko Avatar answered Oct 22 '25 03:10

Paul Kulchenko



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!