0

I'm trying to get tab completion support for rust programs in vim going. There are many descriptions on the net how to this and none of them work out-of-the-box in my environment. The first major roadblock I keep running into is that all seem to rely on or require rustup. When I run it I get this error:

# curl https://sh.rustup.rs -sSf | sh
info: downloading installer
Warning: Not enforcing strong cipher suites for TLS, this is potentially less secure
Warning: Not enforcing TLS v1.2, this is potentially less secure
warning: it looks like you have an existing installation of Rust at:
warning: /usr/local/bin
warning: rustup should not be installed alongside Rust. Please uninstall your existing Rust first.
warning: Otherwise you may have confusion unless you are careful with your PATH
warning: If you are sure that you want both rustup and your already installed Rust
warning: then please reply `y' or `yes' or set RUSTUP_INIT_SKIP_PATH_CHECK to yes
warning: or pass `-y' to ignore all ignorable checks.
error: cannot install while Rust is installed

This is because my system's (FreeBSD) package manager installs rust (1.50) while compiling Mozilla. I hesitate going down the path of multiple rust installations and being careful with my PATH. These are the rust-related programs in /usr/local/bin I can work with:

-rwxr-xr-x    1 root  wheel  11762792 Feb 15 23:22 cargo
-rwxr-xr-x    1 root  wheel    381104 Feb 15 23:22 cargo-clippy
-rwxr-xr-x    1 root  wheel   1266240 Feb 15 23:22 cargo-fmt
-rwxr-xr-x    1 root  wheel   6830672 Feb 15 23:22 clippy-driver
-rwxr-xr-x    1 root  wheel  25513576 Feb 15 23:22 rls
-rwxr-xr-x    1 root  wheel       789 Feb 15 23:22 rust-gdb
-rwxr-xr-x    1 root  wheel      1944 Feb 15 23:22 rust-gdbgui
-rwxr-xr-x    1 root  wheel      1072 Feb 15 23:22 rust-lldb
-rwxr-xr-x    1 root  wheel      7264 Feb 15 23:22 rustc
-rwxr-xr-x    1 root  wheel   7031776 Feb 15 23:22 rustdoc
-rwxr-xr-x    1 root  wheel   7488904 Feb 15 23:22 rustfmt

Note that the rust language server rls is already present.

Is there a rustup-agnostic way of getting rust tab completion working? My vim version is 8.2.2569 and kept reasonably up-to-date. I would prefer a solution for vim instead of neovim. If it works for both, even better. I use the vim-plug plugin manager vim.plug.

8
  • You're saying the documentation for every Vim/Rust plugin you've seen assumes that no user would be starting with a pre-existing Rust install? That is hard to believe.
    – B Layer
    Mar 21 at 13:15
  • If you can't find help for that then here's a workaround that suppresses the install error: github.com/rust-lang/rustup/issues/953 . Unless there's something like Python's venv/virtualenv I'm not sure if you have many choices except a) uninstall existing installation or b) get comfortable with using PATH to control things (e.g. install a new version to /usr/local/bin or equivalent and put that in your path before /usr/bin). b) is really not that hard and done all the time for various things. It's easy to reverse, temporarily disable, etc.
    – B Layer
    Mar 21 at 13:24
  • FYI, I meant to say Python's pyenv not venv. Anyways, here's what looks to be useful information about existing Rust installations vs rustup: users.rust-lang.org/t/cannot-install-rustup-alongside-rust/… (Better outcome, though, would be someone here who can tell you how to use what you already have. Good luck.)
    – B Layer
    Mar 21 at 13:38
  • @BLayer Well, I started with github.com/rust-lang/rls#setup where step 1 is installing rustup. Then there are plugins (e.g. from prabirshrestha) which need code referencing 'cmd': {server_info->['rustup', 'run', 'nightly', 'rls']},. It is a twisty little maze of plugins and I have lost orientation. Maybe even misdiagnosed the root cause.
    – Jens
    Mar 21 at 13:39
  • Well, there's a fair chance there's someone here with experience with this who can tell you how to avoid rustup. Otherwise, you might want to read what I linked. Fingers crossed. :)
    – B Layer
    Mar 21 at 13:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.