2

I know macOS 11 is trying hard to convince me to use zsh, but it also says I can choose another shell, which I have: chsh -s /bin/bash. The problem is, it no longer works as it did, as it neither reads my .profile nor my .bashrc when I start Terminal.app or iTerm.app. I just get this:

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.
bash-3.2$

If I now manually type bash, things happen as they should:

bash-3.2$ bash
[Timer is unset. Use timer_start] core utils setup finished
[3] Executing $HOME/.bashrc
[7] Reading utility functions and aliases
[10] core utils setup finished
[14] Reading aliases and functions
[22] ssh aliases
[26] conversions
[30] Use htop if available
[36] small utils and aliases
[40] aliases: setting up node aliases
[44] aliases: finished setting up node aliases
[48] webserver aliases
[52] global aliases and functions finished
[56] Reading utils for git prompt
[63] Reading bash completion files
[69] /Users/carlerik/.bash_completion.d/azure
[75] /Users/carlerik/.bash_completion.d/git
[89] /Users/carlerik/.bash_completion.d/npm
[95] /Users/carlerik/.bash_completion.d/tmux
[100] Reading color codes
[105] Read /Users/carlerik/.bash.d/colors
[130] Read /Users/carlerik/bin/z.sh
[135] Reading local settings for this machine
[140] Load personalized bashrc for mac
[152] Read /Users/carlerik/.bashrc.local
This setup is missing 'direnv'. Please install it for per-directory overrides
[157] Finished bash setup
[205] Read /Users/carlerik/.secret

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.

carlerik at idas-imac in ~ $

All the timing stuff is due to a DEBUG setting I have enabled (my .bashrc in my dotfiles). So it works as normal.

How can I get macOS 11 to use my .bashrc and/or .profile on startup?

I have even tried overriding the terminal settings in both apps from the standard logon shell to /bin/bash --rcfile $HOME/.bashrc with no further success (just as a temporary workaround to see if it was possible to force it to read my init files).

For reference, this is my .profile:

printf "Reading .profile"
export DEBUG=1

if [ -n "$BASH_VERSION" ]; then # include .bashrc if it exists if [ -f "$HOME/.bashrc" ]; then . "$HOME/.bashrc" fi fi

other stuff

...

other stuff end

if [ -f "$HOME/.profile.local" ]; then . "$HOME/.profile.local" fi

oligofren
  • 372
  • /bin/bash --rcfile $HOME/.bashrc is not a login shell so won't read ~/.profile but should read ~/.bashrc – mmmmmm Jun 22 '21 at 07:59
  • 2
    Note that in the output from runing bash from the command line it correctly does not show the output of printf "Reading .profile". I would suggest there is a problem with your actual ~/.profile or have you got an empty ~/.bash_profile or ~/.bash_login that bash sees first. – mmmmmm Jun 22 '21 at 07:59
  • @mmmmmm: I only tried that to force it to read the basrc, with no apparent effect. I also tried --logon to try and force a read of .profile, to no avail. Weird as hell. – oligofren Jun 22 '21 at 13:33
  • Have you got either of the other r files I mentioned? – mmmmmm Jun 22 '21 at 13:36
  • I missed that question, but I'll try to check when I get back from work. I have been quite diligent in removing those previously to mostly have settings in .profile that can be used in all shells, but maybe there have been files added by upgrading macOS 11? I doubt it, but worth checking out :) – oligofren Jun 22 '21 at 13:38
  • Login shells never read .bashrc. To force a login shell, use --login (not --logon) – nohillside Jun 22 '21 at 13:41
  • Also, did you change any of the related files in /etc in the past? – nohillside Jun 22 '21 at 13:41
  • It was a typo - would probably get an error if I wrote it like that. And logon shells do not read .bashrc on their own, but if you look at my .profile listed above, you will see that they do regardless ;) – oligofren Jun 22 '21 at 13:52
  • No changing of /etc for bash, no – oligofren Jun 22 '21 at 13:52
  • @mmmmmm You were right about the other r files! Installing the gcloud SDK automatically created a .bash_profile, thus overriding my .profile. Removing it immediately fixed the issue. – oligofren Jul 01 '21 at 09:17

1 Answers1

3

The answer to this was hinted to by @mmmmmm: without my knowledge, a .bash_profile file had been added, thus making bash choose to read that instead of .profile.

The culprit was the installer script for gcloud, the CLI for the Google Cloud SDK.

For my cross-platform dotfiles, I have moved these mac-specific settings to another file which is only read when using mac (in my setup).

oligofren
  • 372
  • Or better use .bash_profile rather than .profil unless you do use sh or dash sometimes. – mmmmmm Jul 01 '21 at 10:18
  • I use .profile because I use different shells at times. I keep most shell specific things in the rc file. – oligofren Jul 01 '21 at 20:59
  • gcloud messed up my terminal prompt too, but there's no new profile script on my root. I know my .zprofile is being run but I cannot find what else it is calling to change the prompt! – rogers Oct 03 '22 at 15:48