0

I have been losing my mind due to IntelliJ not wanting to commit my code. I had put export GPG_TTY=$(tty) into my .bash_profile instead of my .bashrc; echoing $GPG_TTY responded with the proper path, but I still kept getting the gpg: failed to sign the data error.

From what I gather, .bash_profile is read and executed when Bash is invoked as an interactive login shell, while .bashrc is executed for an interactive non-login shell; $PATH variables should thus go into the .bash_profile...? Or, at least, so I thought. I'd like to know what the functional difference is between the two: why didn't it work from my profile but it does from the rc?

3
  • Is IntelliJ starting a login shell?
    – muru
    CommentedNov 7, 2022 at 3:59
  • Are you on macOS?
    – Kusalananda
    CommentedNov 7, 2022 at 5:58
  • @Kusalananda No, I am on Linux. I guess what White Owl said in his answer cleared things up. I didn't know that it was "pointless" to have a .bash_profile if you run a desktop system which has a GUI, and instead just dump things into the .bashrc.
    – telometto
    CommentedNov 7, 2022 at 10:47

1 Answer 1

1

Solution to a problem: put the export var into .bashrc, and call the .bashrc from .bash_profile.

Yes, the difference is login vs non-login. The bash would be in login mode, when you login to bash, for example through ssh or on a non-gui machine. But once you logged in, all new instances of bash would be started in non-login mode.

If you having a GUI desktop, you will login into WM and not into the bash. So you would never have bash in a login mode (unless you specifically call it with a --login option). So it is kind of pointless to even have .bash_profile on a workstation with GUI.
But you still can have it, in case you will login to that machine-user through ssh, or your WM break and you need to start a recovery procedures.

And of course, the official documentation is a must read: https://www.gnu.org/savannah-checkouts/gnu/bash/manual/bash.html#Bash-Startup-Files

1
  • Didn't know about the GUI stuff. Thanks for clearing that up. I'll just ignore the .bash_profile, then.
    – telometto
    CommentedNov 7, 2022 at 10:45

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.