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

When hex_erl is included as project dependency it tries to run protobuf provider hooks #20

Closed
kubaodias opened this issue May 25, 2018 · 15 comments

Comments

@kubaodias
Copy link

kubaodias commented May 25, 2018

I have a project that includes hex_erl in rebar.config e.g.

{deps,[
    {hex_erl, {git, "https://github.com/hexpm/hex_erl.git", {branch, "master"}}}
]}.

When I run rebar3 compile in my project I get the following error:

===> Verifying dependencies...
===> Fetching hex_erl ({git,"https://github.com/hexpm/hex_erl.git",
                                  {ref,
                                      "6c8973c2ce3acea1ebec8f08d23b4951f272361b"}})
===> Compiling hex_erl
===> Unable to run pre hooks for 'compile', command 'compile' in namespace 'protobuf' not found.

It seems that when protobuf is added as project plugin it isn't fetched as project dependency. https://github.com/hexpm/hex_erl/blob/6c8973c2ce3acea1ebec8f08d23b4951f272361b/rebar.config#L3-L6
https://github.com/hexpm/hex_erl/blob/6c8973c2ce3acea1ebec8f08d23b4951f272361b/rebar.config#L18-L23
Please refer to end of this section in rebar3 documentation: http://www.rebar3.org/v3/docs/using-available-plugins#section-project-plugins-and-overriding-commands

@ferd
Copy link
Contributor

ferd commented May 25, 2018

Yeah, project plugins are specifically meant for plugins that override a default command's behavior, and as such are only allowed for top-level apps (i.e. making your own release command). Otherwise just put the plugins in the plugins tuple instead of project_plugins and it should work.

@kubaodias
Copy link
Author

@wojtekmach Should hex_erl have a project-only dependency from gpb? Currently I can't inckude hex_erl as dependency of my project without explicitely depending on gpb.

@ericmj
Copy link
Member

ericmj commented Jun 2, 2018

If I understand correctly rebar3_gpb_plugin should be moved to plugins and rebar3_proper kept in project_plugins. Please let us know if making this change fixes the problem for you.

@ericmj
Copy link
Member

ericmj commented Jun 2, 2018

Alternatively we can remove protobuf from provider_hooks and manually run the protobuf generator, I think this would be preferable.

@ferd
Copy link
Contributor

ferd commented Jun 2, 2018

rebar3_proper should be a plugin as well.

project_plugins are only to replace a command provided by rebar3, such as release or tar. Anything else (adding a new command) can be a regular plugin. You could move proper to a project plugin to avoid redownloading it, but it ships with no GPL code anymore and wouldn't be that big of a deal

@tsloughter
Copy link
Contributor

No, rebar3_proper should definitely be a project plugin. There is no reason to have it get downloaded when the project is being used as a dependency. That is one of the purposes of project plugins.

As for gpb, unless the generated modules are committed then yes it needs to be a regular plugin.

@wojtekmach
Copy link
Member

wojtekmach commented Jun 6, 2018

@tsloughter on master both plugins are project plugins, and yet the keep being downloaded when fetching the package using package as dependency, is there a way to avoid downloads?

See: https://github.com/hexpm/hex_erl/pull/23/files - it's safe to remove provider hooks because we commit generated .erl from .pb. On that branch I switch project_plugins to plugins, btw, which I guess I'll revert, but in either case stuff is being downloaded. Help would be very appreciated.

edit: clarified fetching vs using

@tsloughter
Copy link
Contributor

It is a bug in rebar3 if a project plugin is fetched when the application is used as a dependency of another project.

@wojtekmach
Copy link
Member

what's weird is when I add hex_erl on a rebar3 project and do rebar3 compile it does not download gbp, but if I do it on a new mix project it does, even if I switch my ~/.mix/rebar3 version to latest. If someone can reproduce it on mix I'd appreciate, maybe the issue is there after all?

For now, I've removed provider hooks and so part of the issue is solved.

@ferd
Copy link
Contributor

ferd commented Jul 5, 2018

Mix downloads deps its own way, and only gives paths for rebar3 to compile.

@ericmj
Copy link
Member

ericmj commented Jul 6, 2018

@ferd Mix downloads deps but this is a plugin so it would be rebar3 downloading it when running the bare compiler.

@ericmj
Copy link
Member

ericmj commented Jul 6, 2018

My guess is that rebar3 bare compiler runs project_plugins because it doesn't know it is being used a dependency. If that's the case the bare compiler should change to behave as a dependency compilation instead or a flag be added that tells it to do so.

@ferd
Copy link
Contributor

ferd commented Jul 6, 2018

ah that could be a possible interpretation. We have no way to know if the bare compiler is used for a dep or a top-level app (another tool than mix could wrap it), and maybe a switch should be needed for that.

@tsloughter
Copy link
Contributor

Yea, that'd be the issue. Not sure if it is easily changed.

@wojtekmach
Copy link
Member

Until we fix this in mix and/or rebar3, I've pushed a change that puts gpb stuff into dev profile and protobuf stuff into test profile so that mix will no longer download plugins unnecessarily by default. See: 1e5c558

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

5 participants