** (UndefinedFunctionError) function :elixir_env.env_to_scope/1 is undefined or private
skull-squadron opened this issue · 1 comments
skull-squadron commented
- elixir: 1.15.4
- erlang: 26.0.2
- os: macOS 13.5 m1
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<aliases: [], context: nil, context_modules: [], file: "nofile", function: nil, functions: [{Kernel, [!=: 2, !==: 2, *: 2, **: 2, +: 1, +: 2, ++: 2, -: 1, -: 2, --: 2, /: 2, <: 2, <=: 2, ==: 2, ===: 2, =~: 2, >: 2, >=: 2, abs: 1, apply: 2, apply: 3, binary_part: 3, binary_slice: 2, binary_slice: 3, bit_size: 1, byte_size: 1, ceil: 1, div: 2, elem: 2, exit: 1, floor: 1, function_exported?: 3, get_and_update_in: 3, get_in: 2, hd: 1, inspect: 1, inspect: 2, is_atom: 1, is_binary: 1, is_bitstring: 1, is_boolean: 1, ...]}], lexical_tracker: nil, line: 1, macro_aliases: [], macros: [{Kernel, [!: 1, &&: 2, ..: 0, ..: 2, ..//: 3, <>: 2, @: 1, alias!: 1, and: 2, binding: 0, binding: 1, dbg: 0, dbg: 1, dbg: 2, def: 1, def: 2, defdelegate: 2, defexception: 1, defguard: 1, defguardp: 1, defimpl: 2, defimpl: 3, defmacro: 1, defmacro: 2, defmacrop: 1, defmacrop: 2, defmodule: 2, defoverridable: 1, defp: 1, defp: 2, defprotocol: 2, defstruct: 1, destructure: 2, get_and_update_in: 2, if: 2, in: 2, is_exception: 1, ...]}], module: nil, requires: [Application, Kernel, Kernel.Typespec], ...>)
(ielixir 0.9.21) lib/ielixir/sandbox.ex:313: IElixir.Sandbox.eval_forms/3
(ielixir 0.9.21) lib/ielixir/sandbox.ex:263: IElixir.Sandbox.prepare_clear_state/0
(ielixir 0.9.21) lib/ielixir/sandbox.ex:40: IElixir.Sandbox.init/1
(stdlib 5.0.2) gen_server.erl:962: :gen_server.init_it/2
(stdlib 5.0.2) gen_server.erl:917: :gen_server.init_it/6
(stdlib 5.0.2) proc_lib.erl:241: :proc_lib.init_p_do_apply/3
2023-08-08 21:24:59.531 [notice] Application floki exited: :stopped
2023-08-08 21:24:59.531 [notice] Application html_entities exited: :stopped
2023-08-08 21:24:59.531 [notice] Application uuid exited: :stopped
2023-08-08 21:24:59.531 [notice] Application quickrand exited: :stopped
2023-08-08 21:24:59.531 [notice] Application erlzmq exited: :stopped
2023-08-08 21:24:59.531 [notice] Application sqlite_ecto2 exited: :stopped
2023-08-08 21:24:59.531 [notice] Application sqlitex exited: :stopped
2023-08-08 21:24:59.531 [notice] Application esqlite exited: :stopped
2023-08-08 21:24:59.532 [notice] Application sbroker exited: :stopped
2023-08-08 21:24:59.532 [notice] Application sasl exited: :stopped
2023-08-08 21:24:59.532 [notice] Application poison exited: :stopped
2023-08-08 21:24:59.532 [notice] Application db_connection exited: :stopped
2023-08-08 21:24:59.532 [notice] Application connection exited: :stopped
2023-08-08 21:24:59.532 [notice] Application ecto exited: :stopped
2023-08-08 21:24:59.532 [notice] Application poolboy exited: :stopped
2023-08-08 21:24:59.532 [notice] Application decimal exited: :stopped
2023-08-08 21:24:59.533 [notice] Application iex exited: :stopped
** (Mix) Could not start application ielixir: 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<aliases: [], context: nil, context_modules: [], file: "nofile", function: nil, functions: [{Kernel, [!=: 2, !==: 2, *: 2, **: 2, +: 1, +: 2, ++: 2, -: 1, -: 2, --: 2, /: 2, <: 2, <=: 2, ==: 2, ===: 2, =~: 2, >: 2, >=: 2, abs: 1, apply: 2, apply: 3, binary_part: 3, binary_slice: 2, binary_slice: 3, bit_size: 1, byte_size: 1, ceil: 1, div: 2, elem: 2, exit: 1, floor: 1, function_exported?: 3, get_and_update_in: 3, get_in: 2, hd: 1, inspect: 1, inspect: 2, is_atom: 1, is_binary: 1, is_bitstring: 1, is_boolean: 1, ...]}], lexical_tracker: nil, line: 1, macro_aliases: [], macros: [{Kernel, [!: 1, &&: 2, ..: 0, ..: 2, ..//: 3, <>: 2, @: 1, alias!: 1, and: 2, binding: 0, binding: 1, dbg: 0, dbg: 1, dbg: 2, def: 1, def: 2, defdelegate: 2, defexception: 1, defguard: 1, defguardp: 1, defimpl: 2, defimpl: 3, defmacro: 1, defmacro: 2, defmacrop: 1, defmacrop: 2, defmodule: 2, defoverridable: 1, defp: 1, defp: 2, defprotocol: 2, defstruct: 1, destructure: 2, get_and_update_in: 2, if: 2, in: 2, is_exception: 1, ...]}], module: nil, requires: [Application, Kernel, Kernel.Typespec], ...>)
(ielixir 0.9.21) lib/ielixir/sandbox.ex:313: IElixir.Sandbox.eval_forms/3
(ielixir 0.9.21) lib/ielixir/sandbox.ex:263: IElixir.Sandbox.prepare_clear_state/0
(ielixir 0.9.21) lib/ielixir/sandbox.ex:40: IElixir.Sandbox.init/1
(stdlib 5.0.2) gen_server.erl:962: :gen_server.init_it/2
(stdlib 5.0.2) gen_server.erl:917: :gen_server.init_it/6
(stdlib 5.0.2) proc_lib.erl:241: :proc_lib.init_p_do_apply/3
noizu commented
@@ -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.