Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

appup compile generates "git" into the generated appup file #35

Open
tothlac opened this issue Jan 12, 2018 · 9 comments
Open

appup compile generates "git" into the generated appup file #35

tothlac opened this issue Jan 12, 2018 · 9 comments

Comments

@tothlac
Copy link

tothlac commented Jan 12, 2018

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:

Context = [{"vsn", rebar_app_info:original_vsn(AppInfo)}],

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?

@lrascao
Copy link
Owner

lrascao commented Jan 12, 2018

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?

@tothlac
Copy link
Author

tothlac commented Jan 12, 2018

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
Copy link
Author

tothlac commented Jan 13, 2018

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
Copy link
Author

tothlac commented Jan 13, 2018

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:

SourceAppInfo = rebar3_appup_utils:find_app_info(Name, State),

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.

#36

@tothlac
Copy link
Author

tothlac commented Jan 15, 2018

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.

@lrascao
Copy link
Owner

lrascao commented Jan 19, 2018

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?

@tothlac
Copy link
Author

tothlac commented Jan 24, 2018

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

@lrascao
Copy link
Owner

lrascao commented Jan 24, 2018

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

@lrascao
Copy link
Owner

lrascao commented Jan 24, 2018

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants