# Not sourceing .bashrc or .bash\_profile on linux

**URL:** <https://forum.cursor.com/t/not-sourceing-bashrc-or-bash-profile-on-linux/162266>\
**Category:** Help\
**Tags:** terminal, linux\
**Created:** [June 2, 2026, 11:34pm UTC](https://forum.cursor.com/t/not-sourceing-bashrc-or-bash-profile-on-linux/162266 "2026-06-02T23:34:49Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![HEMgreen](https://avatars.discourse-cdn.com/v4/letter/h/9e8a1a/32.png) [@HEMgreen](https://forum.cursor.com/u/HEMgreen)\
**Post date:** [June 2, 2026, 11:34pm UTC](https://forum.cursor.com/t/not-sourceing-bashrc-or-bash-profile-on-linux/162266/1 "2026-06-02T23:34:49Z")

</div>

### Describe the Bug

I’m realizing there’s a fundamental issue here—Cursor’s agent shells are non-interactive and non-login, which means they won’t source either .bash\_profile or .bashrc, so adding the API keys to .bash\_profile won’t actually work for loading environment variables in the agent context.

However, the user is pushing back on the ~/.aws/credentials approach and wants to try .bash\_profile instead. I should clarify what actually gets sourced by Cursor’s different shell contexts—the integrated terminal versus the agent tool-call shell—and explain why the .bash\_profile approach won’t solve the agent’s credential problem, while still respecting their direction.

### Steps to Reproduce

AWS api keys are not being picked up in .bashrc nor .bash\_profile, so aws cli errors

### Operating System

Linux

### Version Information

see other post

### Does this stop you from using Cursor

No - Cursor works, but with this issue

---

<div class="post-metadata">

**Author:** ![mohitjain](https://sea3.discourse-cdn.com/cursor1/user_avatar/forum.cursor.com/mohitjain/32/100229_2.png) [@mohitjain](https://forum.cursor.com/u/mohitjain)\
**Post date:** [June 3, 2026, 6:47am UTC](https://forum.cursor.com/t/not-sourceing-bashrc-or-bash-profile-on-linux/162266/6 "2026-06-03T06:47:25Z")

</div>

Agent shells actually do source `.bashrc` and `.bash_profile` - but only once, when the agent session initializes. The init shell runs as a login + interactive shell, so both files get loaded. After that, each command runs in a simpler shell that restores a snapshot of the environment captured during init, without re-reading the profile files.

So if you added AWS credentials to your profiles after starting the session, the snapshot won’t include them. A few things to try:

1. Restart Cursor after modifying your profile files - this forces a fresh init that captures the new exports

2. Check that `.bash_profile` sources `.bashrc` - on some Linux distros these are separate. If your creds are in `.bashrc` but `.bash_profile` doesn’t source it, the login shell init won’t pick them up

3. Check for early-exit guards in `.bashrc` - some distros include `[-z "$PS1"] && return` near the top, which can skip the rest of the file in non-standard shell contexts

For AWS specifically, `~/.aws/credentials` (or `~/.aws/config` with named profiles) is the most reliable approach. The AWS CLI reads these files directly regardless of how the shell was started, so there’s no dependency on environment variable sourcing.

---

<div class="post-metadata">

**Author:** ![HEMgreen](https://avatars.discourse-cdn.com/v4/letter/h/9e8a1a/32.png) [@HEMgreen](https://forum.cursor.com/u/HEMgreen)\
**Post date:** [June 3, 2026, 4:28pm UTC](https://forum.cursor.com/t/not-sourceing-bashrc-or-bash-profile-on-linux/162266/7 "2026-06-03T16:28:34Z")

</div>

no, i have had it in my .bashrc for a while, and it continues to not pick up the credentials even though it works in my terminal sessions. I think this is a bug

---

<div class="post-metadata">

**Author:** ![mohitjain](https://sea3.discourse-cdn.com/cursor1/user_avatar/forum.cursor.com/mohitjain/32/100229_2.png) [@mohitjain](https://forum.cursor.com/u/mohitjain)\
**Post date:** [June 8, 2026, 11:50am UTC](https://forum.cursor.com/t/not-sourceing-bashrc-or-bash-profile-on-linux/162266/8 "2026-06-08T11:50:33Z")

</div>

That’s helpful, it rules out the timing issue I mentioned.

Here’s what’s actually going on. Your terminal and the agent start bash in different modes:

- Your integrated terminal runs as a non-login shell, which reads `~/.bashrc`. That’s why your credentials work there.

- The agent starts its shell as a login shell, which reads `~/.bash_profile` (or `~/.bash_login` / `~/.profile`) and does not read `~/.bashrc` unless one of those files sources it.

So with your credentials in `~/.bashrc` and a `~/.bash_profile` that doesn’t source it, the agent’s shell never loads them — even though your terminal does. This is standard bash behavior for login vs non-login shells rather than something specific to Cursor.

The fix is one line. Add this to your `~/.bash_profile`:

```auto
[-f ~/.bashrc] && . ~/.bashrc

```

Then restart Cursor so the agent shell re-initializes. After that it’ll pick up everything in `~/.bashrc`.

For AWS specifically, `~/.aws/credentials` is still the most robust option, since the CLI reads it directly no matter how the shell was started.

---

<div class="post-metadata">

**Author:** ![system](https://sea3.discourse-cdn.com/cursor1/user_avatar/forum.cursor.com/system/32/99069_2.png) [@system](https://forum.cursor.com/u/system)\
**Post date:** [July 18, 2026, 4:59pm UTC](https://forum.cursor.com/t/not-sourceing-bashrc-or-bash-profile-on-linux/162266/10 "2026-07-18T16:59:47Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
