bmitc

bmitc

Erlang "init terminating in do_boot" error when calling Elixir from .NET

Hello! I am working on something where I am trying to pass data between .NET, namely F#, and Elixir through the command line. On Windows, I am getting a strange error that I can’t figure out.

Here is my F# function:

let executeProcess name arguments =
    let startInfo = System.Diagnostics.ProcessStartInfo(
        FileName = name,
        Arguments = arguments,
        UseShellExecute = false,
        RedirectStandardError = true,
        RedirectStandardOutput = true
    )
    use p = new System.Diagnostics.Process(StartInfo = startInfo)
    p.Start() |> printfn "Successfull?: %A"
    p.WaitForExit()
    p.StandardOutput.ReadToEnd()

On Ubuntu, this works without issue (you can try by copy and pasting this into a dotnet fsi session after downloading the latest .NET SDK or you can try it in a Polyglot Notebook in VS Code, which requires no install I believe as it installs F# for you):

$ dotnet fsi

Microsoft (R) F# Interactive version 12.4.0.0 for F# 7.0
Copyright (c) Microsoft Corporation. All Rights Reserved.

For help type #help;;

> <copy and paste above function>;;
val executeProcess: name: string -> arguments: string -> string

> executeProcess "dotnet" "--version";;
Successfull?: true
val it: string = "7.0.101
"

> executeProcess "elixir" "--version";;
Successfull?: true
val it: string =
  "Erlang/OTP 25 [erts-13.1.4] [source] [64-bit] [smp:20:20] [ds:20:20:10] [async-threads:1] [jit:ns]

Elixir 1.14.3 (compiled with Erlang/OTP 25)
"

>

However, on Windows, I get a strange Erlang init error but notice that Elixir works just fine on the command line:

PS > elixir.bat --version
Erlang/OTP 25 [erts-13.0.4] [source] [64-bit] [smp:20:20] [ds:20:20:10] [async-threads:1] [jit:ns]

Elixir 1.14.2 (compiled with Erlang/OTP 25)
PS > dotnet fsi

Microsoft (R) F# Interactive version 12.8.0.0 for F# 8.0
Copyright (c) Microsoft Corporation. All Rights Reserved.

For help type #help;;

> <copy and paste above command>;;
val executeProcess: name: string -> arguments: string -> string

> executeProcess "dotnet" "--version";;
Successfull?: true
val it: string = "8.0.100-preview.6.23330.14
"

> executeProcess "elixir.bat" "--version";;
Successfull?: true
val it: string =
  "{"init terminating in do_boot",{undef,[{elixir,start_cli,[],[]},{init,start_em,1,[{file,"init.erl"},{line,1220}]},{init,do_boot,3,[{file,"init.erl"},{line,910}]}]}}
"

This is where I get this weird error of {"init terminating in do_boot",{undef,[{elixir,start_cli,[],[]},{init,start_em,1,[{file,"init.erl"},{line,1220}]},{init,do_boot,3,[{file,"init.erl"},{line,910}]}]}}. Searching and even looking up the line numbers in init.erl, this error seems to be because of Erlang version issues. However, that is not an issue on my machine. Elixir and Erlang via iex and erl work just fine, as does elixir.bat --version from the command line.

There seems to be something in how the .NET process launcher is interacting with the Elixir.bat that one or the other doesn’t like. Does anyone know what’s going on here? Is this an issue with elixir.bat on Windows?

(Note: There is a workaround, and it is to actually make the filename "powershell" with arguments "elixir --version". However, I don’t know why that works and the other doesn’t. The Elixir binaries/scripts are in my path, as are the Erlang binaries.)


Edit: I went ahead and tried this on the latest versions of Elixir 1.15.4 and Erlang/OTP 26. The Erlang "init terminated in do_boot" error seems to have gone away, but nothing is written to standard out when running this code as above. However, if I remove the redirection from standard out and reading, I get the following error in FSI:

> let executeProcess name arguments =
-     let startInfo = System.Diagnostics.ProcessStartInfo(
-         FileName = name,
-         Arguments = arguments
-     )
-     use p = new System.Diagnostics.Process(StartInfo = startInfo)
-     p.Start() |> printfn "Successfull?: %A"
- ;;
val executeProcess: name: string -> arguments: string -> unit

> executeProcess "elixir.bat" "--version";;
Successfull?: true
val it: unit = ()

> Error! Failed to load module 'elixir' because it cannot be found. Make sure that the module name is correct and
that its .beam file is in the code path.

Runtime terminating during boot ({undef,[{init,start_it,1,[{_},{_}]},{init,start_em,1,[{_},{_}]},{init,do_boot,3,[{_},{_}]}]})

Crash dump is being written to: erl_crash.dump...done

First Post!

lud

lud

Did you install elixir from something that requires some environment from your shell, like asdf for instance?

Where Next?

Popular in Questions Top

sergio
In Ruby, I can go: User.find_by(email: "foobar@email.com").update(email: "hello@email.com") How can I do something similar in Elixir? ...
New
openscript
Hello! Sorry for this astonishing simple question, but I’m really stuck. I try to set up the intellij-elixir plugin, but I don’t know ho...
New
jononomo
I am trying to figure out how Mix knows whether the environment is test, dev, or prod -- where is this set? Thanks.
New
Kagamiiiii
Student &amp; New to elixir. Nice language. I want to convert a english character, e.g. “a”, which is stored in a variable, to it’s asci...
New
fireproofsocks
I’m working on defining a simple Ecto schema for a table (in PostGres), but I don’t see where I can define a column as NOT NULL. Conside...
New
sacepums
Hey guys. I'm new to elixir and im really stocked about it. But I ran into a bit of problem - I need to convert a date sting, for examp...
New
alice
Hey, Just curious what are the main benefits of Elixir compared to Clojure? When is Elixir more useful than Clojure and vice versa? Th...
New
fayddelight
I tried installing elixir 1.11.2 erlang 23.3.4 via asdf in my zsh shell. Enabled the versions locally and globally. When I list them ...
New
gonzofish
I’m currently trying to understand how to join three tables using Ecto. All the examples I’ve seen use 2, so maybe I’m just missing somet...
New
fireproofsocks
Forgive me if this is obvious, but how does one delete a database record WITHOUT selecting it first? https://hexdocs.pm/ecto/Ecto.Repo.h...
New

Other popular topics Top

shahryarjb
Hello, I get Persian date from my client and convert it to normal calendar like this: def jalali_string_to_miladi_english_number(persi...
New
sorentwo
Hello! tl;dr Announcing Oban, an Ecto based job processing library with a focus on reliability and historical observability. After spen...
977 41022 311
New
ycv005
I have followed this StackOverflow post to install the specific version of Erlang. And When I am running mix ecto.setup then getting fol...
New
malloryerik
Hi, this is for people who, like me, have had some friction using .html.heex templates in VSCode. The solution seems to be, in a hyphena...
New
Harrisonl
We have an ECS cluster with 4 services, where each task joins a single cluster, via discovery ECS discovery service. Currently when I de...
New
fireproofsocks
I’m working on defining a simple Ecto schema for a table (in PostGres), but I don’t see where I can define a column as NOT NULL. Conside...
New
chrismccord
This release brings a number of exciting features, including integration with the new Phoenix LiveDashboard and Phoenix LiveView. There h...
New
vonH
When I run the Plug and I recompile I wind up having to use Ctrl C to quit iex and start again. Witht the help of rlwrap I can use the cu...
New
WestKeys
Currently suffering from paralysis by [HTTP client] analysis. This is rather unusual in Elixirland as there tends to be consensus on the ...
New
belgoros
I’m not a pro in using Regex and can’t figure out why the following behaviour happens, especially if we take into account the difference ...
New

We're in Beta

About us Mission Statement