Terminal not sourcing ~/.bash_profile


> PyCharm 2016.3
> Build #PY-163.8233.8, built on November 22, 2016
> Licensed to
> Subscription is active until
> JRE: 1.8.0_112-release-408-b2 x86_64
> JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o

I'm having an issue after upgrading from 2013.2 where terminal no longer sources my ~/.bash_profile.  It seems to default to /bin/bash but without sourcing the rc. 

Not sure how to give details on reproducing but the essential of it is,

  1. In 2016.2 open terminal within pycharm, should resemble my Terminal or iTerm application shell, ie sourcing my bashrc
  2. Upgrade to 2016.3
  3. Open terminal within pycharm, now gives the default prompt, ie ` bash-3.2$ `

Looking a little more into it, it seems it might have to do with virtualenv? but I'm not sure



See the related discussion here. Workaround for me was to change my shell path setting in the PyCharm tools/terminal settings to 

/bin/bash --rcfile ~/.bash_profile



I had the issue with intellij idea 17.2 version

I solved this by setting the value /bin/bash --login in setting->Tools->Terminal->Shell path.

/bin/bash --login forces the bash to read the ~/.bash_profile.

Following is the explanation of --login option from bash reference manual




There's also a workaround suggested by JetBrains: 

Workaround: disable "Python Terminal" plugin.


It seems, that the files ~/.bash_profile, ~/.bash_login and ~/.profile are only loaded when the bash is started as login_shell.

See condition in <PYCHARM_ROOT>/plugins/terminal/jediterm-bash.in

if [ `shopt -q login_shell` ]; then

I removed the condition and it worked. Nice that they introduced the forward-word, backward-word functionality though.


Great! Worked like a charm!


Read this stackoverflow post: https://stackoverflow.com/a/51522459/2722625


I solved it using:


echo "source ~/.bash_profile" >> .profile

The answer from Tim above is correct, but be careful to also select: 

Tools -> Terminal -> Shell Integration


In a previous attempt to fix this, I unchecked this box and with the following command: 

/bin/bash --rcfile ~/.bash_profile

The Terminal would not even start up. I then "checked" the "Shell Integration" option and that worked. 

Comment for the PyCharm team. I find it annoying that PyCharm behaviour should be inconsistent with other tools, e.g. IntelliJ where the Terminal just works as expected. It'd be nice if you could fix it please?


Do you have a ~/.bash_profile file? If you open a Mac Terminal and type:

source ~/.bash_profile what happens? If that is the terminal you'd like to see, setting the command above and checking the "Shell Integration" checkbox works on PyCharm 2018.3


Boom! It worked. How did you know this? 

I mean disabling "python terminal" will not affect running the code or any other settings. Will it?


I didn't know it. The person owning the issue at Jetbrains suggested the workaround. Glad it helped you


Seems IntelliJ terminal is broken by iTerm2 shell integration (https://www.iterm2.com/documentation-shell-integration.html).
We still couldn't reproduce the problem with the latest iTerm2 shell integration. Could you please attach ~/.iterm2_shell_integration.bash?


perhaps why do you change the bash-3.2$  from userid-MacBook-Pro:mercury userid$? do you know return the userid-MacBook-Pro:mercury userid$


This issue https://youtrack.jetbrains.com/issue/IDEA-164435 should be fixed in the next Pycharm update - Pycharm 2016.3.1. Sorry for the inconvenience.


Hi Marco,

I can confirm this behavior, as I've reproduced it myself. There is indeed seems to be a difference between PyCharm and IDEA in how they handle the "Shell integration" checkbox. However I wouldn't consider this a bug, as enabling this checkbox solves the initial issue.

If this difference in behavior affects your workflow in any way, please feel free to submit a feature request about it to our issue tracker using the link https://youtrack.jetbrains.com/issues/PY and let us know if you need any help.


Setting through this doesn't help.

/bin/bash --rcfile ~/.bash_profile

Not working this way. I don't know how you managed to solve this. Could you please elaborate like how it gets resolved?

That would be of great help.


Yes i do have it. But see when i do source ~/.bash_profile? Nothing happens. Screen remains the same.

I simply have this : Himanshus-MacBook-Air-2:~

This is my home directory.

- My shell integration is already checked. Nothing happens. Still bash-3.2$ is visible.


OK, I've just got a reply from JetBrains that this is a known regression and can be tracked here: https://youtrack.jetbrains.com/issue/IDEA-201459

Hopefully it'll be fixed with the first 2019 release.


The latest update BROKE my prompt, and I had to UNCHECK the Sync Integration to fix it.

That flag causes IntelliJ to load its own config first, then load my own. So something they do in that other config is causing my prompt to break.

Very frustrating to try to figure this stuff out.


Hi Bobby,

Are talking about PyCharm or IntelliJ IDEA ? I will ask the right person to take a look at your issue depending on the product you're using.


Sorry, IntelliJ IDEA.

I couldn't find this discussion when searching for IntelliJ issues, but since a lot of the architecture is the same with JetBrains other products and the symptoms match so closely, I figured it was a safe bet they are related, if not identical in nature.

If they aren't, my apologies.


Hello, Bobby.

Could you please provide more details regarding the problem?



My prompt is customized this way in .bashrc:

export PS1='\[\e[0;31m\]\u\[\e[m\]@\[\e[0;32m\]\h\[\e[m\] \[\e[1;34m\]\w\[\e[m\] $(__git_ps1 "(%s)")\n\[\e[1;32m\]\$\[\e[m\] \[\e[0;37m\]'

I checked "Shell integration" and opened a new Terminal. The first thing I notice is that my .bashrc ran twice. I've confirmed that without shell integration, it only runs once.

At this point the prompt is normal as you see. Then I press the enter key, nothing else. A bunch of stuff gets printed before the prompt, and all subsequent prompts look the same.



Will your external terminal application have the same issue if you run source ~/.bashrc manually?


No, all my terminals work fine.

And IntelliJ terminal is also fine as long as I don't check that Shell Integration option.

I'm assuming this was the result of an update, because I haven't touched those settings for several updates, if ever, and I never had a problem till recently.


Unfortunately, we couldn't reproduce the issue so far.
Could you please attach your /etc/profile, /etc/profile.d/*, /etc/bashrc*, ~/.bashrc, ~/.bash_profile, ~/.profile?
Please provide also output of echo "TERM_PROGRAM=$TERM_PROGRAM, PROMPT_COMMAND=$PROMPT_COMMAND" in the terminal tab in IntelliJ IDEA.


I don't know how to attach a zip file.

Here are screenshots of the output from that echo command. Local was started with Shell Integration checked, Local (2) with it unchecked.


>I don't know how to attach a zip file.

For uploading please use ftp://ftp.intellij.net/.uploads / https://uploads.services.jetbrains.com or any file sharing service.


bcottle.zip (9 kb) 100%

It contains all the matching files I could find in their folders.