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

Improve error message when an option is valid, but is being applied to a subsystem/goal, rather than globally #9627

Closed
rtpg opened this issue Apr 24, 2020 · 4 comments
Assignees

Comments

@rtpg
Copy link

rtpg commented Apr 24, 2020

My pants.toml

[GLOBAL]
v2=true
v1=false
v2_ui=true
pants_version="1.27.0rc0"

# no v1 packages
backend_packages = []

# v2 backends
backend_packages2 = []

# v2 plugins
plugins2 = []

I wanted to try out the backends goal, but hit a failure. Then I wanted to see the actual stacktrace and ended up with the following stacktrace about... not being able to see the stacktrace

~/proj/pants-test                                                                                                           
$ ./pants backends                                                                                                                       

ERROR: max() arg is an empty sequence

(Use --print-exception-stacktrace to see more error details.)

~/proj/pants-test                                                                                                           
$ ./pants backends --print-exception-stacktrace                                                                                          
timestamp: 2020-04-24T13:17:30.874773
Exception caught: (pants.option.errors.ParseError)
  File "/home/rtpg/.cache/pants/setup/bootstrap-Linux-x86_64/1.27.0rc0_py37/bin/pants", line 8, in <module>
    sys.exit(main())
  File "/home/rtpg/.cache/pants/setup/bootstrap-Linux-x86_64/1.27.0rc0_py37/lib/python3.7/site-packages/pants/bin/pants_loader.py", line 94, in main
    PantsLoader.run()
  File "/home/rtpg/.cache/pants/setup/bootstrap-Linux-x86_64/1.27.0rc0_py37/lib/python3.7/site-packages/pants/bin/pants_loader.py", line 90, in run
    cls.load_and_execute(entrypoint)
  File "/home/rtpg/.cache/pants/setup/bootstrap-Linux-x86_64/1.27.0rc0_py37/lib/python3.7/site-packages/pants/bin/pants_loader.py", line 83, in load_and_execute
    entrypoint_main()
  File "/home/rtpg/.cache/pants/setup/bootstrap-Linux-x86_64/1.27.0rc0_py37/lib/python3.7/site-packages/pants/bin/pants_exe.py", line 33, in main
    runner.run(start_time)
  File "/home/rtpg/.cache/pants/setup/bootstrap-Linux-x86_64/1.27.0rc0_py37/lib/python3.7/site-packages/pants/bin/pants_runner.py", line 100, in run
    runner = LocalPantsRunner.create(env=self.env, options_bootstrapper=options_bootstrapper)
  File "/home/rtpg/.cache/pants/setup/bootstrap-Linux-x86_64/1.27.0rc0_py37/lib/python3.7/site-packages/pants/bin/local_pants_runner.py", line 188, in create
    options.for_scope(scope)
  File "/home/rtpg/.cache/pants/setup/bootstrap-Linux-x86_64/1.27.0rc0_py37/lib/python3.7/site-packages/pants/util/memo.py", line 123, in memoize
    result = func(*args, **kwargs)
  File "/home/rtpg/.cache/pants/setup/bootstrap-Linux-x86_64/1.27.0rc0_py37/lib/python3.7/site-packages/pants/option/options.py", line 535, in for_scope
    self._parser_hierarchy.get_parser_by_scope(scope).parse_args(parse_args_request)
  File "/home/rtpg/.cache/pants/setup/bootstrap-Linux-x86_64/1.27.0rc0_py37/lib/python3.7/site-packages/pants/option/parser.py", line 320, in parse_args
    levenshtein_max_distance=levenshtein_max_distance,
  File "/home/rtpg/.cache/pants/setup/bootstrap-Linux-x86_64/1.27.0rc0_py37/lib/python3.7/site-packages/pants/option/parser.py", line 394, in _raise_error_for_invalid_flag_names
    suggestions_message=suggestions_message,

Exception message: Unrecognized command line flags on scope 'backends': --print-exception-stacktrace. Suggestions:
--print-exception-stacktrace: [--print-exception-stacktrace]
@rtpg rtpg changed the title --print-exception-stacktrace not working in v2? --print-exception-stacktrace not working in v2 backends command? Apr 24, 2020
@Eric-Arellano
Copy link
Contributor

Try out ./pants --print-exception-stacktrace backends.

./pants backends --print-exception-stacktrace doesn't work as you'd expect because it's really a shorthand for ./pants --backends-print-exception-stacktrace backends.

Another example: ./pants run --args='arg1 -o' is shorthand for ./pants --run-args='arg1 -o' run.

--

With the original issue, yes, unfortunately, we realized a few days ago that ./pants backends doesn't work properly when you installed Pants from a wheel, like you would normally do and how we recommend :/ We'll be temporarily disabling it soon until we fix this. Sorry about that!

@rtpg
Copy link
Author

rtpg commented Apr 24, 2020

OK passing in the param in the front works, good to know. That issue is a bit subtle but I get why this would happen

@Eric-Arellano Eric-Arellano changed the title --print-exception-stacktrace not working in v2 backends command? Improve error message when an option is valid, but is being applied to a subsystem/goal, rather than globally Apr 27, 2020
@Eric-Arellano Eric-Arellano self-assigned this Apr 27, 2020
@Eric-Arellano
Copy link
Contributor

FYI we took a first pass at improving the error message in #9795. Your message would now read:

Exception message: Unrecognized command line flag `--print-exception-stacktrace` on scope 'backends'. Suggestions:
--print-exception-stacktrace

(Run `./pants help-advanced backends` for all available options.)

This does still have the same major issue of showing options that don't make sense - I hope to address that in a followup this week or next.

@Eric-Arellano
Copy link
Contributor

Fixed by #10872. Thanks for reporting this @rtpg!

We released 2.0.0rc0 yesterday, and it makes lots of big improvements. Check out https://www.pantsbuild.org/docs/how-to-upgrade-pants-2-0 for an upgrade guide, and https://www.pantsbuild.org/docs/community for how to join our Slack. We'd love to help you out with upgrading and trying it out.

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