Skip to content

Duplicative auto completions #3156

Description

@acgxv

Problem

Duplicative auto completions

Steps

rustup completions zsh rustup > ~/.cache/oh-my-zsh/completions/_rustup
rustup c <TAB>

check        -- Check for updates to Rust toolchains and rustup
completions  -- Generate tab-completion scripts for your shell
component    -- Modify a toolchain's installed components
# It also starts the path completion, weird
code/
rustup check <TAB>

# All these are duplicative
check           -- Check for updates to Rust toolchains and rustup
completions     -- Generate tab-completion scripts for your shell
component       -- Modify a toolchain's installed components
default         -- Set the default toolchain
doc             -- Open the documentation for the current toolchain
dump-testament  -- Dump information about the build
help            -- Prints this message or the help of the given subcommand(s)
install         -- Update Rust toolchains
man             -- View the man page for a given command
override        -- Modify directory toolchain overrides
run             -- Run a command with an environment configured for a given toolchain
self            -- Modify the rustup installation
set             -- Alter rustup settings
show            -- Show the active and installed toolchains or profiles
target          -- Modify a toolchain's supported targets
toolchain       -- Modify or query the installed toolchains
uninstall       -- Uninstall Rust toolchains
update          -- Update Rust toolchains and rustup
which           -- Display which binary will be run for a given command
rustup check check --v

--help     -h  -- Prints help information
--version  -V  -- Prints version information
rustup check check --version

error: Found argument 'check' which wasn't expected, or isn't valid in this context

USAGE:
    rustup check

For more information try --help

Possible Solution(s)

No response

Notes

No response

Rustup version

rustup 1.25.1 (bb60b1e89 2022-07-12)
info: This is the version for the rustup toolchain manager, not the rustc compiler.
info: The currently active `rustc` version is `rustc 1.68.0-nightly (0b90256ad 2023-01-13)`

Installed toolchains

Default host: aarch64-apple-darwin
rustup home:  /Users/xavier/.rustup

installed toolchains
--------------------

stable-aarch64-apple-darwin
nightly-aarch64-apple-darwin (default)

installed targets for active toolchain
--------------------------------------

aarch64-apple-darwin
wasm32-unknown-unknown

active toolchain
----------------

nightly-aarch64-apple-darwin (default)
rustc 1.68.0-nightly (0b90256ad 2023-01-13)

Activity

  1. changed the title [-]Duplicate auto completions[/-] [+]Duplicative auto completions[/+] on Jan 14, 2023
  2. rbtcollins commented on Feb 22, 2023

    @rbtcollins
    Contributor

    This is probably some clap interaction.

  3. samchouse commented on Aug 16, 2023

    @samchouse

    This is also an issue for me but it doesn't occur with Cargo completions. Something specifically about Rustup completions must have gone wrong.

  4. djc commented on Aug 16, 2023

    @djc
    Contributor

    @xenfo do you want to test if this still happens with #3444?

  5. omertuc commented on Sep 8, 2024

    @omertuc

    EDIT: see more minimal Containerfile below

    Still happens, can easily reproduce with the following:

    cd $(mktemp -d)
    
    cat << EOF > Containerfile
    FROM alpine
    RUN apk add --no-cache zsh curl
    RUN zsh -c "curl https://sh.rustup.rs -sSf | sh -s -- -y"
    RUN mkdir ~/.zfunc
    RUN ~/.cargo/bin/rustup completions zsh > ~/.zfunc/_rustup
    RUN echo 'export PATH="/root/.cargo/bin/:\$PATH"' > ~/.zshrc
    RUN echo 'fpath+=~/.zfunc' >> ~/.zshrc
    RUN echo 'autoload -Uz compinit' >> ~/.zshrc
    RUN echo 'compinit' >> ~/.zshrc
    ENTRYPOINT /bin/zsh
    EOF
    
    podman build . --iidfile rustupid
    podman run -it $(cat rustupid)
  6. rami3l commented on Sep 9, 2024

    @rami3l
    Member

    Our command line argument parser has been rewritten in #3596, so we might need to test against the latest (git) version to know whether the issue is still there.

    @omertuc Thanks in advance for your reproduction steps :)

  7. rami3l commented on Sep 9, 2024

    @rami3l
    Member

    @omertuc I can reproduce this on d288805 with the following Dockerfile:

    FROM rust:alpine
    RUN apk add --no-cache zsh curl
    ADD _rustup /root/.zfunc/
    RUN echo 'export PATH="/root/.cargo/bin/:$PATH"' > ~/.zshrc
    RUN echo 'fpath+=~/.zfunc' >> ~/.zshrc
    RUN echo 'autoload -Uz compinit' >> ~/.zshrc
    RUN echo 'compinit' >> ~/.zshrc
    ENTRYPOINT /bin/zsh

    @samchouse Thanks for your insight. This seems to have something to do with the +toolchain syntax. Clap does not know the difference between rustup +completions completions and rustup completions completions (the rejection logic is implemented manually), so it will happily suggest the latter.

  8. rami3l commented on Sep 9, 2024

    @rami3l
    Member

    Unfortunately, given the analysis above in #3156 (comment), I'm afraid there's not much we can do about this situation.

  9. omertuc commented on Sep 9, 2024

    @omertuc

    Would something like this help in the future?

  10. rami3l commented on Sep 9, 2024

    @rami3l
    Member

    Would something like this help in the future?

    @omertuc Looks like it requires a lot of changes to the current shell ecosystem, but it'll definitely be helpful if feasible.

  11. rami3l commented on Oct 24, 2024

    @rami3l
    Member

    Closing in favor of #2268.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions