aws / aws/amazon-q-developer-cli
bug: q doctor does not detect .zshrc integration scripts inside if statements
- 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
Linux 5.10.238-212.953.amzn2int.x86_64 - Amazon Linux 2
### Expected behaviour
`q doctor` passes for the zshrc shell integration when the script is within an `if` statement at the top and bottom of the file.
### Actual behaviour
The zsh integration fails to detect the first line of the script within the `if` statement. Even with a successful integration into the `.zshrc` file, it fails.
```text
✘ zsh ~/.zshrc integration check: /home/frashen/.zshrc does not source pre integration first
```
### Steps to reproduce
Copy this block to the top of the `.zshrc` file.
```bash
# Amazon Q pre block. Keep at the top of this file.
if [[ $os == "Darwin" ]]; then
[[ -f "${HOME}/Library/Application Support/amazon-q/shell/zshrc.pre.zsh" ]] && builtin source "${HOME}/Library/Application Support/amazon-q/shell/zshrc.pre.zsh"
else
[[ -f "${HOME}/.local/share/amazon-q/shell/zshrc.pre.zsh" ]] && builtin source "${HOME}/.local/share/amazon-q/shell/zshrc.pre.zsh"
fi
```
Copy this block to the bottom of the `.zshrc` file.
```bash
# Amazon Q post block. Keep at the bottom of this file.
if [[ $os == "Darwin" ]]; then
[[ -f "${HOME}/Library/Application Support/amazon-q/shell/zshrc.post.zsh" ]] && builtin source "${HOME}/Library/Application Support/amazon-q/shell/zshrc.post.zsh"
else
[[ -f "${HOME}/.local/share/amazon-q/shell/zshrc.post.zsh" ]] && builtin source "${HOME}/.local/share/amazon-q/shell/zshrc.post.zsh"
fi
```
Source the `.zshrc` file.
```bash
source ~/.zshrc
```
Run the doctor command.
```bash
q doctor --all
```
Inspect the failing output for the zsh integration.
```text
✘ zsh ~/.zshrc integration check: /home/USER/.zshrc does not source pre integration first
```
### Environment
```yaml
[q-details]
version = "1.13.0"
hash = "5f91e9a7619f1460eb2a017f4df5ca8d6bcd01fa"
date = "2025-07-31T03:22:55.322798Z (1d ago)"
variant = "minimal"
[system-info]
chip = "Intel(R) Xeon(R) Platinum 8488C"
total-cores = 8
memory = "30.81 GB"
[system-info.os.linux]
kernel_version = "5.10.238-212.953.amzn2int.x86_64"
id = "amzn"
name = "Amazon Linux"
pretty_name = "Amazon Linux 2"
version_id = "2"
version = "2"
variant = "internal"
[environment]
cwd = "/local/home/USER/repos/dotfiles"
cli-path = "/local/home/USER/repos/dotfiles"
os = "Linux"
shell-path = "/usr/bin/zsh"
shell-version = "5.8"
install-method = "toolbox"
in-ssh = true
[env-vars]
PATH = "/usr/local/bin/:/home/linuxbrew/.linuxbrew/opt/ruby/bin:/home/linuxbrew/.linuxbrew/opt/node:/home/linuxbrew/.linuxbrew/opt/python@3.13/libexec/bin:/home/linuxbrew/.linuxbrew/bin:/home/linuxbrew/.linuxbrew/sbin:/home/USER/.gem/bin:/usr/local/opt/ssh-copy-id/bin:/home/USER/.local/bin:/usr/local/opt/sqlite/bin:/usr/local/bin:/usr/bin:/home/USER/bin:/usr/local/sbin:/usr/sbin:/home/USER/.local/bin:/home/USER/.toolbox/bin:/home/USER/workplace/dotfiles/src/FrashenDotfiles/bin/"
Q_SET_PARENT_CHECK = "1"
SHELL = "/bin/zsh"
TERM = "xterm-kitty"
```
Contributor guide
Assessment
This issue has not been assessed yet.