r/lua • u/Flickyn • Dec 17 '25
I need help executing lua files on VScode
FIXED BY UNINSTALLING FLATPACK VSCODE AND INSTALLING THE OFFICIAL ONE (.deb)
THANKS TO EVERYONE WHO HELPED!!!
(Sorry for bad english)
I'm using PopOS
Already installed lua with "sudo apt install 5.4" and everything is fine.
When I try to execute a file in VScode terminal with "lua5.4 filename.lua " or "lua filename.lua"
It appears "lua5.4: command not found"
Can someone help me please? Im new on Linux and dont know if I need to do another command on terminal.
11
Upvotes
6
u/slade51 Dec 17 '25 edited Dec 17 '25
Have you tried inserting this as the first line of your source file:
Look at update-alternatives if lua is pointing to a different version. This command will reset symlinks for various installations with multiple versions.
1
u/Calaverd Dec 18 '25
Seems that you are pretty new in linux and software in general, usually if you just installed Lua using "sudo apt install lua5.4" it is added to the path automatically. What is happening is that you are calling Lua including their version number, but once it is installed you just need to call Lua (the version number only matters at installation or if you are running a lot of different versions).
You can check that Lua is running typing just
And that should print the version of Lua showing that it is working. 🙂
2
u/autoerotion95 Dec 17 '25
Export the lua path to your bashrc
2
u/xoner2 Dec 18 '25
I googled it for you: https://fabianlee.org/2021/12/23/vscode-add-a-directory-to-the-terminal-path/
1
u/NabePup Dec 18 '25
I'm not 100% sure what the issue is, but it could possible be related to your VS Code terminal not being run as a login shell. If you installed lua5.4 via apt (or whatever your default package manager is) it should have been added to your path automatically. If you installed by some other means then it not being added to your path could be the issue.
Try launching your operating system's native terminal, NOT the VS Code terminal and run the command
which lua5.4and check to see if you see a path to the lua5.4 binary printed, something like:if you don't see anything printed then that means it's not added to your
PATHvariable. If you do see something printed then try to do the same in the VS Code terminal and if you don't see anything printed there then that way you know it's just something having to do with the VS Code terminal.I'm assuming you're using either
bashorzshas your shell, so to get them to run as login shells in VS Code (which may or may not be the solution), add these settings to your VS Code settings:and restart VS Code and see if that helps.