Search code examples
erlangrebar

'start_erl.data is missing' error when generating upgrade with rebar erlang


I was following the guide on the rebar wiki page for creating application upgrades (https://github.com/rebar/rebar/wiki/Upgrades); I was trying to upgrade from release 0.0.1 to 0.0.2 and after generating release 0.0.1 and 0.0.2, I run the command:

rebar generate-appups previous_release=0.0.1

and I got the error:

/rel/0.0.1/releases/start_erl.data is missing.

The file start_erl.data is not generated anywhere when I generate the release. I really have no idea what could be causing this.

My reltool.config for release 0.0.1:

%% -*- mode: erlang -*-
%% ex: ft=erlang
{sys, [
  %%{lib_dirs, []},
  {erts, [{mod_cond, derived}, {app_file, strip}]},
  {app_file, strip},
  {rel, "my_app", "0.0.1",
    [
      kernel,
      stdlib,
      sasl,
      mnesia,
      crypto,
      sync,
      ranch,
      cowlib,
      cowboy,
      auth,
      quickrand,
      snappy,
      lz4,
      semver,
      uuid,
      re2,
      my_app
    ]},
  {rel, "start_clean", "",
    [
      kernel,
      stdlib
    ]},
  {boot_rel, "my_app"},
  {profile, embedded},
  {incl_cond, derived},
  {excl_archive_filters, [".*"]}, %% Do not archive built libs
  {excl_sys_filters, ["^bin/(?!start_clean.boot)",
    "^erts.*/bin/(dialyzer|typer)",
    "^erts.*/(doc|info|include|lib|man|src)"]},
  {excl_app_filters, ["\.gitignore"]},
  {app, hipe, [{incl_cond, exclude}]},
  {app, sync, [{mod_cond, app}, {incl_cond, include}, {lib_dir, "../deps/sync"}]},
  {app, ranch, [{mod_cond, app}, {incl_cond, include}, {lib_dir, "../deps/ranch"}]},
  {app, jsx, [{mod_cond, app}, {incl_cond, include}, {lib_dir, "../deps/jsx"}]},
  {app, cowlib, [{mod_cond, app}, {incl_cond, include}, {lib_dir, "../deps/cowlib"}]},
  {app, cowboy, [{mod_cond, app}, {incl_cond, include}, {lib_dir, "../deps/cowboy"}]},
  {app, quickrand, [{mod_cond, app}, {incl_cond, include}, {lib_dir, "../deps/quickrand"}]},
  {app, snappy, [{mod_cond, app}, {incl_cond, include}, {lib_dir, "../deps/snappy"}]},
  {app, lz4, [{mod_cond, app}, {incl_cond, include}, {lib_dir, "../deps/lz4"}]},
  {app, semver, [{mod_cond, app}, {incl_cond, include}, {lib_dir, "../deps/semver"}]},
  {app, uuid, [{mod_cond, app}, {incl_cond, include}, {lib_dir, "../deps/uuid"}]},
  {app, re2, [{mod_cond, app}, {incl_cond, include}, {lib_dir, "../deps/re2"}]},
  {app, auth, [{mod_cond, app}, {incl_cond, include}, {lib_dir, "../deps/auth"}]},
  {app, my_app, [{mod_cond, app}, {incl_cond, include}, {lib_dir, ".."}]}
]}.

{target_dir, "my_app"}.

{overlay, [
  {mkdir, "log/sasl"},
  {copy, "files/erl", "\{\{erts_vsn\}\}/bin/erl"},
  {copy, "files/nodetool", "releases/\{\{rel_vsn\}\}/nodetool"},
  {copy, "my_app/bin/start_clean.boot",
    "\{\{erts_vsn\}\}/bin/start_clean.boot"},
  {copy, "files/my_app", "bin/my_app"},
  {copy, "files/my_app.cmd", "bin/my_app.cmd"},
  {copy, "files/start_erl.cmd", "bin/start_erl.cmd"},
  {copy, "files/install_upgrade.escript", "bin/install_upgrade.escript"},
  {copy, "files/sys.config", "releases/\{\{rel_vsn\}\}/sys.config"},
  {copy, "files/vm.args", "releases/\{\{rel_vsn\}\}/vm.args"}
]}.

The reltool.config file for release 0.0.2 is identical except for the part: {rel, "my_app", "0.0.1", which changes to {rel, "my_app", "0.0.2", (I am using R16B03)


Solution

  • I am not sure if there is any specific Erlang or rebar command to generate the start_erl.data file but it can be easily generated manually. It's just one line of text containing the erts version and the release name. For example:

    g@crayon2:~/work/humbundee/releases % cat start_erl.data 
    7.2.1 hbd-0.0.1
    

    You can get the current version of erts from the Erlang installation, e.g.:

    g@crayon2:~/work/humbundee/releases % l /usr/local/lib/erlang/lib/ | grep erts
    drwxr-xr-x   4 root  wheel   4 17 Feb 08:46 erts-7.2.1/
    

    And the release name in your case would be simply "0.0.1". So you could create it like this:

    echo "7.2.1 0.0.1" > start_erl.data
    

    If you want to see how this could be done in a more automatic way, in my build scripts I use this write_start_erl_data function:

    write_start_erl_data(ErtsVsn, Vsn) ->
        DataFile = filename:join("releases", "start_erl.data"),
        io:format(" => Create file: ~s~n", [DataFile]),
        ok = file:write_file(DataFile, io_lib:format("~s ~s~n", [ErtsVsn, Vsn])).