Exrm(Elixir Release Manager)を使ったリリースでエラーが出た時の対処法
最近Elixirを勉強中だけど、ビルド周りで少しハマったのでメモ。
現象
Exrmを導入した状態で「mix release」コマンドを実行してElixirのアプリをビルドしようとしたところ、「(CaseClauseError) no case clause matching: :eacces」というエラーが発生した。
% MIX_ENV=prod mix release : ** (CaseClauseError) no case clause matching: :eacces lib/exrm/utils/utils.ex:110: ReleaseManager.Utils.relx/5 lib/mix/tasks/release.ex:339: anonymous fn/4 in Mix.Tasks.Release.do_release/1 lib/ex_unit/capture_io.ex:146: ExUnit.CaptureIO.do_capture_io/2 lib/ex_unit/capture_io.ex:119: ExUnit.CaptureIO.do_capture_io/3 lib/mix/tasks/release.ex:338: Mix.Tasks.Release.do_release/1 lib/mix/tasks/release.ex:78: Mix.Tasks.Release.do_run/1 (mix) lib/mix/task.ex:294: Mix.Task.run_task/3 (mix) lib/mix/cli.ex:58: Mix.CLI.run_task/2
対処法
調べたところ、とりあえずsudoをつけることで解決することが判明。
mix release fails with 'no case clause matching: :eacces' · Issue #401 · bitwalker/exrm · GitHub
% sudo MIX_ENV=prod mix release ==> The release for sample-app-0.0.1 is ready! ==> You can boot a console running your release with `$ rel/sample-app/bin/sample-app console`
別の対処
Exrmの代わりにdistilleryを使う。
release.initが事前に必要になるが、sudoをわざわざ付ける必要はなくなる。
% MIX_ENV=prod mix release.init An example config file has been placed in rel/config.exs, review it, make edits as needed/desired, and then run `mix release` to build the release % MIX_ENV=prod mix release ==> Assembling release.. ==> Building release sample-app:0.0.1 using environment prod ==> Including ERTS 8.2.2 from /usr/local/Cellar/erlang/19.2.3/lib/erlang/erts-8.2.2 ==> Packaging release.. ==> Release successfully built! You can run it in one of the following ways:[f:id:matsnow:20170314011357p:plain] Interactive: _build/prod/rel/sample-app/bin/sample-app console Foreground: _build/prod/rel/sample-app/bin/sample-app foreground Daemon: _build/prod/rel/sample-app/bin/sample-app start