Distillery - Symlink version directory to current

I’m trying to figure out the proper way to have a current directory that is symlinked to the versioned release directory, after the release has been deployed and extracted. I thought overlays would work but the documentation seems sparse here. I currently have:

release :reference_app do
  set version: "0.1.0"
  set applications: [
    :runtime_tools,
    site: :permanent
  ]
  set overlays: [
    {:link, "releases/<%= release_version %>", "releases/current"}
  ]

  plugin Conform.ReleasePlugin
end

But I get an error building the release saying:

==> Failed to archive release: _build/prod/rel/reference_app/releases/current: not a directory

You need {:link, "releases/current", "releases/<%= release_version %>"}. I’ll make sure I cover this better in the docs being released soon.

Thanks for the quick response. So the order is reversed from the ln command?

I got the following error after making the change.

==> Erlang error: {:overlay_failed, :file, {:eexist, {:link, "releases/current", "releases/<%= release_version %>"}}}:
    (stdlib) erl_anno.erl:375: :erl_anno.anno_info({1, 2, 17})
    (elixir) /usr/local/lib/erlang/lib/parsetools-2.1.5/include/yeccpre.hrl:149: :elixir_parser.yecctoken_location/1
    (elixir) /usr/local/lib/erlang/lib/parsetools-2.1.5/include/yeccpre.hrl:114: :elixir_parser.yeccpars1/7
    (elixir) /usr/local/lib/erlang/lib/parsetools-2.1.5/include/yeccpre.hrl:57: :elixir_parser.yeccpars0/5
    (elixir) src/elixir.erl:282: :elixir.string_to_quoted/4
    (elixir) src/elixir.erl:299: :elixir.string_to_quoted!/4
    (eex) lib/eex/compiler.ex:37: EEx.Compiler.generate_buffer/4
    (eex) lib/eex.ex:196: EEx.eval_string/3

You can think of it as {:link, source, target}, which is the same structure as ln -s source target.

Hmm, what version of Distillery? I’ll see if I can reproduce

mix.lock shows it’s version 1.5.2

Ok. I’m confused now. If it’s {:link, source, target} then it should be

{:link, "releases/<%= release_version %>", "releases/current"}

correct? Distillery is creating the releases/0.1.0 directory and I want a link called current that points to releases/0.1.0.

When I have it in this order I now get this error:

Failed to archive release: _build/prod/rel/reference_app/releases/current: no such file or directory

Which is odd since of course it doesn’t exist, distillery should be creating that link.

When I switch the order to what you originally posted: {:link, "releases/current", "releases/<%= release_version %>"} I get the stack trace:

==> Erlang error: {:overlay_failed, :file, {:eexist, {:link, "releases/current", "releases/<%= release_version %>"}}}:
    (stdlib) erl_anno.erl:375: :erl_anno.anno_info({1, 2, 17})
    (elixir) /usr/local/lib/erlang/lib/parsetools-2.1.5/include/yeccpre.hrl:149: :elixir_parser.yecctoken_location/1
    (elixir) /usr/local/lib/erlang/lib/parsetools-2.1.5/include/yeccpre.hrl:114: :elixir_parser.yeccpars1/7
    (elixir) /usr/local/lib/erlang/lib/parsetools-2.1.5/include/yeccpre.hrl:57: :elixir_parser.yeccpars0/5
    (elixir) src/elixir.erl:282: :elixir.string_to_quoted/4
    (elixir) src/elixir.erl:299: :elixir.string_to_quoted!/4
    (eex) lib/eex/compiler.ex:37: EEx.Compiler.generate_buffer/4
    (eex) lib/eex.ex:196: EEx.eval_string/3
2 Likes