Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release failed: no match of right hand side value: {:error, :eacces} #749

Open
KoeusIss opened this issue Mar 2, 2023 · 3 comments
Open

Comments

@KoeusIss
Copy link

KoeusIss commented Mar 2, 2023

Steps to reproduce

$ mix phx.new --no-ecto phoenix_distillery
$ cd phoenix_distillery

# mix.exs
defp deps do
    [ ...,
     {:distillery, "~> 2.0"},
      ...,
    ]
  end

$ mix deps.get --only prod
$ MIX_ENV=prod mix compile
$ npm run deploy --prefix assets
$ mix phx.digest

$ mix distillery.init

$ MIX_ENV=prod mix distillery.release

Just a brief list of the steps required to produce the issue.

Verbose Logs

Paste the output of the release command you ran with the --verbose flag
below in the summary tags (this helps keep the issue easy to navigate):

Generated phoenix_distillery app
==> Assembling release..
==> Building release phoenix_distillery:0.1.0 using environment prod
==> Including ERTS 13.1.4 from /opt/homebrew/Cellar/erlang/25.2.2/lib/erlang/erts-13.1.4
==> Release failed: no match of right hand side value: {:error, :eacces}
@gazzer82
Copy link

Same problem here, did you manage to resolve it? I turned on Verbose logging and no more useful hints I can see. Release on it's own seems to work fine.

@miklblitz
Copy link

miklblitz commented Apr 5, 2023

somewhere in the Internet i found decision:

fix error: Release failed: no match of right hand side value: {:error, :eacces}

--- 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

and it works for me (dont forget remove _build folder after fixes)

montebrown added a commit to montebrown/distillery that referenced this issue Jul 2, 2023
For OTP 25 distillery was failing at the 'archive' step with: 

     ==> Failed to archive release: _build/prod/rel/osnap/releases/RELEASES: no such file or directory

See bitwalker#749
@wschroeder
Copy link

Explanation of the above patch, as I just went through this process and made my own version of it before I found this issue:

--- a/lib/distillery/releases/assembler.ex
+++ b/lib/distillery/releases/assembler.ex
@@ -860,7 +860,11 @@ 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(
+      './' |> Path.absname() |> String.to_charlist(),
+      'releases' |> Path.absname() |> String.to_charlist(),
+      '#{relfile}',
+      [])
     File.cd!(old_cwd)
     :ok
   end

It turns out that the root cause is that

:release_handler.create_RELEASES('./', 'releases', '#{relfile}', [])

ultimately resulted in a call to :release_handler's

root_dir_relative_path(Pathname) ->
    case filename:pathtype(Pathname) of
        relative ->
            filename:join(code:root_dir(), Pathname);
        _ ->
            Pathname
    end.

That code:root_dir() reaches out to the Erlang release's root directory, which makes no sense for our purposes. In one of my environments, this was a readonly /nix path. The file writing in :release_handler fails to open the missing joined path:

do_write_file(File1, Str, FileOpts) ->
    File = root_dir_relative_path(File1),
    case file:open(File, [write | FileOpts]) of
	{ok, Fd} ->
	    io:put_chars(Fd, Str),
	    ok = file:close(Fd);
	{error, Reason} ->
	    {error, {Reason, File}}
    end.

We have to use an absolute path instead of a relative path to avoid the relative fork and reach the expected RELEASE file directory.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants