Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Installing dependencies in Elixir

Is there a way to install a dependency for an Elixir project directly through the command line using mix or mix hex?

I am aware of the option for searching the hex registry via

$ mix hex.search httpoison  Package    Version  URL httpoison  0.11.0   https://hex.pm/packages/httpoison 

However, I am looking for something like

$ mix hex.install httpoison 

which will modify my mix.exs file, adding the name and most recent version of the dependency to the deps function and the application name to the applications list and then run

$ mix deps.get 

to pull and compile the dependency.

like image 375
Daniel Corin Avatar asked Aug 12 '15 03:08

Daniel Corin


People also ask

How do I install hex Elixir?

Elixir provides an installer you can use to install Elixir and its prerequisites. Just run the installer and it will put everything where it needs to be. The installer can be downloaded from https://repo.hex.pm/elixir-websetup.exe.

What does mix DEPS get do?

get (Mix v1. 12.3) Gets all out of date dependencies, i.e. dependencies that are not available or have an invalid lock.


1 Answers

It sounds like you are looking for something similar to npm install --save. This feature does not exist in mix. You can install something the usual way by adding it to mix.exs and running mix deps.get as you mention.

The other way you may wish to install certain applications is via a mix archive allowing this mix task to be run globally. One example of this is phoenix.new for creating new phoenix applications which can be installed by running:

mix archive.install https://github.com/phoenixframework/phoenix/releases/download/v0.16.1/phoenix_new-0.16.1.ez 
like image 139
Gazler Avatar answered Sep 23 '22 22:09

Gazler