Closed choptastic closed 2 years ago
The package name is only use in rebar.config
. In .app.src
you use the application name.
Same for the list of applications in the release, as in the list of apps in {relx, [{release, {r, "1"}, [app_1]}]}
. The only place package name is ever used is deps
.
Thanks, I hadn't noticed the {AppName, {pkg, PkgName}}
option here: https://hex.pm/docs/rebar3_usage (hiding in plain sight)
It's notable that https://hex.pm/docs/rebar3_publish does specify that you can add pkg_name
to the .app.src
file, but it doesn't specifically mention that if you do that, you'll also need to specify the package name in rebar.config
, otherwise bad things might happen.
I also see that the pkg_name
term for the .app.src
isn't specified anywhere on rebar3.org, and seems to only exist on hex.pm. I will contact the hex.pm team to suggest updates to the documentation, unless you happen to know if the documentation for hex.pm exists somewhere in a publicly editable state.
Thanks again.
Oooh, that is about naming the package you are publishing, not the dependency of a package. If you need to name your package different you put pkg_name
in your .app.src
like in the docs. But that is just publishing data.
Indeed, but once that's done, it's not currently clear that doing so means you must also specify the package name explicitly in rebar deps
as {AppName, {pkg, PkgName}}
. That bit wasn't obvious (to me, anyway).
This was one of those situations where I wasn't really sure which app or config was at fault, since it's an interplay between rebar3, hex, and relx. But since the error itself manifested when making a release with relx, that's where I went with my questions.
So, in short, I've learned that:
1) Specifying {pkg_name, PackageName}
in .app.src
, means you must:
2) Specify {AppName, {pkg, PackageName}}
in deps
in rebar.config
, otherwise:
3) relx will crash when making a release.
As this isn't a bug with relx, but can be a little difficult to troubleshoot if misconfigured, I propose some improved error messages with this PR: https://github.com/erlware/relx/pull/893
Hopefully this is okay!
Thanks again for the help!
It should actually fail earlier than a release build. rebar3 should fail to build the application if you use {deps, [PackageName]}
. So I'm not sure how you were able to get passed that?
I'm not sure, but I'm not doing anything particularly crazy.
The package that set this off was erl_pipeline
(with app name pipeline
).
But I tested making a bare application and specifying erl_pipeline
as the only dependency (where it should be {pipeline, {pkg, erl_pipeline}}
), rebar3 compile
pulls deps and compiles just fine.
Hey folks,
I haven't found a solution to this anywhere, so I suspect it's not currently supported, but here goes.
In the hex publishing options is the
pkg_name
option (in the .app.src file) to specify an alternate hex package name from the application name itself.That said, trying to generate a release with one of those packages seems to crash when trying to load the .app file because the
pkg_name.app
file is different from theappname.app
I haven't done an experimenting, but my initial suggestion, if this isn't supported, would be to make appname in the relx apps able to be a tuple (to specify both the
pkg_name
and theapp_name
explicitly), thereby allowing the.app
file to be loaded accordingly, but I'm not sure if that's even feasible (because I know there are issues with app names wanting to be named the same as their containing directories).Anyway, I wanted to pop this down here in case there is a known solution. If there is not a solution with the current state of the code, are there plans to? Or is my above suggestion feasible? Or, if neither of those are the case, what is the practical use-case of the
pkg_name
setting in the.app
file?