7
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Elixirでmixコマンドでライブラリを追加する【npm install/pip installをやりたい】

7
Posted at

はじめに

Elixirはmixコマンドを使用したエコシステムが充実しているのですが、Pythonのpip installやnodejsのnpm installみたいにCLIからプロジェクトにライブラリを追加することができません。

mix.exsをエディタで編集すれば良いのですが、iex内で新たなライブラリを試したい場合などに、ライブラリのバージョンを記述する必要があり、お手軽感が薄れてしまいます。

mix.exsの中で、ライブラリの依存関係を記述するdepsセクションは単なるjsonやyamlではなく、リストを返す関数なので、シェルスクリプトなどでのパースや編集が難しい特徴があります。

mix_deps_add

そこで今回は、CLIでライブラリ追加が可能になるmixのプラグインmix_deps_addをご紹介します。

インストール

mix archive.install https://github.com/bryanstearns/mix_deps_add/releases/download/0.1.3/mix_deps_add-0.1.3.ez

使い方

以下は、poisonとmojiexをプロジェクトに追加する例になります。

mix deps.add poison mojiex

mix deps.getをお忘れなく!

注意点

以下のような問題点があるので、ライブラリを試用する場合にとどめるのが良いと思います。

  • 最新バージョンのライブラリしか読み込まれない。
  • mix.exsdepsに書いたコメント欄が保持されない。
  • git:の依存関係が使用できない

あとがき

9月7日に小倉場で正式なExixir Conferenceである、「ElixirConfJP 2019 小倉城 be simple, fast & reliable」が開催されます!
 スポンサー枠、来賓枠で公募の枠が少ないのですが、まだ空きがありますので、ご興味がある方はお早めにいかがでしょうか。
fukuoka.exのメンバーも万全の応援体制で挑みます。

7
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
7
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?