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

Global options in the command line are being associated with scope (goal) #9916

Closed
asherf opened this issue May 30, 2020 · 2 comments
Closed
Assignees
Milestone

Comments

@asherf
Copy link
Member

asherf commented May 30, 2020

When I run: ./tc test --use-coverage --pytest-coverage-report=xml --print-exception-stacktrace src/python::
I get an error:

14:41:52:771 [INFO] waiting for file /Users/asher/projects/toolchain/.pids/pantsd/pid to appear...
14:41:58:943 [ERROR] Unrecognized command line flag '--print-exception-stacktrace' on scope 'test'.
Suggestions:
--print-exception-stacktrace

(Run `./pants help-advanced test` for all available options.)
Traceback (most recent call last):
  File "/Users/asher/.cache/pants/setup/bootstrap-Darwin-x86_64/1.29.0rc0_py38/lib/python3.8/site-packages/pants/bin/daemon_pants_runner.py", line 143, in _run
    runner = LocalPantsRunner.create(
  File "/Users/asher/.cache/pants/setup/bootstrap-Darwin-x86_64/1.29.0rc0_py38/lib/python3.8/site-packages/pants/bin/local_pants_runner.py", line 142, in create
    options.for_scope(scope)
  File "/Users/asher/.cache/pants/setup/bootstrap-Darwin-x86_64/1.29.0rc0_py38/lib/python3.8/site-packages/pants/util/memo.py", line 123, in memoize
    result = func(*args, **kwargs)
  File "/Users/asher/.cache/pants/setup/bootstrap-Darwin-x86_64/1.29.0rc0_py38/lib/python3.8/site-packages/pants/option/options.py", line 541, in for_scope
    self._parser_hierarchy.get_parser_by_scope(scope).parse_args(parse_args_request)
  File "/Users/asher/.cache/pants/setup/bootstrap-Darwin-x86_64/1.29.0rc0_py38/lib/python3.8/site-packages/pants/option/parser.py", line 341, in parse_args
    self._raise_error_for_invalid_flag_names(
  File "/Users/asher/.cache/pants/setup/bootstrap-Darwin-x86_64/1.29.0rc0_py38/lib/python3.8/site-packages/pants/option/parser.py", line 429, in _raise_error_for_invalid_flag_names
    raise ParseError(f"{message}\n\n{help_instructions}")
pants.option.errors.ParseError: Unrecognized command line flag '--print-exception-stacktrace' on scope 'test'.
Suggestions:
--print-exception-stacktrace

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

When I run: ./tc --print-exception-stacktrace test --use-coverage --pytest-coverage-report=xml src/python::
it works... the error is confusing and I think pants should consider global scope for options before erroring out.
I also believe this used to work, but stopped working in recent versions.

@Eric-Arellano

@benjyw
Copy link
Sponsor Contributor

benjyw commented Sep 29, 2020

#10872 addresses the UX issue, providing more helpful error messages when this occurs.

Actually supporting global options in a scoped position turns out to be trickier, because of how per-scope options parsing works. I'm not sure whether it's worth doing, since we now offer a useful error message, as it can add confusion of its own.

@Eric-Arellano
Copy link
Contributor

Totally fine IMO to not allow, now that we have a good error message.

@benjyw benjyw closed this as completed Sep 29, 2020
@stuhood stuhood added the ui label Nov 12, 2020
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

4 participants