Executing rebar3 throwing escript exception

105 views Asked by At

Environment:

1. Ubuntu 20.04.6 LTS
2. Erlang/OTP 22 [erts-10.6.4] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] 
Eshell V10.6.4
3. Erlang/OTP 22 [erts-10.6.4] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] 
Elixir 1.9.1 (compiled with Erlang/OTP 22)

Exception:

escript: exception error: undefined function rebar3:main/1
in function  escript:run/2 (escript.erl, line 758)
in call from escript:start/1 (escript.erl, line 277)
in call from init:start_em/1 
in call from init:do_boot/3

See the answer for more details.

1

There are 1 answers

0
AlexH On BEST ANSWER

[Solved] Installing from the source erlang, rebar3.

Steps:

  1. sudo apt-get purge erlang elixir
  2. sudo apt autoremove
  3. Remove rebar3, erlang, and elixir related files if any.
  4. Download Erlang.
  5. Unzip it.
  6. Go to unziped folder.
  7. Execute: sudo su -
  8. Execute: ./configure && make && make install
  9. Download rebar3, and make sure it supports OTP-{your_version}
  10. chmod u+x rebar3
  11. ./rebar3 local install
  12. mv rebar3 /usr/local/bin/
  13. Execute rebar3 --version from any dir.

From what I see, the root causes are in bold.

  1. Lack of privileges.
meaning
sudo su -
./configure && make && make install

and
sudo ./configure && make && make install
is not the same.
  1. Version compatibilities.