rebar3 icon indicating copy to clipboard operation
rebar3 copied to clipboard

rebar3 installed with local install crashes if you attempt to set VSN variable

Open rlipscombe opened this issue 1 year ago • 1 comments

I've got a rebar.config.script that expects the VSN environment variable to be set, but rebar3 crashes if it is.

Reproduction

  1. Compile from source (I used main @2189a408d6c8ae239f730ca41a5ad3c651a90643), using ./bootstrap
  2. Install with ./rebar3 local install.
  3. Add $HOME/.cache/rebar3/bin to $PATH.
  4. Run VSN=1 rebar3; it crashes with init terminating in do_boot ({undef,[{rebar3,main,[],[]},{init,start_em,1,[]},{init,do_boot,3,[]}]})

Investigation

This is because rebar3 local install uses a wrapper script to locate the rebar3 files, and it uses the VSN environment variable to do that. Unless you specify a "valid" VSN (e.g. 3.19.0 or 3.20.0), it crashes.

Suggestion

Co-opting the VSN variable is bad form. I suggest that the script use REBAR3_VSN instead. I'm aware that this might break something, but is the use of VSN documented as allowing using a different rebar3?

rlipscombe avatar Nov 04 '22 15:11 rlipscombe

Yeah it's undocumented, so I think switching to REBAR3_VSN ought to be entirely safe. I can open up a PR.

ferd avatar Nov 04 '22 17:11 ferd