rust-lang / rust-lang/rustup

clap is overeager eating `+toolchain` positional

Open
#2,345 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
Rust
Stars
7k
Forks
1.1k
Avg merge
22h 40m
Merged PRs (30d)
46

Description

Problem

The clap CLI parser is overeager at eating a positional argument to fill the +toolchain field when it's not actually appropriate, this can lead to very confusing interactions. Consider:

Steps

  1. run rustup add target (braino swapped target and add) and be told about the list subcommand.
  2. run rustup add target list thinking maybe that'll tell you what targets you can add and get the unexpected error error: Invalid value for '<+toolchain>': Toolchain overrides must begin with '+'

Possible Solution(s)

We probably want to detect, consume, and remove from the argv the +toolchain argument and then not have it as part of clap, unless we can teach clap to ignore a positional which doesn't match +toolchain somehow

Notes

This is using master at 53b2168fa6426ea3cb3099be6049aa7e04ed4a6e

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the two rustup command examples and trace how the CLI argument handling passes positional values to clap's +toolchain field. Done means positional arguments that do not begin with '+' are not reported as invalid toolchain overrides, while the intended subcommand guidance or behavior remains intact.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
cli
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.