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

Bash-Completion Errors #544

Open
itinance opened this issue May 23, 2015 · 32 comments
Open

Bash-Completion Errors #544

itinance opened this issue May 23, 2015 · 32 comments

Comments

@itinance
Copy link

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
Copy link

See #536

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

@itinance
Copy link
Author

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
Copy link

^ +1

@johnelliott
Copy link

^ +1 thanks @itinance

1 similar comment
@DoaneAS
Copy link

DoaneAS commented Jul 3, 2015

^ +1 thanks @itinance

@BrianSipple
Copy link

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

1 similar comment
@EtaiG
Copy link

EtaiG commented Jul 5, 2015

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

@anthonyringoet
Copy link

Thanks @itinance

@SamirBoulil
Copy link

+1 thanks @itinance

@eroncanc
Copy link

+1 thanks @itinance

@vinkla
Copy link
Contributor

vinkla commented Sep 13, 2015

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

@ggrigon
Copy link

ggrigon commented Nov 21, 2015

^ +1 thanks @itinance

@mathiasbynens
Copy link
Owner

@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
Copy link

Ryahn commented Nov 29, 2015

Thanks @itinance and @mathiasbynens

@dongs0104
Copy link

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
Copy link
Contributor

@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
Copy link

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

@jeffbyrnes
Copy link
Contributor

@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
Copy link

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
Copy link
Contributor

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

@dongs0104
Copy link

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
Copy link
Contributor

@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
Copy link

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

@jeffbyrnes
Copy link
Contributor

@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
Copy link
Contributor

s10wen commented Jan 28, 2016

@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
Copy link
Contributor

s10wen commented Jan 28, 2016

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
Copy link
Contributor

@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
Copy link
Contributor

s10wen commented Jan 28, 2016

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 [email protected] 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
Copy link
Contributor

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

@s10wen
Copy link
Contributor

s10wen commented Jan 29, 2016

@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
Copy link

mklaber commented May 24, 2016

@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
Copy link

brimarq commented Jun 29, 2016

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.

mhausmann added a commit to mhausmann/dotfiles that referenced this issue Jan 31, 2017
alexjpaz added a commit to alexjpaz/workstation that referenced this issue Jan 28, 2019
Mrick343 pushed a commit to euclidTeam/system_core that referenced this issue May 8, 2024
Patch Set 3:

> Patch Set 3: Verified-1
> 
> This breaks completion on mac (which uses bash 3.2):
> 
>   bash-3.2$ source build/envsetup.sh
>   bash: type: compopt: not found
>   bash: type: compopt: not found
>   bash-3.2$ adb <tab>bash: type: _init_completion: not found

mathiasbynens/dotfiles#544
This issue is exactly the same as what we encountered, upgrading bash via brew will resolve this issue. Many built-in commands such as compopt and declare are not available in out-of-box bash in MacOSX.

Perhaps we have to test BASH_VERSION > 4 in envsetup.sh and inform users to upgrade bash to eliminate this issue since 3.x is really outdated.

Patch-set: 3
Reviewer: Gerrit User 1311067 <1311067@85c56323-6fa9-3386-8a01-6480fb634889>
Label: Presubmit-Ready=0
Mrick343 pushed a commit to euclidTeam/system_core that referenced this issue May 8, 2024
Patch Set 3:

> Patch Set 3:
> 
> > Patch Set 3: Verified-1
> > 
> > This breaks completion on mac (which uses bash 3.2):
> > 
> >   bash-3.2$ source build/envsetup.sh
> >   bash: type: compopt: not found
> >   bash: type: compopt: not found
> >   bash-3.2$ adb <tab>bash: type: _init_completion: not found
> 
> mathiasbynens/dotfiles#544
> This issue is exactly the same as what we encountered, upgrading bash via brew will resolve this issue. Many built-in commands such as compopt and declare are not available in out-of-box bash in MacOSX.
> 
> Perhaps we have to test BASH_VERSION > 4 in envsetup.sh and inform users to upgrade bash to eliminate this issue since 3.x is really outdated.

Tab completion currently working in 3.2, and it's unlikely that apple will ever upgrade past that (with the GPLv3 license change in 4). We shouldn't be breaking the default shell on one of our supported systems to add what's still considered an unsupported shell.

Patch-set: 3
Reviewer: Gerrit User 1074628 <1074628@85c56323-6fa9-3386-8a01-6480fb634889>
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

No branches or pull requests