aws / aws/amazon-q-developer-cli
bug: Environment variables not persisting across qcli native tool invocations
- Dominant language
- Rust
- Stars
- 2k
- Forks
- 439
- PR merge metrics
- No merged PRs in 30d
Description
### Checks
- [x] I have searched [github.com/aws/amazon-q-developer-cli/issues](https://github.com/aws/amazon-q-developer-cli/issues?q=) and there are no duplicates of my issue
- [x] I have run `q doctor` in the affected terminal session
- [x] I have run `q restart` and replicated the issue again
### Operating system
MacOS
### Expected behaviour
Environment variables set during a qcli session should persist across tool invocations within the same session.
### Actual behaviour
Env variables are not persisted across the tool invocations.
```
> export A=B
> I'll help you with that command. The command export A=B sets an environment variable named "A" with the value "B" in your shell session. Let me execute this for you:
🛠️ Using tool: execute_bash
⋮
● I will run the following shell command: export A=B
⋮
↳ Purpose: Setting environment variable A to value B
Allow this action? Use 't' to trust (always allow) this tool for the session. [y/n/t]:
> y
⋮
● Completed in 0.4s
> The environment variable A has been set to B successfully. This variable will be available in your current shell session and any child processes you launch from this session.
If you want to verify that the variable was set correctly, you can run:
echo $A
Note that this environment variable will only persist for the duration of your current shell session. If you want to make it permanent, you would need to add this export command to your shell configuration file (
like ~/.zshrc or ~/.bash_profile).
> echo $A
> I'll help you check the value of the environment variable A. Let me execute the echo command for you:
🛠️ Using tool: execute_bash (trusted)
⋮
● I will run the following shell command: echo $A
⋮
↳ Purpose: Displaying the value of environment variable A
⋮
● Completed in 0.5s
> It seems that the output is empty, which suggests that the environment variable A is not set in the current environment.
```
### Steps to reproduce
```
# in q chat session
> export A=B
> echo $A
```
### Environment
```yaml
➜ ~ q diagnostic
[q-details]
version = "1.12.6"
hash = "9c083cf7e8f7de077eb116c3993823b82f71ca12"
date = "2025-07-18T21:39:58.652366Z (3d ago)"
variant = "full"
[system-info]
os = "macOS 15.5.0 (24F74)"
chip = "Apple M3 Pro"
total-cores = 12
memory = "36.00 GB"
[environment]
cwd = "/Users/USER"
cli-path = "/Users/USER"
os = "Mac"
shell-path = "/bin/zsh"
shell-version = "5.9"
terminal = "iTerm 2"
install-method = "unknown"
[env-vars]
PATH = "/Library/Java/JavaVirtualMachines/amazon-corretto-17.jdk/Contents/Home/bin:/Users/USER/.codeium/windsurf/bin:/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/local/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal/bin:/Users/USER/.cargo/bin:/Applications/iTerm.app/Contents/Resources/utilities:/Users/USER/.local/bin:/Applications/Visual Studio Code.app/Contents/Resources/app/bin:/opt/homebrew/opt/fzf/bin:/Users/USER/.toolbox/bin"
QTERM_SESSION_ID = "979d3f8023824f7da2c314cf32136b80"
Q_SET_PARENT_CHECK = "1"
Q_TERM = "1.12.6"
SHELL = "/bin/zsh"
TERM = "xterm-256color"
__CFBundleIdentifier = "com.googlecode.iterm2"
```
Contributor guide
Assessment
This issue has not been assessed yet.