How are environment variables set before reading /etc/bash.bashrc?

Hello all!

I’m having trouble tracking down how an environment variable is being set before Bash reads any of its configuration files. Specifically, the ${PROMPT_COMMAND} environment variable is being set somewhere, and I cannot find out where.

The reason I’m asking about this is because when I open up Kitty, I get this error at the top of each prompt:

bash: command not found: prompt_command

This happens because ${PROMPT_COMMAND} is set to execute prompt_command, which fails.

I know that it’s being set before reading any of the configuration files because I added this line at the top of /etc/bash.bashrc:

echo "Running /etc/bash.bashrc, prompt command = ${PROMPT_COMMAND}"

and this confirms when I open a new shell that ${PROMPT_COMMAND} is set before any of these configuration files are read.

I can work around this by setting ${PROMPT_COMMAND} in my bashrc, but I feel like this shouldn’t be necessary.

Any leads on where this environment variable setting could be hiding? /etc/environment is empty, and I don’t see any “Environment Variables” section in YaST.

This is with Tumbleweed, specifically version 20250217.

I think I managed to at least partially-answer my question. I had been using Mise-en-place to manage development environments, so I think that had set something, but it was persisting even after I uninstalled the tool.

After a reboot, it looks like ${PROMPT_COMMAND} is no longer set at the top of /etc/bash.bashrc, so I assume something was cached in memory somehow. If anyone is able to shed light on this behavior, I’d be interested to learn more about it, but the immediate problem at least has been solved by turning it off and back on again.

1 Like

.profile is read prior to .*rc files. Could be that! :face_holding_back_tears:

bash reads either profile or rc.