[ EN | PT ] What is the best way for you to install the Lua language on your Ubuntu? - Qual a melhor forma de você instalar a linguagem Lua no seu Ubuntu?

in HiveDevslast month

banner

There are some common ways to install the Lua language on your Ubuntu device (as well as other programming languages). The best known are installation via APT, installation from source code and installation via Luaver, each having its advantages and disadvantages. Shall we analyze each one a little?

Using APT

Installation via APT is one of the most common for standard Ubuntu users, as it is simple to install and use. Unfortunately, I don't like this way because I'm unlucky with APT, and I always find broken packages or that the default installation simply doesn't understand the environment variables (cough cough Netbeans cough cough), which makes me prefer other ways of installing packages, such as SNAP and Flatpak managers, .deb packages, and .AppImages executables.

To be able to install the Lua language using APT you have to first look for the language in the package manager:

apt search lua

For me, APT listed a bunch of stuff that has nothing to do with it, so I filtered it with grep:

apt search lua | grep lua

Then the list got better. The language packages that matter to us are these:

lua5.1/focal 5.1.5-8.1build4 amd64
lua5.2/focal 5.2.4-1.1build3 amd64
lua5.3/focal 5.3.3-1.1ubuntu2 amd64

And then you can install it like this:

sudo apt install lua5.3

And that's it, you have the language installed.

Installing from source code

To install from the source code you have to access the language download page and follow the step by step. To install the current version of the Lua language (5.4.6), just run the script below:

curl -L -R -O https://www.lua.org/ftp/lua-5.4.6.tar.gz
tar zxf lua-5.4.6.tar.gz
cd lua-5.4.6
make all test

And that’s it.

Luaver

Luaver is a version manager for the Lua language, which is capable of managing multiple versions of the language and package managers within your computer. Although you can do this manually using APT, for example, Luaver has language versions prior to version 5, and allows you to easily switch versions without much effort unlike installing via source code.

To install the manager, you first need to install the dependency:

sudo apt-get install libreadline-dev

If you want to install old versions of Lua (32-bit) on 64-bit computers, you will also need the following dependency:

sudo apt-get install lib32ncurses5-dev

To install it on your machine, after installing the dependencies, you just need to run the following command:

curl -fsSL https://raw.githubusercontent.com/dhavalkapil/luaver/master/install.sh | sh -s - -r v1.1.0

Then you restart your terminal:

. ~/.zshrc

And list the versions to select the one you want:

luaver list -r

For me, a series of numbers appeared representing each version, such as 5.4.3, 5.4.4, 5.4.5 and 5.4.6, which, at the time of writing, is the latest version available, and the one we are going to install here, however, if you need to use another version (for whatever reason), you can choose one of the other dozens of versions available simply by using the same commands below and switching the version number.

To install the language, you just need to do this:

luaver install 5.4.6

To switch between different versions, you have to use the following command:

luaver use 5.4.6

You can also set a specific version of Lua to be the default version of the language:

luaver set-default 5.4.6

And that's it, just use the language on your machine. You can repeat the steps above for any other version of the language whenever you need, regardless of the reasons. For example, I created this minesweeper game using Lua in version 5.3.6. If I need to make some adjustments and the newer version of the language doesn't work, I'm not going to rack my brains remaking the game from scratch. Instead, I will run the commands below:

luaver install 5.3.6
luaver use 5.3.6

And that's it, I'm already using, in the current terminal session, the Lua language in version 5.3.6. Now it's just work.

The verdict

Although I find it very practical to install via APT, and installation using the source code is the most compatible with everyone, my preferred way is Luaver, which allows you to easily change your language version and also manage installed packages more fluidly. and practicality. Even after installing and using it initially, the advantages of the tool outweigh the disadvantages, so I recommend at least taking a look. You can also manage the versions of other tools, such as LuaRocks (Lua's package manager), using Luaver, which is a great facilitator for any developer.

In any case, each developer is able to determine the best conditions and the best tools for their suite, as well as the best ways to install certain applications, and the purpose of the post was to present an alternative to the traditional way of installing the tool.

Did you like it? Leave your opinion in the comments.


banner

Existem algumas formas comuns de serem usadas para instalar a linguagem Lua no seu dispositivo Ubuntu (assim como outras linguagens de programação). As mais conhecidas são a instalação via APT, a instalação a partir do código fonte e a instalação via Luaver, cada uma possuindo suas vantagens e desvantagens. Vamos analisar um pouco cada uma?

Usando o APT

A instalação via APT é uma das mais usuais para usuários padrão no Ubuntu, já que é simples de instalar e de utilizar. Infelizmente, eu não gosto dessa forma porque eu sou azarado com o APT, e sempre encontro pacotes quebrados ou que simplesmente a instalação padrão não entende as variáveis de ambiente (cof cof Netbeans cof cof), o que me faz preferir outras formas de instalação de pacotes, como os gerenciadores SNAP e Flatpak, pacotes .deb e executáveis .AppImages.

Para poder instalar a linguagem Lua usando APT você tem que primeiro procurar a linguagem no gerenciador de pacotes:

apt search lua

Para mim, o APT listou um monte de coisas que não tem nada a ver, então eu filtrei com grep:

apt search lua | grep lua

Aí a listagem melhorou. Os pacotes da linguagem que importam para a gente são esses aqui:

lua5.1/focal 5.1.5-8.1build4 amd64
lua5.2/focal 5.2.4-1.1build3 amd64
lua5.3/focal 5.3.3-1.1ubuntu2 amd64

E aí você pode instalar assim:

sudo apt install lua5.3

E pronto, você tem a linguagem instalada.

Instalando a partir do código fonte

Para instalar a partir do código fonte você tem que acessar a página de download da linguagem e seguir o passo a passo. Para instalar a versão atual da linguagem Lua (5.4.6), é só executar o script abaixo:

curl -L -R -O https://www.lua.org/ftp/lua-5.4.6.tar.gz
tar zxf lua-5.4.6.tar.gz
cd lua-5.4.6
make all test

E pronto.

Luaver

O Luaver é um gerenciador de versões da linguagem Lua, que é capaz de gerenciar várias versões da linguagem e de gerenciadores de pacote dentro do seu computador. Apesar de você poder fazer isso manualmente usando o APT, por exemplo, o Luaver possui versões da linguagem anteriores à versão 5, e permite que você troque facilmente de versão sem muito esforço ao contrário da instalação via source code.

Para instalar o gerenciador, primeiro você precisa instalar a dependência:

sudo apt-get install libreadline-dev

Se quiser instalar versões antigas da Lua (de 32 bits) em computadores 64 bits, vai precisar também da seguinte dependência:

sudo apt-get install lib32ncurses5-dev

Para instalar na sua máquina, após instalar as dependências, você só precisa rodar o seguinte comando:

curl -fsSL https://raw.githubusercontent.com/dhavalkapil/luaver/master/install.sh | sh -s - -r v1.1.0

Depois você reinicia o seu terminal:

. ~/.zshrc

E liste as versões para selecionar a que você quiser:

luaver list -r

Para mim, apareceu uma série de números representando cada versão, como 5.4.3, 5.4.4, 5.4.5 e 5.4.6, que, no momento em que escrevo, é a versão mais recente disponível, e a que vamos instalar aqui, porém, caso você precise usar outra versão (por qualquer motivo que seja), você pode escolher alguma das outras dezenas de versões disponíveis simplesmente usando os mesmos comandos abaixo e alternando o número da versão.

Para instalar a linguagem, você só precisa fazer isso:

luaver install 5.4.6

Para alternar entre diferentes versões, você tem que suar o seguinte comando:

luaver use 5.4.6

Você também pode definir uma versão específica da Lua para ser a versão padrão da linguagem:

luaver set-default 5.4.6

E pronto, só usar a linguagem na sua máquina. Você pode repetir os passos acima para qualquer outra versão da linguagem sempre que precisar, independente dos motivos. Por exemplo, eu criei este jogo de campo minado usando Lua na versão 5.3.6. Caso eu precise fazer algum ajuste e a versão mais nova da linguagem não funcione, eu não vou quebrar a cabeça refazendo o jogo do zero. No lugar disso, eu vou executar os comandos abaixo:

luaver install 5.3.6
luaver use 5.3.6

E pronto, já estou usando, na sessão atual do terminal, a linguagem Lua na versão 5.3.6. Agora é só trabalhar.

O veredito

Embora eu ache bem prático instalar via APT, e a instalação usando o código fonte seja a mais compatível com todos, a minha forma preferida é o Luaver, que permite que você troque facilmente sua versão da linguagem e também gerencie os pacotes instalados com mais fluidez e praticidade. Mesmo que a instalação e o uso inicial dele, as vantagens da ferramenta superam as desvantagens, então, recomendo ao menos darem uma olhadinha. Você ainda pode gerenciar as versões de outras ferramentas, como o LuaRocks (gerenciador de pacotes do Lua), usando o Luaver, o que é um grande facilitador para qualquer desenvolvedor.

De todas as formas, cada desenvolvedor é capaz de determinar as melhores condições e as melhores ferramentas para sua suíte, bem como as melhores formas para instalar determinadas aplicações, e o intuito da postagem foi de apresentar uma alternativa à forma tradicional de instalação da ferramenta.

Gostou? Deixe sua opinião nos comentários.

Sort:  

Thanks for the support, hope I can help someone hehe

!PIZZA


Your post was manually curated by @CrazyPhantomBR.
banner_hiver_br_01.png

Delegate your HP to the hive-br.voter account and earn Hive daily!

🔹 Follow our Curation Trail and don't miss voting! 🔹

Hello. Based on your post you might be interested in our new tribe that is launching on Hive soon. Have you seen our Learn to Code tribe and BYTE token whitepaper?

https://peakd.com/hive-188262/@learn2code/learn-to-code-tribe-and-byte-token-whitepaper

Obrigado por ter compartlhado essa postagem na Comunidade Brasil.

Metade das recompensas dessa resposta serão destinadas ao autor do post.

Vote no @perfilbrasil para Testemunha Hive.

Obrigado por promover a Língua Portuguesa em suas postagens.

Vamos seguir fortalecendo a comunidade lusófona dentro da Hive.

Metade das recompensas dessa resposta serão destinadas ao autor do post.

Vote no @perfilbrasil para Testemunha Hive.

Thanks for your contribution to the STEMsocial community. Feel free to join us on discord to get to know the rest of us!

Please consider delegating to the @stemsocial account (85% of the curation rewards are returned).

You may also include @stemsocial as a beneficiary of the rewards of this post to get a stronger support. 
 

Hello from bleujay! Interesting and well written post.

Bleujay is working on getting set up at Peakd....looks like it is taking time to get things sorted...all in good time.

What is Bleyjay?

!PIZZA

Thank you @arthursiq5 .....@bleujay from Whaleshares and formerly Steem...and now HIVE ...seems Ionomy is broken..as my funds have not transferred to HIVE-Engine..any suggestions?

PIZZA!

$PIZZA slices delivered:
@arthursiq5(1/5) tipped @bleujay
arthursiq5 tipped palomap3