Complete Guide: Installing Elixir on Fedora/Linux 40
Tags: elixir
Published: 2024-06-16 11:55:14


## Introduction

In this guide, we will learn how to install Elixir on Fedora/Linux version 40. Elixir is a functional and concurrent programming language, ideal for developing distributed applications.

I am currently using Fedora/Linux version 40 with a window manager called DWM, which is a Tiling Window Manager that allows you to open windows within predefined layouts and has several workspaces called tags.

There are two main methods to install Elixir on Fedora: using the `dnf` package manager or using `asdf`, a version manager. I personally use `asdf`, but I will show both methods so you can choose the one that best suits your needs.

## Method 1: Installing Elixir with `dnf`

To install Elixir using Fedora's package manager called `dnf`, you can type the following command in the terminal:

## Method 1: Installing Elixir with `dnf`

To install Elixir using Fedora's package manager called `dnf`, you can type the following command in the terminal:

```bash
sudo dnf install elixir erlang erlang-doc
```

- **elixir**: This package installs the Elixir compiler and the basic tools needed to develop with Elixir.
- **erlang**: This package installs the Erlang virtual machine (BEAM) and the necessary components to run Elixir applications.
- **erlang-doc**: This package contains the Erlang documentation, which can be useful for reference during development.

## Using VS Code with Elixir

As a code editor, you can use VS Code with the ElixirLS extension, which is a language server that provides autocompletion and other features. You can find it on the [Visual Studio Code Marketplace](https://marketplace.visualstudio.com/items?itemName=JakeBecker.elixir-ls).

## Method 2: Installing `asdf` on Fedora

In my specific case, I use `asdf`, which is a version manager, making it easier to have multiple versions of Elixir and Erlang installed on my machine and switch between them for each project.

You can find more information about `asdf` at the following address: [asdf-vm.com](https://asdf-vm.com/). One of the advantages of `asdf` is that you can have a single installation manager supporting multiple languages.

## Installing `asdf` on Fedora

### Step 1: Install Dependencies
First, install two dependencies:

```bash
sudo dnf install curl git
```
### Step 2: Clone the `asdf` Repository
Next, run the following git command in your terminal to install `asdf`:

### Step 3: Configure Zsh
For those using Zsh as a shell, the following configuration must be done in the `.zshrc` file by adding the line below:

```bash
. "$HOME/.asdf/asdf.sh"
```

### Step 4: Install Additional Dependencies
Now, to install `asdf` plugins for each language on Fedora, you need to install some dependencies:

```bash
sudo dnf install gnupg2 curl gawk
```

### Plugins I Use with `asdf`:

#### Node.js

To add the Node.js plugin:

```bash
asdf plugin add nodejs https://github.com/asdf-vm/asdf-nodejs.git
```

To list available versions for installation:

```bash
asdf list-all nodejs
```

Installing a specific version:

```bash
asdf install nodejs 20.14.0
```

Setting the global version:

```bash
asdf global nodejs 20.14.0
```

#### Erlang

Erlang is necessary to have the virtual machine where Elixir will run.

To add the Erlang plugin:

```bash
asdf plugin add erlang https://github.com/asdf-vm/asdf-erlang.git
```

Install dependencies for Fedora ([link for more information](https://github.com/asdf-vm/asdf-erlang)):

```bash
sudo dnf groupinstall -y 'Development Tools' 'C Development Tools and Libraries'
sudo dnf install -y autoconf ncurses-devel openssl-devel libxslt fop
```

Installing a specific version:

```bash
asdf install erlang 27.0
```

Setting the global version:

```bash
asdf global erlang 27.0
```

#### Elixir

To add the Elixir plugin:

```bash
asdf plugin add elixir https://github.com/asdf-vm/asdf-elixir.git
```

Installing a specific version:

```bash
asdf install elixir 1.17
```

Setting the global version:

```bash
asdf global elixir 1.17
```

### Verifying Installations
Now you can open a new terminal and run the following commands to check if they are installed correctly:

```bash
node --version
elixir --version
```

Now you are ready to start your journey into the world of Elixir! With all the necessary tools installed, you can explore the powerful features of this amazing language. Don't hesitate to experiment, explore, and create amazing projects. Good luck and have fun learning Elixir!