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

Pants doesn't complain when goal doesn't exist for target #3651

Closed
sid-kap opened this issue Jul 11, 2016 · 3 comments
Closed

Pants doesn't complain when goal doesn't exist for target #3651

sid-kap opened this issue Jul 11, 2016 · 3 comments

Comments

@sid-kap
Copy link

sid-kap commented Jul 11, 2016

Hi,

I have a pants project which contains a hadoop_binary target. (It actually contains two hadoop_binary targets.) My goal was to compile the project and create a bundle of one of the binary targets (in the dist/ directory).

Unfortunately, I forgot to include the target in my pants command. So, instead of

./pants bundle path/to/project:my_binary_name

I typed

./pants bundle path/to/project

As a result, pants did not produce a bundle.

Eventually, I realized that the bundle was not created, and that I was typing the wrong command. However, I wish that pants would have given me an error when I typed this command.

Do you think this would be a useful change? If so, I might try to submit a PR.

@kwlzn
Copy link
Member

kwlzn commented Jul 12, 2016

path/to/project implicitly resolves to the address path/to/project:project (based on inferring the target name from a dirname of the BUILD file path). the fact that it did not throw an error in this instance indicates that this target actually exists - but that the targets type resulted in a no-op for the bundle goal.

beyond bundle itself, I think it would be helpful to error out when a goal is specified that does not apply to any of the specified targets - tho it'd probably be good to socialize the idea on pants-devel@ etc to ensure there aren't use cases that this behavior needs to be permitted for. at a minimum, you'd probably want to put this checking behind a feature flag that can be toggled on/off via the repo-specific pants.ini.

my gut feeling is that this is probably somewhat non-trivial due to the way pants works - ymmv tho.

@sid-kap
Copy link
Author

sid-kap commented Jul 12, 2016

Thanks for your reply!

What you said is correct -- there is a target called path/to/project:project, but it is a scala_library target. As you said, the goal bundle doesn't apply to scala_library targets, which is why it no-oped.

I'll post this on pants-devel@ to solicit more opinions.

@sid-kap sid-kap changed the title pants bundle doesn't complain on wrong arguments Pants doesn't complain when goal doesn't exist for target Jul 12, 2016
@Eric-Arellano
Copy link
Contributor

Closing as V2 goals now have a mechanism for doing this by requesting Addresses or Targets in the rule signature, then erroring if it's == 0. Currently, we only error in certain cases if too many targets are given, rather than too little, but it's trivial to implement.

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

No branches or pull requests

3 participants