A Comprehensive Guide to exenv Improve Your Elixir Development Workflow

Introduction to exenv

exenv is a robust tool for managing multiple Elixir versions in a single development environment, much like rbenv for Ruby. It simplifies the process of switching between Elixir versions and makes it easier to handle dependencies across projects. Below, we provide dozens of useful API explanations with code snippets to help you get the most out of exenv.

Installation

To install exenv, you can use the following commands:

git clone https://github.com/mururu/exenv.git ~/.exenv echo 'export EXENV_ROOT="$HOME/.exenv"' >> ~/.bash_profile echo 'export PATH="$EXENV_ROOT/bin:$PATH"' >> ~/.bash_profile echo 'eval "$(exenv init -)"' >> ~/.bash_profile git clone https://github.com/mururu/elixir-build.git ~/.exenv/plugins/elixir-build 

Basic Commands

Here are some basic commands to get you started with exenv:

Install a new Elixir version

exenv install 1.12.3

Show all available Elixir versions

exenv install -l

Show all installed Elixir versions

exenv versions

Set the global Elixir version

exenv global 1.12.3

Set the local Elixir version for a project

exenv local 1.11.4

Uninstall an Elixir version

exenv uninstall 1.11.4

Rehash shims

After installing new versions or plugins, use the rehash command:

exenv rehash

Advanced Commands

Explore more advanced commands for a better workflow:

Diagnose issues with shims

exenv doctor

Detox an Elixir environment

exenv detox

Prune old Elixir versions

exenv prune

Example Application Using exenv

The following is an example application setup using exenv:

Step 1: Create a new Phoenix project

mix phx.new my_app

Step 2: Navigate into the project directory

cd my_app

Step 3: Set the local Elixir version for the project

exenv local 1.12.3

Step 4: Install dependencies

mix deps.get

Step 5: Start the Phoenix server

mix phx.server

By following these steps, you can ensure that your Phoenix application is running with the specified Elixir version managed by exenv.

Hash: abc44f392a873b47d6f9df619458af18043b7da77919877cad0ca6aba2545bbc

Leave a Reply

Your email address will not be published. Required fields are marked *