bitwalker / distillery

Simplify deployments in Elixir with OTP releases!
MIT License
2.96k stars 396 forks source link

THIS LIBRARY IS NOT COMPATIBLE WITH ERLANG/OTP 25 #744

Open roychowdhuryrohit-dev opened 2 years ago

roychowdhuryrohit-dev commented 2 years ago

Steps to reproduce

Producing a release using Distillery shows error.

Verbose Logs

Screenshot 2022-05-26 at 20 36 07

Description of issue

brooksmtownsend commented 2 years ago

Getting this as well, which makes our MacOS builds that install via brew (and brew doesn't let you downgrade versions, ugh) unusable

Just wanted to echo that I'm running into this too for https://github.com/wasmCloud/wasmcloud-otp/pull/409, and would be happy to help test a fix

cc @bitwalker / @mobileoverlord since this issue has been open for a bit

narrowtux commented 2 years ago

@brooksmtownsend this is off-topic, but I can recommend using asdf for managing developer dependencies where you can pin on the exact version you need, per project even.

brooksmtownsend commented 2 years ago

@narrowtux Yeah asdf is pretty fantastic and what I ended up falling back to, the reason I preferred brew was simply for the speed of installation in CI builds

ziyouchutuwenwu commented 1 year ago

similar for me

MIX_ENV=prod mix distillery.release

output

MIX_ENV=prod mix distillery.release                       
Generated demo app
==> Assembling release..
==> Building release demo:0.1.0 using environment prod
==> Including ERTS 13.0.3 from /usr/lib/erlang/erts-13.0.3
==> Release failed: no match of right hand side value: {:error, :eacces}
    (distillery 2.1.1) lib/distillery/releases/assembler.ex:863: Distillery.Releases.Assembler.create_RELEASES/2
    (distillery 2.1.1) lib/distillery/releases/assembler.ex:290: Distillery.Releases.Assembler.write_release_scripts/1
    (distillery 2.1.1) lib/distillery/releases/assembler.ex:50: Distillery.Releases.Assembler.assemble/1
    (distillery 2.1.1) lib/distillery/tasks/release.ex:130: Mix.Tasks.Distillery.Release.do_release/2
    (mix 1.13.2) lib/mix/task.ex:397: anonymous fn/3 in Mix.Task.run_task/3
    (mix 1.13.2) lib/mix/cli.ex:84: Mix.CLI.run_task/2
    (elixir 1.13.2) src/elixir_compiler.erl:73: :elixir_compiler.dispatch/4
    (elixir 1.13.2) src/elixir_compiler.erl:58: :elixir_compiler.compile/3
randysecrist commented 1 year ago

Also seeing this;

==> Including ERTS 13.0.4 from /opt/homebrew/Cellar/erlang/25.0.4/lib/erlang/erts-13.0.4
==> Release failed: no match of right hand side value: {:error, :eacces}
    (distillery 2.1.1) lib/distillery/releases/assembler.ex:863: Distillery.Releases.Assembler.create_RELEASES/2
    (distillery 2.1.1) lib/distillery/releases/assembler.ex:290: Distillery.Releases.Assembler.write_release_scripts/1
    (distillery 2.1.1) lib/distillery/releases/assembler.ex:50: Distillery.Releases.Assembler.assemble/1
    (distillery 2.1.1) lib/distillery/tasks/release.ex:130: Mix.Tasks.Distillery.Release.do_release/2
    (mix 1.13.4) lib/mix/task.ex:397: anonymous fn/3 in Mix.Task.run_task/3
    (mix 1.13.4) lib/mix/cli.ex:84: Mix.CLI.run_task/2
    (elixir 1.13.4) src/elixir_compiler.erl:73: :elixir_compiler.dispatch/4
    (elixir 1.13.4) src/elixir_compiler.erl:58: :elixir_compiler.compile/3
andyleclair commented 1 year ago

+1 here

cplotter commented 1 year ago

+1

tensor-programming commented 1 year ago

same, it seems to be due to the changes to the release handler in erlang otp 25.

carflynn2009 commented 1 year ago

Same issue here

erlang - 25.0.4 elixir - 1.14.0-otp-25 OS - MacOS

Downgrading is not an option for me as we need the latest version of Elixir

==> Assembling release..
==> Building release management_portal_umbrella:0.1.0 using environment prod
==> Including ERTS 13.0.4 from /Users/carlflynn/.asdf/installs/erlang/25.0.4/erts-13.0.4
==> Packaging release..
==> Failed to archive release: _build/prod/rel/management_portal_umbrella/releases/RELEASES: no such file or directory
lkananowicz commented 1 year ago

+1

austinsalonen commented 1 year ago
--- a/lib/distillery/releases/assembler.ex
+++ b/lib/distillery/releases/assembler.ex
@@ -860,7 +860,7 @@ defmodule Distillery.Releases.Assembler do
     # no work around for this
     old_cwd = File.cwd!()
     File.cd!(output_dir)
-    :ok = :release_handler.create_RELEASES('./', 'releases', '#{relfile}', [])
+    :ok = :release_handler.create_RELEASES(File.cwd!(), Path.join([File.cwd!(), 'releases']), '#{relfile}', [])
     File.cd!(old_cwd)
     :ok
   end

I have a local fork that works with just this change within lib/ so if you use a git dependency in your mix file, you can use your own fork with this change.

Getting the tests to run has been a challenge and required quite a few changes. I had to comment out the cookie tests because I couldn't hit quvic.com from behind a firewall. Also, the "directory with space in name" wouldn't work for me so I just removed it.

If I can find the time to run tests across several versions of Elixir & OTP, I'll submit a MR. If someone else submits this fix based on this post, thanks!

Tested with Elixir 1.12.3 & 1.13.4 + Erlang 25.0.4.

MichaelSzer commented 1 year ago

==> Assembling release.. ==> Building release phoenix_sample:0.1.0 using environment prod ==> Including ERTS 13.1.2 from /home/miguel/.asdf/installs/erlang/25.1.2/erts-13.1.2 ==> Packaging release.. ==> Failed to archive release: _build/prod/rel/phoenix_sample/releases/RELEASES: no such file or directory

Using {:distillery, "~> 2.1"} and {:phoenix, "~> 1.6.15"}

zazaian commented 1 year ago

==> Assembling release.. ==> Building release phoenix_sample:0.1.0 using environment prod ==> Including ERTS 13.1.2 from /home/miguel/.asdf/installs/erlang/25.1.2/erts-13.1.2 ==> Packaging release.. ==> Failed to archive release: _build/prod/rel/phoenix_sample/releases/RELEASES: no such file or directory

Using {:distillery, "~> 2.1"} and {:phoenix, "~> 1.6.15"}

@carflynn2009 @MichaelSzer I would recommend simply adding the RELEASES directory inside of _build/prod/rel/phoenix_sample/releases. This worked for me on my local development environment. It doesn't seem like this is generated by default.

Lucian-Bosinceanu commented 8 months ago

This has fixed the distillery issue for me when upgrading to Elixir 1.15.4 and OTP 26: https://github.com/bors-ng/bors-ng/pull/1561

However, the remote-console command ended up crashing with this error:

=CRASH REPORT==== 5-Oct-2023::18:34:46.165601 ===
  crasher:
    initial call: supervisor_bridge:user_sup/1
    pid: <0.3882.0>
    registered_name: []
    exception error: undefined function 'Elixir.IEx.CLI':start/0
      in function  user_sup:start_user/3 (user_sup.erl, line 102)
      in call from user_sup:init/1 (user_sup.erl, line 51)
      in call from supervisor_bridge:init/1 (supervisor_bridge.erl, line 87)
      in call from gen_server:init_it/2 (gen_server.erl, line 962)
      in call from gen_server:init_it/6 (gen_server.erl, line 917)
    ancestors: [kernel_sup,<0.3850.0>]

I was able to fix the above by adding exec before iex here: https://github.com/bitwalker/distillery/blob/3ab4d6146c7bc18139ed75d330e4fbb0fceb7591/priv/libexec/commands/remote_console.sh#L26

Hope this helps someone in need.

randysecrist commented 7 months ago

Has anyone seen this when using remote_console? If I read this right; it seems like Elixir.iEx.CLI is undefined - however it is part of the release and I can see its beams in the ebin dir within the release directory ...

OTP: 26.1 (only erts is installed as part of the release)
Elixir 1.15.7
2023-12-05 21:33:12.185235 crash_report
    initial_call: {supervisor_bridge,user_sup,['Argument__1']}
    pid: <0.71.0>
    registered_name: []
    error_info: {error,undef,[{'Elixir.IEx.CLI',start,[],[]},{user_sup,start_user,3,[{file,"user_sup.erl"},{line,102}]},{user_sup,init,1,[{file,"user_sup.erl"},{line,51}]},{supervisor_bridge,init,1,[{file,"supervisor_bridge.erl"},{line,87}]},{gen_server,init_it,2,[{file,"gen_server.erl"},{line,962}]},{gen_server,init_it,6,[{file,"gen_server.erl"},{line,917}]},{proc_lib,init_p_do_apply,3,[{file,"proc_lib.erl"},{line,241}]}]}
    ancestors: [kernel_sup,<0.47.0>]
    message_queue_len: 0
    messages: []
    links: [<0.49.0>]
    dictionary: []
    trap_exit: true
    status: running
    heap_size: 1598
    stack_size: 28
    reductions: 334
=SUPERVISOR REPORT==== 5-Dec-2023::21:33:12.185290 ===
    supervisor: {local,kernel_sup}
    errorContext: start_error
    reason: {undef,
                [{'Elixir.IEx.CLI',start,[],[]},
                 {user_sup,start_user,3,[{file,"user_sup.erl"},{line,102}]},
                 {user_sup,init,1,[{file,"user_sup.erl"},{line,51}]},
                 {supervisor_bridge,init,1,
                     [{file,"supervisor_bridge.erl"},{line,87}]},
                 {gen_server,init_it,2,[{file,"gen_server.erl"},{line,962}]},
                 {gen_server,init_it,6,[{file,"gen_server.erl"},{line,917}]},
                 {proc_lib,init_p_do_apply,3,
                     [{file,"proc_lib.erl"},{line,241}]}]}
    offender: [{pid,undefined},
               {id,user},
               {mfargs,{user_sup,start,[]}},
               {restart_type,temporary},
               {significant,false},
               {shutdown,2000},
               {child_type,supervisor}]
Lucian-Bosinceanu commented 7 months ago

@randysecrist I had the same problem, please see above.

randysecrist commented 7 months ago

@Lucian-Bosinceanu

I did try that; and it works great if a full install is available.

I am however using the set include_erts: true in the rel/config.exe .. thus iex isn't available directly; only erts. (small footprint required)

jweinkam commented 6 months ago

@randysecrist did you find a solution?

randysecrist commented 6 months ago

@jweinkam no, not when using a base image with only the release + erts (include_erts) copied into it. This used to work just fine with OTP 24. (i'm using 26 now; so it could be an issue not covered by this issue?)

jweinkam commented 6 months ago

@randysecrist We have been using OTP 25 and Elixir 1.14.1 with a forked version of this library. The only change is

+++ b/lib/distillery/releases/assembler.ex
@@ -860,15 +860,7 @@ defmodule Distillery.Releases.Assembler do
     # no work around for this
     old_cwd = File.cwd!()
     File.cd!(output_dir)
-    :ok = :release_handler.create_RELEASES('./', 'releases', '#{relfile}', [])
+
+    :ok =
+      :release_handler.create_RELEASES(
+        File.cwd!(),
+        Path.join([File.cwd!(), 'releases']),
+        '#{relfile}',
+        []
+      )
+
     File.cd!(old_cwd)
     :ok
   end

We are attempting to switch to Elixir 1.15.7, but then get error

   crasher:
    initial call: supervisor_bridge:user_sup/1
    pid: <0.4290.0>
    registered_name: []
    exception error: undefined function 'Elixir.IEx.CLI':start/0
      in function  user_sup:start_user/3 (user_sup.erl, line 100)
      in call from user_sup:init/1 (user_sup.erl, line 49)
      in call from supervisor_bridge:init/1 (supervisor_bridge.erl, line 87)
      in call from gen_server:init_it/2 (gen_server.erl, line 851)
      in call from gen_server:init_it/6 (gen_server.erl, line 814)
    ancestors: [kernel_sup,<0.4268.0>]
    message_queue_len: 0
    messages: []

We too are using set include_erts: true

randysecrist commented 6 months ago

@jweinkam my intuition tells me this is a problem with the erlang boot file -> I can see that the `Elixir.IEx.CLI' module is included in the release; but erlang crying about it being undefined means that it isn't in the beam path for some reason.

I spent a day learning more about releases ; so next step is to go back and try to figure out if I can find where this plugin is broken .. or if I'm going to just script the release myself.

This is going to take some time ; i'm on holiday in a bit as well.

randysecrist commented 5 months ago

So after a new year rest; and some poking - the problem is not that the module Elixir.IEx.CLI isn't on the code path ... it is that this value is passed to the -user switch when erl is invoked.

ref: https://hexdocs.pm/iex/1.15.7/IEx.html#module-the-user-switch-command

When I test with Elixir.IEx - this is what I see:


{{badmatch,{error,{kernel,{{shutdown,{failed_to_start_child,user,nouser}},
                           {kernel,start,[normal,[]]}}}}},
 [{'Elixir.IEx','-start/2-fun-3-',1,[{file,"lib/iex.ex"},{line,873}]}]}```
randysecrist commented 5 months ago

fixed this in my fork: https://github.com/bors-ng/distillery/commit/578f12b5770ddee3e9b0a04d4443581f0b0fd10a