mathiasbynens / dotfiles

:wrench: .files, including ~/.macos — sensible hacker defaults for macOS
https://mths.be/dotfiles
MIT License
30.01k stars 8.74k forks source link

Bash-Completion Errors #544

Open itinance opened 9 years ago

itinance commented 9 years ago

I've installed this dotfiles-repo on a newly installed Yosemite Machine. I also ran brew.sh after installing homebrew. Everything works as expected, but not in the terminal.

After reboot each terminal starts with lots of errors:

-bash: declare: -A: invalid option 
declare: usage: declare [-afFirtx] [-p] [name[=value] ...]
-bash: complete: -D: invalid option
complete: usage: complete [-abcdefgjksuv] [-pr] [-o option] [-A action] [-G globpat] [-W wordlist] [-P    prefix] [-S suffix] [-X filterpat] [-F function] [-C command] [name ...]

Also, when i want to use bash completion, something like this happens:

mv Dropb-bash: ${prev,,}: bad substitution

I typed "mv Dropb" and pressed the Tab-key then. The other characters "-bash: $(prev..." occur then and restricts me to use the bash completion as it was possible before installing these dotfiles.

which part of the dotfiles should i change (or delete) to fix these issues?

garethlewin commented 9 years ago

See #536

@mathiasbynens you might want to add this to the readme :)

itinance commented 9 years ago

Thanks a lot!

By the way, these both lines will fix these issues, maybe they could be part of the brew.sh script?

sudo bash -c 'echo /usr/local/bin/bash >> /etc/shells'
chsh -s /usr/local/bin/bash
AlecRust commented 9 years ago

^ +1

johnelliott commented 9 years ago

^ +1 thanks @itinance

DoaneAS commented 9 years ago

^ +1 thanks @itinance

BrianSipple commented 9 years ago

+1... and +1 thanks @itinance!

EtaiG commented 9 years ago

+1... and +1 thanks @itinance!

anthonyringoet commented 8 years ago

Thanks @itinance

SamirBoulil commented 8 years ago

+1 thanks @itinance

eroncanc commented 8 years ago

+1 thanks @itinance

vinkla commented 8 years ago

Here is a article on updating Bash on Mac OS X.

ggrigon commented 8 years ago

^ +1 thanks @itinance

mathiasbynens commented 8 years ago

@itinance Here’s a slightly more robust version:

if ! grep '/usr/local/bin/bash' /etc/shells; then
  echo '/usr/local/bin/bash' | sudo tee -a /etc/shells;
  chsh -s /usr/local/bin/bash;
fi;
Ryahn commented 8 years ago

Thanks @itinance and @mathiasbynens

dongs0104 commented 8 years ago

it's not work on subl it is still using /bin/bash so I can see error "usr/local/share/bash-completion/bash_completion: line 1812: declare: -A: invalid option declare: usage: declare [-afFirtx] [-p] [name[=value] ...] /usr/local/share/bash-completion/bash_completion: line 1949: complete: -D: invalid option complete: usage: complete [-abcdefgjksuv] [-pr] [-o option] [-A action] [-G globpat] [-W wordlist] [-P prefix] [-S suffix] [-X filterpat] [-F function] [-C command] [name ...] " but i want to change new bash how to do ? i already try to use
if ! grep '/usr/local/bin/bash' /etc/shells; then echo '/usr/local/bin/bash' | sudo tee -a /etc/shells; chsh -s /usr/local/bin/bash; fi; on root and mine

jeffbyrnes commented 8 years ago

@sd9972 did you open a new shell to test out the results of your chsh operation? Also, I would not chsh for root, since /usr/local/bin/bash can potentially be deleted quite easily.

dongs0104 commented 8 years ago

@jeffbyrnes Thanks for help. :) http://imgur.com/EpFP792 this is my chsh status http://imgur.com/9cshkGN it is my sublime

jeffbyrnes commented 8 years ago

@sd9972 can’t really tell what that chsh status means… in any case, a few things to check:

  1. Did you brew install bash to install a newer version of bash?
  2. Did you verify that /usr/local/bin/bash is in your /etc/shells?
  3. What do you see when you echo $SHELL?
  4. What do you get when you echo $0?

Please just copy & paste the output of your shell here, no need to take screenshots, you can use fenced code blocks to make it render more clearly.

dongs0104 commented 8 years ago
sd9972 at Dongs-MBPr in ~
$ brew install bash
Warning: bash-4.3.42 already installed

sd9972 at Dongs-MBPr in ~
$ cat /etc/shells
# List of acceptable shells for chpass(1).
# Ftpd will not allow users to connect who are not using
# one of these shells.

/usr/local/bin/bash
/bin/bash
/bin/csh
/bin/ksh
/bin/sh
/bin/tcsh
/bin/zsh
sd9972 at Dongs-MBPr in ~
$ echo $SHELL
/usr/local/bin/bash

sd9972 at Dongs-MBPr in ~
$ echo $0
-bash
jeffbyrnes commented 8 years ago

Well, that all looks good. Perhaps try running chsh -s /usr/local/bin/bash again, just for your user?

dongs0104 commented 8 years ago
sd9972 at Dongs-MBPr in ~
$ chsh -s /usr/local/bin/bash 
Changing shell for sd9972.
Password for sd9972: 
chsh: no changes made

and Sublime text

2016-01-15 5 18 30
jeffbyrnes commented 8 years ago

@sd9972 damn. Yeah, really not sure what‘s going on there. Do you have any other shell stuff loaded up? bash-it or something similar?

dongs0104 commented 8 years ago

i don't use bash-it or something about bash shell w/o this !!!

jeffbyrnes commented 8 years ago

@sd9972 I’m at a loss as to what’s missing from your setup, and why the version of bash installed via brew isn’t the bash your shell is using. Sorry I can’t be of more help!

s10wen commented 8 years ago

@mathiasbynens just did a fresh install and noticed this issue as well, wondering if it's worth adding your solution in somewhere to automate this fix?

s10wen commented 8 years ago

Also getting this error:

chsh: Operation was denied because the current credentials do not have the appropriate privileges.  Operation was denied because the current credentials do not have the appropriate privileges.
chsh: no changes made

I tried running as sudo as well and the user is an admin, any ideas please?

I also tried: http://superuser.com/questions/442849/why-do-i-see-operation-was-denied-because-the-current-credentials-do-not-have-t and have /bin/bash set as my login shell.

With sudo bash -c 'echo /usr/local/bin/bash >> /etc/shells' I get sudo: pam_authenticate: unknown user.

Then I ran into an issue where I couldn't open Terminal/iTerm, but a computer restart fixed this.

Following @jeffbyrnes commands I get;

༼ つ ◕_◕ ༽つ⚡  brew install bash
Warning: bash-4.3.42 already installed
owensi at Simons-MacBook-Pro.local in ~

༼ つ ◕_◕ ༽つ⚡  cat /etc/shells
# List of acceptable shells for chpass(1).
# Ftpd will not allow users to connect who are not using
# one of these shells.

/bin/bash
/bin/csh
/bin/ksh
/bin/sh
/bin/tcsh
/bin/zsh
/usr/local/bin/bash
/usr/local/bin/bash
/usr/local/bin/bash
owensi at Simons-MacBook-Pro.local in ~

༼ つ ◕_◕ ༽つ⚡  echo $0
-bash

༼ つ ◕_◕ ༽つ⚡  chsh -s /usr/local/bin/bash
Changing shell for owensi.
Password for owensi:
chsh: Operation was denied because the current credentials do not have the appropriate privileges.  Operation was denied because the current credentials do not have the appropriate privileges.
chsh: no changes made
jeffbyrnes commented 8 years ago

@s10wen two things:

  1. your user should definitely have permissions to chsh for itself
  2. I’d strongly discourage doing chsh for root, that could have unpredictable results (in fact, try not to mess with root at all)

You’ll want to remove the duplicate entries for /usr/local/bin/bash from your /etc/shells.

I’m curious, is your user an admin user? And are you on El Capitan?

s10wen commented 8 years ago

Thanks for the reply I'm just travelling atm but I'll have a look later today. I'm on El Capitan. Something that might be a factor is that this is a work machine, I have a local admin 'simonowen' then also a work admin 'owensi' but afaik they both have full admin rights.

On 28 Jan 2016, at 14:10, Jeff Byrnes notifications@github.com wrote:

@s10wen two things:

your user should definitely have permissions to chsh for itself I’d strongly discourage doing chsh for root, that could have unpredictable results (in fact, try not to mess with root at all) You’ll want to remove the duplicate entries for /usr/local/bin/bash from your /etc/shells.

I’m curious, is your user an admin user? And are you on El Capitan?

— Reply to this email directly or view it on GitHub.

jeffbyrnes commented 8 years ago

As long as they’re both admins, you should be able to chsh, but perhaps your work did something to lock it down.

s10wen commented 8 years ago

@jeffbyrnes I enabled a 'mobile' user in the system preferences and I'm sorted now :) looks like it was a permissions / user issue. Thanks for your help, cleaned up the duplicate entries as well.

mklaber commented 8 years ago

@s10wen 's mention of 'mobile' user led me to a solution that worked for me: I'm on an Active Directory domain which is controlled by Centrify. I had to follow these steps to set my shell in the /etc/centrifydc/centrifydc.conf configuration file as described here.

brimarq commented 8 years ago

I was having this issue as well, and, fixed it with the code in @itinance 's comment. Here's what happened with mine:

Since I already had a homebrew dev environment setup, I chose not to use the brew.sh script. Instead, I just installed the newer Bash manually, then issued the $ chsh -s /usr/local/bin/bash command, which seemed to succeed. The problem: I had overlooked this crucial comment in brew.sh. Oops! Oh, the things we can miss when we lack enough sleep!

So... if you're having this issue, maybe you missed this, too? You have to manually add the new Bash path to /etc/shells for this to work correctly.