Open skull-squadron opened 1 year ago
@@ -55,9 +55,9 @@ defmodule IElixir.HMAC do
end
def handle_call({:compute_sig, parts}, _from, state = {algo, key}) do
ctx = Enum.reduce(parts,
- :crypto.hmac_init(algo, key),
- &:crypto.hmac_update(&2, &1))
- |> :crypto.hmac_final()
+ :crypto.mac_init(:hmac, algo, key),
+ &:crypto.mac_update(&2, &1))
+ |> :crypto.mac_final()
hex = for <<h :: size(4), l :: size(4) <- ctx>>, into: <<>>, do: <<to_hex_char(h), to_hex_char(l)>>
{:reply, hex, state}
end
and
defp eval_forms(forms, binding, e) do
+ {ex_vars, erl_vars, erl_binding} = :elixir_erl_var.load_binding(binding,false)
+ e2 = :elixir_env.with_vars(e, ex_vars)
+ ex_s = :elixir_env.env_to_ex(e2)
+ erl_s = :elixir_erl_var.from_env(e2,erl_vars)
+
:elixir.eval_forms(forms, binding, e)
- |> Tuple.append(:elixir_env.env_to_scope(e))
+ |> Tuple.append({ex_s,erl_s})
end
Wil get you closer, you you also need to redo
try do
- {{result, binding, env, scope}, stdout, stderr} =
+ {{ {result, binding, env, scope}, diagnostics}, stdout, stderr} =
CaptureIO.capture do
{:ok, quoted} = Code.string_to_quoted(request["code"])
- eval_forms(quoted, state.binding, state.env, state.scope)
+ Code.with_diagnostics([log: true],
+
+ fn ->
+try do
+ {:ok, eval_forms(quoted, state.binding, state.env, state.scope)}
+rescue
+err -> {:error, err}
+end
+end ) |> case do
+{{:ok,r},d} -> {r,d}
+{{:error,e},d} -> throw {:diagnostics, e, d}
+end
end
to catch diagnostics or you won't get any usable warning messages when running nodes in ielixir on newer OTP versions.
MCE
``` git clone --depth 1 https://github.com/pprzetacznik/IElixir cd IElixir patch -Np1 <<'PATCH' diff --git a/mix.exs b/mix.exs index f0cdc60..76cf7a4 100644 --- a/mix.exs +++ b/mix.exs @@ -29,7 +29,7 @@ defmodule IElixir.Mixfile do end def application do - [mod: {IElixir, []}, applications: [:logger, :iex, :ecto, :erlzmq, :poison, :uuid, :floki]] + [mod: {IElixir, []}, applications: [:logger, :iex, :ecto, :sqlite_ecto2, :erlzmq, :poison, :uuid, :floki]] end defp deps do @@ -37,7 +37,7 @@ defmodule IElixir.Mixfile do {:erlzmq, "~> 3.0"}, {:floki, "~> 0.29.0"}, {:poison, "~> 3.0"}, - {:uuid_erl, "~> 1.7.5", app: false}, + {:uuid, "~> 1.7.5", [hex: :uuid_erl]}, {:sqlite_ecto2, "~> 2.4.0"}, # Docs dependencies @@ -46,6 +46,10 @@ defmodule IElixir.Mixfile do {:inch_ex, "~> 2.0.0", only: :docs}, # Test dependencies + # TODO: Remove when the following PR is merged & released: + # https://github.com/deadtrickster/ssl_verify_fun.erl/pull/27 + {:ssl_verify_fun, "~> 1.1", + manager: :rebar3, only: [:test], runtime: false, override: true}, {:excoveralls, "~> 0.13.3", only: :test} ] end PATCH mix deps.get env CFLAGS="-I$(brew --prefix zeromq)/include" LDFLAGS="-L$(brew --prefix zeromq)/lib" mix ecto.migrate -r IElixir.Repo env CFLAGS="-I$(brew --prefix zeromq)/include" LDFLAGS="-L$(brew --prefix zeromq)/lib" mix test ```Console
``` 023-08-08 21:24:59.509 [debug] Initializing control agent on url: tcp://127.0.0.1:42483 2023-08-08 21:24:59.522 [notice] Application ielixir exited: IElixir.start(:normal, []) returned an error: shutdown: failed to start child: IElixir.Sandbox ** (EXIT) an exception was raised: ** (UndefinedFunctionError) function :elixir_env.env_to_scope/1 is undefined or private (elixir 1.15.4) :elixir_env.env_to_scope(#Macro.Env