mac vscode bash: shopt: globstar: invalid shell option name [duplicate] - bash

This question already has answers here:
Associative arrays: error "declare: -A: invalid option"
(10 answers)
How to get Bash version number in OS X
(3 answers)
Closed 3 years ago.
Running vscode on Mac. I updated the Mac bash version and, as you can see the built-in vscode terminal shows the same version of bash as that of the Mac terminal. When I source my .bash_profile, I get the invalid shell option name error in the vscode terminal. What is causing this?
FWIW - the Terminal > Integrated > Shell: Osx is set to bin/bash, if that is not obvious. And, my SHELL variable is the same.

Related

shebang in macos bin/bash incompatible with linux and windows /usr/bin/bash [duplicate]

This question already has answers here:
What is the preferred Bash shebang ("#!")?
(6 answers)
Why is #!/usr/bin/env bash superior to #!/bin/bash?
(8 answers)
Closed 4 months ago.
I have a shell script intended to run as bash, on all of MacOS, Windows and Linux (Ubuntu).
The problem is that the shebang is not compatible between MacOS and the others, as MacOS expects /bin/bash while Windows and Linux expect /usr/bin/bash.
/usr/bin/bash is not available on MacOS, and sudo ln -s /bin/bash /usr/bin/bash fails as well (I guess, OS protected write?).
How do I write a bash shebang that works correctly on all OSs?

Environment variable is not set MacOS [duplicate]

This question already has answers here:
Mac OS X 10.9 - setting permanent environment variables
(8 answers)
Closed 6 months ago.
I need to set environment variables to build an Ionic application, open the terminal and run the command:
export ANDROID_SDK_ROOT=$HOME/Android/Sdk
Without closing the terminal I type echo $ANDROID_SDK_ROOT, and the environment variable is returned perfectly, so I run "source ~/.bash_profile", to update the environment variables. I open and close the terminal and my environment variable is empty!
I tried to set it manually by opening the environment variables files, with a text editor but without success.
For macOS 10.15 Catalina and Newer, you need to use a .zshenv file instead of .bash_profile. This is because, by default since Catalina, the terminal uses zsh instead of bash.
Export paths permanently in the following manner:
Create .zshenv file:
touch ~/.zshenv
open -a TextEdit.app ~/.zshenv
Type out the export you want to do in this format:
export ANDROID_SDK_ROOT=$HOME/Android/Sdk
and save it. (From this old answer)

Git doesn't work on MacOS Catalina: "xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing" [duplicate]

This question already has answers here:
Git is not working after macOS Update (xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools)
(37 answers)
Closed 3 years ago.
After upgrading to MacOS X 10.15 Catalina, I cannot run any git commands in my shell:
The default interactive shell is now zsh.
To update your account to use zsh, please run chsh -s /bin/zsh.
For more details, please visit https://support.apple.com/kb/HT208050.
~ | git
xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun
I thought there's a problem with my shell, so I followed the instructions to change the default Mac OS shell back to bash, using the GUI and also using the command line:
chsh -s /bin/bash
I also restarted the computer. However, I still see the same message, even though echo "$SHELL" outputs /bin/bash.
You'll need to reinstall the command line tools:
$ xcode-select --install

-bash: ls: command not found [duplicate]

This question already has answers here:
Bash script prints "Command Not Found" on empty lines
(17 answers)
Closed 4 years ago.
I have setup react-native in my system.
I have mac OS X El Capitan.
After completing setup of react native, whenever i open my terminal and type command ls then, it shows "command not found".
export PATH="/usr/bin:/bin:/usr/sbin:/sbin"
export PATH="/usr/local/bin:/usr/local/sbin:$PATH"
After executing above two lines in my terminal, everything works fine. ls command is working after that. But once i close my terminal and again open it, ls command stops working and it shows "command not found".
I have also tried to add above two lines in .bash_profile file, but didn't get success. I don't know how to get rid of this issue.
Add following line to you .bash_profile
export PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/b‌​in
Simply you can do it by following command
echo "export PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/b‌​in" >> ~/.bash_profile
After that please restart your terminal

Bash error after opening Terminal and running shell scripts (CentOS) [duplicate]

This question already has answers here:
Error message on Terminal launch [duplicate]
(2 answers)
Closed 6 years ago.
Every time I open Terminal in CentOS 6.4, I get the error:
bash: usr/local/bin: No such file or directory
I've checked .bashrc and .bash_profile to see if there are any lines that reference usr/local/bin, but haven't found anything. The same error also appears when I switch to root, or run a shell script.
Is it as simple as adding a backslash in front of usr? Like so--
/usr/local/bin
Still don't know where the error is happening though. Any help is much appreciated. Thanks!
This is strange as the normal bash directory on a centos 6.4 system is /bin/bash, however I would advise you to check the following:
echo $SHELL
It should pull your SHELL environment variable to show you where what shell you are using, normally it looks like this:
SHELL=/bin/bash
If it's different say for example:
SHELL=usr/local/bin/bash
then I would check your passwd file to make sure your users default shell is pointing to the right place.
username:x:601:601::/home/username:/bin/bash
Also I would suggest check where you shell actually lives
which bash
/bin/bash
And make sure everything is pointing to the correct location.

Resources