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

Add documentation for installing rustup completion as non root user #1705

Closed
wants to merge 1 commit into from
Closed

Add documentation for installing rustup completion as non root user #1705

wants to merge 1 commit into from

Conversation

ArifRoktim
Copy link

The instructions for adding rustup completion for bash as a non root
user were missing. Said instructions were already added for the other
shells.

@tesuji
Copy link
Contributor

tesuji commented Mar 11, 2019

Strange, this instruction didn't work on my machine.

$ bash --version
GNU bash, version 4.4.19(1)-release (x86_64-pc-linux-gnu)

@ArifRoktim
Copy link
Author

ArifRoktim commented Mar 11, 2019

Hmm, it works for me when I copy and paste the two commands as-is. I tested it on Fedora 29 and Ubuntu 18.04.2 LTS. The bash version on Ubuntu is the same as yours:

GNU bash, version 4.4.19(1)-release (x86_64-pc-linux-gnu)

Troubleshooting steps:

  • Do you have the bash-completion package installed and working?
    • Does your shell source /etc/profile in ~/.bashrc?
    • Did you apply any manual modifications to /etc/profile, the files in /etc/profile.d, or the files in /usr/share/bash-completion/?
  • Do you have either of the following environment variables set?
    • $BASH_COMPLETION_USER_DIR
      • Defaults to $XDG_DATA_HOME/bash-completion when not set
    • $XDG_DATA_HOME
      • Defaults to ~/.local/share/ when not set

Also, what OS/Linux distro are you using?

@tesuji
Copy link
Contributor

tesuji commented Mar 11, 2019

@ArifRoktim It's my fault for not sourcing /etc/bash_completion in ~/.bashrc.
Maybe you could add that caution in this PR.

It is weird! Last time I used bash interactively, I don't need to source /etc/bash_completion.
In /etc/skel/.bashrc, it states that

# enable programmable completion features (you don't need to enable
# this, if it's already enabled in /etc/bash.bashrc and /etc/profile
# sources /etc/bash.bashrc).
if ! shopt -oq posix; then
  if [ -f /usr/share/bash-completion/bash_completion ]; then
    . /usr/share/bash-completion/bash_completion
  elif [ -f /etc/bash_completion ]; then
    . /etc/bash_completion
  fi
fi

But in /etc/bash.bashrc, those lines has been commented:

# enable bash completion in interactive shells
#if ! shopt -oq posix; then
#  if [ -f /usr/share/bash-completion/bash_completion ]; then
#    . /usr/share/bash-completion/bash_completion
#  elif [ -f /etc/bash_completion ]; then
#    . /etc/bash_completion
#  fi
#fi

I'm on Ubuntu 18.04.2 (fresh install).

@ArifRoktim
Copy link
Author

@lzutao So I spun up a fresh install of Ubuntu in a VM to see if bash completion works by default. After running the rustup completions ... command and opening a new shell, rustup completion worked.

I looked at the default shell config files and at the very end of ~/.bashrc(and also /etc/skel/.bashrc) were the following lines:

# enable programmable completion features (you don't need to enable
# this, if it's already enabled in /etc/bash.bashrc and /etc/profile
# sources /etc/bash.bashrc).
if ! shopt -oq posix; then
  if [ -f /usr/share/bash-completion/bash_completion ]; then
    . /usr/share/bash-completion/bash_completion
  elif [ -f /etc/bash_completion ]; then
    . /etc/bash_completion
  fi
fi

I took a look at /etc/bash.bashrc and also found those commented out lines. I guess Ubuntu decided that it's better to have the completion-enabling code in the user .bashrc to make it easier for users to turn off the feature if they wanted to.
Fedora takes a different approach. The default .bashrc just sources /etc/bashrc. That file then sources all files that fit the glob /etc/profile.d/*.sh, and /etc/profile.d/bash_completion.sh matches that glob.


I think in general, bash completion usually "just works" out of the box for most Linux distros. The exact method that the shell uses to enable bash completion is distro specific. Perhaps I should add that users should first check to make sure that completion works for their specific shell?

@bors
Copy link
Contributor

bors commented Mar 15, 2019

☔ The latest upstream changes (presumably #1704) made this pull request unmergeable. Please resolve the merge conflicts.

@kinnison
Copy link
Contributor

Hi @ArifRoktim

Would you mind rebasing your change rather than having a PR with merge commits in?

I think that if you do that, we should be in a position to merge this pretty soon.

Thanks,

D.

@bors
Copy link
Contributor

bors commented Apr 14, 2019

☔ The latest upstream changes (presumably #1646) made this pull request unmergeable. Please resolve the merge conflicts.

The instructions for adding rustup completion for bash as a non root
user were missing. Said instructions were already added for the other
shells.
@kinnison
Copy link
Contributor

Hi @ArifRoktim

I merged some changes which put you in need of a rebase again. Since it was in part my fault for taking so long to process your PR I've rebased it for you and think it's good. Could you please check what I've done and if it's good then we'll try and merge your submission :D

D.

@yodaldevoid
Copy link
Contributor

I might have already covered this with #1646. If I overshadowed your work, I'm sorry.

@ArifRoktim
Copy link
Author

@yodaldevoid
Indeed you have. But it's fine, these things happen.
I've also been annoyed by not having cargo completion for a while so I'm happy for your pr being merged 😄

@kinnison
There are some issues with the rebase but since #1646 obsoletes this pr, I'm going to close it instead. Thanks for working with me on this pr even if it is closed.

@ArifRoktim ArifRoktim closed this Apr 14, 2019
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

Successfully merging this pull request may close these issues.

6 participants