rebar3_appup_plugin icon indicating copy to clipboard operation
rebar3_appup_plugin copied to clipboard

appup compile generates "git" into the generated appup file

Open tothlac opened this issue 6 years ago • 9 comments

when calling appup release, which calls appup compile on one of our applications it generates

{"git", UpgradeInstructions, DowngradeInstructions} instead of putting the correct version number there. The version number comes from this line:

https://github.com/lrascao/rebar3_appup_plugin/blob/c9fae0f20db3b27b1ef0cc640163eb3690d8e689/src/rebar3_appup_compile.erl#L123

It gives back an atom 'git' instead of the version. so basically there is a bad version number coming from the rebar state. I also see that during earlier when rebar_app_info:original_vsn/2 is called the Vsn still stores the correct value, but right after that this atom comes out from the state. I can't see who sets it. Can it be a rebar bug, or maybe in this case the plugin should read this information from somewhere else?

tothlac avatar Jan 12 '18 17:01 tothlac

when calling appup release, which calls appup compile on one of our applications it generates

you mean appup generate right?

{"git", UpgradeInstructions, DowngradeInstructions} instead of putting the correct version number there.

This is weird because relapp1 also uses git versioning and it works ok, any idea what's different about your project?

lrascao avatar Jan 12 '18 18:01 lrascao

Maybe I'm wrong, but as we have

{provider_hooks, [
      {pre, [{tar, {appup, tar}}]},
      {post, [{compile, {appup, compile}},
              {clean, {appup, clean}}]}
  ]}.

in our rebar.config release calls first compile, and because of the post rule appup compile is called after compiling. When I was debugging it I saw the above mentioned line being executed and there rebar_app_info:original_vsn/2 returns 'git' instead of a string. Because of this problem our build stops in the next step when we call rebar3 relup , in systools_relup:get_script_from_appup/5 on this line:

https://github.com/erlang/otp/blob/a94d94975e06c880e0ceb4eb23b652812fdc1d34/lib/sasl/src/systools_relup.erl#L493

, because TopVsn comes from the generated appup file where it contains 'git', and that won't match TopApp#application.vsn.

I was trying to figure out the reason why this is not correctly set in rebar. If it helps I will try to create a similar application.

tothlac avatar Jan 12 '18 21:01 tothlac

One more thing we have found: The atom git most probably comes from the .app.src of the given dependency. There we use

{vsn, git},

instead of an exact version number. The .app file already contains the version number correctly after the compile in the generated .app.src.

If I change {vsn, git} in the .app.src file to a version string, we don't have this problem anymore.

tothlac avatar Jan 13 '18 09:01 tothlac

It looks like even though

rebar3 compile

generates the .app file with the correct vsn, in appup compile still the vsn coming from the app.src files are used:

https://github.com/lrascao/rebar3_appup_plugin/blob/c9fae0f20db3b27b1ef0cc640163eb3690d8e689/src/rebar3_appup_compile.erl#L80

So SourceAppInfo is basically the contents of the .app.src file, but AppInfo already contains the contents of the generated .app file with the correct Vsn. I've created a PR which just passes the orinal_vsn coming from #rebar_state{} to the template function.

https://github.com/lrascao/rebar3_appup_plugin/pull/36

tothlac avatar Jan 13 '18 12:01 tothlac

Unfortunately I have not noticed in relapp.appup.src the first two lines:

AppInfo = rebar3_appup_utils:find_app_info(<<"relapp">>, STATE),
"{{vsn}}" = rebar_app_info:original_vsn(AppInfo),

With those two lines added to our .appup.src the correct version is used. The problem was that with earlier versions of the plugin the versioning worked without these two lines, so actually it can still be a problem for other users. What do you think do we need this bugfix (maybe it is not a bug this way)? If you want it, I can create a test for it.

tothlac avatar Jan 15 '18 08:01 tothlac

so, on relapp1, if i delete ´relapp.appup.src´ and change the vsn tuple to {vsn, git} i should be able to reproduce the error?

lrascao avatar Jan 19 '18 23:01 lrascao

I've pushed some commits to my local repo containing the needed changes to reproduce the same problem.

So basically if the project is not umbrella, and the first lines setting the vsn in the .appup.src are missing, and semver is used for relx in rebar.config the string "git" will be stored in the generated .appup file after calling "rebar3 compile" which calls "rebar3 appup compile".

The commits are here: https://github.com/tothlac/relapp1/commits/master

tothlac avatar Jan 24 '18 08:01 tothlac

nice, thanks for that, i'll dig into it soon

lrascao avatar Jan 24 '18 10:01 lrascao

i think this is another instance of #24, as @ferd mentioned on it the provider hook functionality works differently when not in an umbrella app context, for some reason git gets replaced in app_info_t in some cases and not in others

lrascao avatar Jan 24 '18 19:01 lrascao