Nitrogen failing to `make`, rebar failed

I’m going through the recent Nitrogen book and walking someone through the setup to teach them erlang with a brand new install and they are getting an interesting error when running make ... from a fresh git clone https://github.com/nitrogen/nitrogen.git:

❯ make slim_cowboy PROJECT=testnitro
make[1]: Entering directory '/home/<usr>/erlang/nitrogen'
./rebar get-deps
escript: exception error: undefined function rebar:main/1
  in function  escript:run/2 (escript.erl, line 750)
  in call from escript:start/1 (escript.erl, line 277)
  in call from init:start_em/1 
  in call from init:do_boot/3 
make[1]: *** [Makefile:40: get-deps] Error 127
make[1]: Leaving directory '/home/<user>/erlang/nitrogen'
make: *** [Makefile:83: slim_cowboy] Error 2

And having them run ./rebar returns the same issue:

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

I’m pretty sure I know their issue, but I’m curious if a better and more accurate error message could be provided to such a newbie to erlang?

For note, they grabbed the old rebar 2.6.4 and replaced the one in the nitrogen clone with it then it worked (thus we continued), but that seems wrong to do?

In addition, we had a later issue but we just added the base erlang to the path instead of a shim (via asdf env erl), but this also seems very wrong and unnecessary as any other erlang thing that I do and have ran works fine with asdf?

❯ ./bin/nitrogen console
Exec: /home/<user>.asdf/shims/../erts-13.0/bin/erlexec -boot_var RELTOOL_EXT_LIB /home/<user>/erlang/testnitro/lib -sasl releases_dir "/home/<user>/erlang/testnitro/releases" -boot /home/<user>/erlang/testnitro/releases/2.4.0/nitrogen -mode interactive  -config /home/<user>/erlang/testnitro/etc/app.config -config /home/<user>/erlang/testnitro/etc/simple_bridge.config -config /home/<user>/erlang/testnitro/etc/sync.config -args_file /home/<user>/erlang/testnitro/etc/vm.args -- console
Root: /home/<user>/.asdf/shims/..
./bin/nitrogen: 299: exec: /home/<user>/.asdf/shims/../erts-13.0/bin/erlexec: not found
1 Like

The latter issue seems odd as the bin/nitrogen script doesn’t seem to look even remotely close to any of my modern runner scripts generated by rebar3 or mix release or anything of the sort (all of which work fine), so I’m curious how this one is intended to work?

1 Like

This appears to be an issue related to erlang being installed via asdf:

2 Likes

Yeah, working around it with just sourcing the variables returned from asdf env erl fixes it, but it seems excessively odd that that is necessary as I run quite a hoard of BEAM things without issue otherwise?

1 Like

Yeah. I’m sure it’s just a relic of rebar2 and Nitrogen’s default pretty-custom directory structure (hence why it’s taking so long to get nitrogen converted to rebar3).

2 Likes