Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I use MsysGit on windows 7. I have one annoying problem. The entire bash_profile file seems to get executed twice. for example, I have the following echo line in the .bash_profile

echo "Boinkk..."

enter image description here

If I have

echo "Calvin..."
echo "Hobbes..."

Then I get enter image description here So I know that the .bash_profile file is getting executed twice and not each statement getting executed twice. The target for the "Git Bash" Executable is

C:\Windows\System32\cmd.exe /c ""C:\Program Files\Software\Git\bin\sh.exe" --login -i"

Does anybody know what I have to do to get the bash shell to execute the bash_profile statements only once?

share|improve this question
because if each statement was getting executed twice, I should have got Calvin... Calvin... Hobbes... Hobbes... – Prasanth Aug 4 '11 at 8:46
Do you have any other rc files like bashrc that source bash_profile? I don't think it would do anything but try removing the -i from your target. – jw013 Aug 4 '11 at 9:18
@jw013 I tried removing -i, didn't help. I also tried removing --login -i, but then .bash_profile didn't get sourced at all – wisbucky Jan 31 '14 at 0:21
up vote 1 down vote accepted

I'm not familiar with how to fix on Windows but if it were UNIX/Linux you could do:

echo $PATH <br />

and see where you're getting your double entry from. I'm speculating that your .bash_profile is being added to the path more than once. If you track down where the path is being manipulated you can fix your problem.

share|improve this answer
Thanks. Got it fixed – Prasanth Sep 3 '11 at 10:34
@Prasanth Can you share what the fix was? I tried echo $PATH <br />, echo "$0", echo "$BASH_SOURCE" to try to find what was sourcing .bash_profile twice, but no luck. I have no .bashrc files. It appears to me that Git Bash is sourcing ~/.bash_profile twice when it starts. – wisbucky Jan 31 '14 at 0:44
Git bash was sourcing my .bash_profile already. That was my problem. Ive long since moved to a Unix set up. – Prasanth Feb 3 '14 at 4:45

I had the same problem and noticed there was no ~/.bashrc file.

Creating an empty ~/.bashrc resolved the issue:

touch ~/.bashrc

I could only speculate as to why this worked, but it did.

share|improve this answer
This also mysteriously worked for me using Git Bash on Windows. Thanks! – jingtao Mar 8 '15 at 6:00

You must log in to answer this question.

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