Lua is powerful, lightweight interpreted scripting language with a small footprint. It supports multi-paradigm programming: procedural, object-oriented, functional, data-driven and data-description. Lua is rarely used as a stand-alone language. Instead Lua focuses on scripting, as “secondary” language which integrated into other software written in mainly C/C++.
Some examples of Lua’s usage areas: network software, video games, user graphical interfaces, graphics/text processing software, etc. Lua also is good for beginners to create simple video games.
Lua interpreter is written in ANSI C and it is extremely small, both interpreter and source code is only about 1Mb. Lua is considered one of the fastest interpreted languages. Checking Lua
Some distributions already have Lua pre-installed. Open your terminal and type:
luaIf the output is be something like:
Lua 5.4.3 Copyright (C) 1994-2021 Lua.org, PUC-Rio
>install the required Lua libraries using Luarocks (if not installed already):
luarocks install luaposixDepending on your Linux distribution, the installation method for libyaml may differ. Here are the commands for some common distributions:
For Ubuntu/Debian-based systems, use apt-get:
sudo apt-get update
sudo apt-get install libyaml-devFor Fedora, use dnf:
sudo dnf install libyaml-develFor CentOS/RHEL, use yum:
sudo yum install libyaml-develAfter installing libyaml using the appropriate package manager for your Linux distribution, retry installing lyaml with LuaRocks:
luarocks install --local lyamlDon't forget to set up your environment variables using the eval $(luarocks path --bin) command so Lua can find your locally installed modules.
- Run the installation command with
sudoto gain elevated privileges:
sudo luarocks install lyaml- Install the Lua module locally for your user by using the
--localoption:
luarocks install --local lyamlWhen you install the module locally, you need to ensure that Lua can find it by setting up the LUA_PATH and LUA_CPATH environment variables appropriately. The luarocks path command will output the correct settings; you can add them to your shell configuration file (e.g., .bashrc, .bash_profile, .zshrc, etc.) to apply them permanently:
eval $(luarocks path --bin)After running luarocks install --local lyaml, execute the above eval command or restart your shell to apply the settings. Then, try running your script again.
clone
git clone https://github.com/apitee/lua.gitlua apitee.lua git.yamlHint! To exit Lua’s interpreter press Ctrl + D.