goofansu.com

2019/07/18

Use Elixir packages in CodeRunner 2

After install Elixir syntax according to Use Elixir in CodeRunner 2, it works great. Now I want to use gen_stage which is not an Elixir built-in package, It needs additional work to make it available.

Steps

Create elixir_packages directory, clone and compile gen_stage package:

mkdir $HOME/src/elixir_packages
cd $HOME/src/elixir_packages
git clone elixir-lang/gen_stage
cd gen_stage
mix compile

In CodeRunner Preferences → Languages → Elixir, config the "Run Command" as:

elixir -pa "$HOME/src/elixir_packages/**/ebin" $filename

Check it works

We can verify by the rate_limiter example from gen_stage repo.

Result


Update: 2019-07-23

I found it is easier to maintain deps in a mix project instead of clone packages.

Create elixir_packages project

cd $HOME/src
mix new elixir_packages

Add gen_stage in deps

defp deps do
  [
    {:gen_stage, "~> 0.14"}
  ]
end

Compile it

mix do deps.get, compile

In CodeRunner Preferences → Languages → Elixir, config the "Run Command" as:

elixir -pa "$HOME/src/elixir_packages/_build/dev/lib/**/ebin" $filename

Settings

Enjoy!