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
2 Likes

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?

2 Likes

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

3 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?

2 Likes

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).

3 Likes

Hello @OvermindDL1
I’m relatively a newbie, and I’ve just switched to using asdf to manage my Erlang versions. Every other thing is running fine like before, except that I’m getting this same error in Nitrogen.

Could you please elaborate on how to source those numerous variables returned by the asdf env erl command? Thanks.

I’ve tried source asdf env erl from the terminal and I now get this error:

/home/<user>/.asdf/bin/asdf:.:4: no such file or directory: ./lib/utils.bash
asdf_cmd:3: = not found

which I’m not sure of how to fix.

As of now I have to manually disable the asdf plugin from my ~/.zshrc file each time I switch to a project in nitrogen, which is not convenient.

2 Likes

I spent some time today working with asdf and have made changes to the start script for Nitrogen 2.0.

If you pull the latest master from nitrogen/nitrogen, the newly produced project will work with asdf.

If you want to update an existing project to support asdf, pull this script and replace the bin/nitrogen script in your project.

3 Likes

Oh thanks @gumm
Works like charm now. No more problems with Bossman (you know, no moss under that dude’s feet :smile:).

3 Likes

Wonderful! So glad to hear it.

3 Likes