0

I've been having difficulty setting up lua as a system path. I'm attempting to run lua programs via the command prompt. I've followed multiple stackoverflow answers for similar questions: Running a lua program from a text file to no avail. Regarding the link's four steps: I'm able to complete step one no problem, would like to complete step three and step two onward have thoroughly confused me.

I've edited my PATH variable to include what I believe the correct path for lua is: C:\Program Files\Lua\5.3.4_64\lua53.exe. I feel like this is where I'm botching it.

This is the general output when I try to run lua from a cmd prompt within the folder holding lua.exe or outside of it.

C:\Program Files\Lua\5.3.4_32>lua main.lua

'lua' is not recognized as an internal or external command, operable program or batch file.

If anyone can help or needs more information to help please let me know and thank you in advance.

uninformed
  • 15
  • 1
  • 6
  • Please take a look on [What is the reason for '...' is not recognized as an internal or external command, operable program or batch file?](https://stackoverflow.com/a/41461002/3074564) Read also Microsoft Developer Network article [Naming Files, Paths, and Namespaces](https://msdn.microsoft.com/en-us/library/windows/desktop/aa365247.aspx). The first you have to learn is that a full qualified file name like `C:\Program Files\Lua\5.3.4_64\lua53.exe` consists of __drive__ `C:` usually concatenated with __path__ ``\Program Files\Lua\5.3.4_64\``, __file name__ `lua53` and __file extension__ `.exe`. – Mofi May 19 '18 at 07:37

1 Answers1

3

You need to add the folder of lua53.exe to the PATH variable. That is, add C:\Program Files\Lua\5.3.4_64, not C:\Program Files\Lua\5.3.4_64\lua53.exe. Then when you type lua53 in the command prompt, the command processor will search in that folder for lua53.exe and run it.

If you want to run Lua in the command line with the name lua, you will have to rename lua53.exe to lua.exe, or create a batch file named lua.bat with the content lua53 %* and save it in the same folder as lua53.exe. (%* is a variable that copies the arguments that you typed after the name of the batch file. That is, if you type lua -e "print 'Hello, world!'" in the command line, it will execute the command lua53 -e "print 'Hello, world!'".)

cyclaminist
  • 1,697
  • 1
  • 6
  • 12
  • 2
    I recommend in batch file `lua.bat` stored in directory of `lua53.exe` to use the command line `@"%~dp0lua53.exe" %*` as this avoids the necessity for Windows command processor to search for lua53.* with a file extension listed in environment variable `PATHEXT` in current directory. – Mofi May 19 '18 at 07:44