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

Duplicative auto completions #3156

Open
AurevoirXavier opened this issue Jan 14, 2023 · 9 comments
Open

Duplicative auto completions #3156

AurevoirXavier opened this issue Jan 14, 2023 · 9 comments
Labels

Comments

@AurevoirXavier
Copy link

AurevoirXavier commented Jan 14, 2023

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)
@AurevoirXavier AurevoirXavier changed the title Duplicate auto completions Duplicative auto completions Jan 14, 2023
@rbtcollins
Copy link
Contributor

This is probably some clap interaction.

@samchouse
Copy link

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

@djc
Copy link
Contributor

djc commented Aug 16, 2023

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

@omertuc
Copy link

omertuc commented Sep 8, 2024

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)

@rami3l
Copy link
Member

rami3l commented Sep 9, 2024

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 :)

@rami3l
Copy link
Member

rami3l commented Sep 9, 2024

@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.

@rami3l
Copy link
Member

rami3l commented Sep 9, 2024

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

@omertuc
Copy link

omertuc commented Sep 9, 2024

Would something like this help in the future?

@rami3l
Copy link
Member

rami3l commented Sep 9, 2024

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.

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

No branches or pull requests

6 participants