goofansu.com

Use Elixir packages in CodeRunner 2

After install Elixir syntax according to Use Elixir in CodeRunner 2, it works great. But it needs additional work to use external packages such as gen_stage.

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

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!