1

I have many environment variables set with 'export' in my ~/.bashrc. My .profile sources my .bashrc with

source /home/doriad/.bashrc

However, QtCreator doesn't seem to know about these environment variables. If, instead, I put the exports directly in the .profile, QtCreator has them correctly. Any suggestions on what I'm doing wrong here?

David Doria
  • 9,873
  • 17
  • 85
  • 147
  • Try with this: at the end of `.profile`, put this line: `env | sort > /tmp/profile-env.txt`, and at the end of `.bashrc`, put `env | sort > /tmp/bashrc-env.txt`. Open a new terminal, and check or compare files created. Maybe with `diff` or `vimdiff` command. – tivn Apr 29 '15 at 19:14
  • @tivn That was a good way to confirm that I was right that the exports from .bashrc are not getting put into the environment from .profile. Here are the input and output files (the bashrc is long, but that is the stock Kubuntu .bashrc with my 4 exports at the bottom): https://gist.github.com/daviddoria/e86dcf8406c687aa6285 You'll see the environments looks nothing alike! – David Doria Apr 29 '15 at 19:36

1 Answers1

1

Thanks for providing you .profile and .bashrc. Most probably this is the cause found in your .bashrc:

# If not running interactively, don't do anything
case $- in
    *i*) ;;
      *) return;;
esac

In non-interactive mode, your .bashrc will just return, skipping any export below that.

tivn
  • 1,883
  • 14
  • 14
  • Wow, how silly - it works like a charm without that. This seems like a common pattern - I'm not sure why that would be in the default .bashrc. Thanks for point it out! – David Doria Apr 29 '15 at 20:49
  • File `~/.bashrc` is intended for interactive shell (like aliases setting, command history, etc), so it is better to leave it there. The recommended way to set personal environment variable is to put it in `~/.bash_profile` . See `man bash` and http://stackoverflow.com/questions/902946/about-bash-profile-bashrc-and-where-should-alias-be-written-in/903213#903213 – tivn Apr 29 '15 at 21:25