This must be something very simple, but I can't figure it out. Until recently iTerm always properly sourced .bash_profile which has:

Sellotape:~ mnewman$ cat .bash_profile
## .bash_profile - Make sure that .bashrc and .profile are read

if [ -f ~/.bashrc ]; then
    source ~/.bashrc

if [ -f ~/.profile ]; then
    source ~/.profile

.profile has this important line from MacPorts:

export PATH="/opt/local/bin:/opt/local/sbin:$PATH"

This is what Terminal says:

Sellotape:~ mnewman$ echo $SHELL
Sellotape:~ mnewman$ echo $PATH

And this is what iTerm says:

Sellotape:~ mnewman$ echo $SHELL
Sellotape:~ mnewman$ echo $PATH

iTerm Settings>Profiles>General>Default has: command /bin/bash

(I also tried Login Shell, but that didn't work either.)

What have I done to mess up iTerm?

  • Provided that you are really using bash (what does echo $BASH_VERSINFO say?), note that .bash_profile is not necessarily sourced. Have a look at the bash man-page, section INVOCATION, to see under which conditions this file is processed. Nov 27, 2023 at 12:36
  • echo $BASH_VERSINFO returns 3. Now that I have set iTerm to run bash as a login shell everything is working as expected.
    – Buadhai
    Nov 28, 2023 at 0:01

1 Answer 1


iTerm does not source your shell startup files. It is a terminal emulator, not a shell.

The shell you run inside iTerm sources your shell startup files.

Further, looking at the value of $SHELL is more or less irrelevant. The contents of $SHELL are what your login shell is, not what shell you currently happen to be in.

Example. My login shell is ksh. However...

Version AJM 93u+m/1.1.0-alpha+e9182bd6 2023-09-24   <-- yup, this is ksh
$ echo $SHELL
/usr/local/bin/ksh                                  <-- and $SHELL agreees
$ bash                                              <-- now launch bash
                                                    <-- not in ksh any more
$ echo $SHELL
/usr/local/bin/ksh                                  <-- waitaminit!
3.2.57(1)-release                                   <-- ah, this *is* bash


Bash reads .bash_profile only for login shells. It also doesn't read .profile if it can find .bash_profile, which I've always thought is more than a little broken.

So iTerm is not launching bash as a login shell, which means your particular combination of startup files are not being read the way you expect them to be, while Terminal is.

  • Thank you for the clear and concise explanation. I learned a lot and fixed the issue. I appreciate your taking the time.
    – Buadhai
    Nov 27, 2023 at 5:00

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .