claude-code - 💡(How to fix) Fix Claude Code shell does not inherit AWS_REGION from user's terminal session

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…

When Claude Code runs Bash tool calls, the shell does not inherit environment variables set in the user's terminal session — specifically AWS_REGION (and AWS_DEFAULT_REGION). This causes all aws CLI and pulumi commands that depend on region configuration to silently fall back to us-east-1, even when the user has AWS_REGION=us-west-2 set in their own shell.

Root Cause

When Claude Code runs Bash tool calls, the shell does not inherit environment variables set in the user's terminal session — specifically AWS_REGION (and AWS_DEFAULT_REGION). This causes all aws CLI and pulumi commands that depend on region configuration to silently fall back to us-east-1, even when the user has AWS_REGION=us-west-2 set in their own shell.

Fix Action

Workaround

Prefix every aws/pulumi Bash call with the region inline:

AWS_REGION=us-west-2 aws ecs list-clusters
AWS_REGION=us-west-2 pulumi up --stack stage

This is workable but requires the region to be hardcoded in project instructions (CLAUDE.md).

Code Example

AWS_REGION=us-west-2 aws ecs list-clusters
AWS_REGION=us-west-2 pulumi up --stack stage
RAW_BUFFERClick to expand / collapse

Description

When Claude Code runs Bash tool calls, the shell does not inherit environment variables set in the user's terminal session — specifically AWS_REGION (and AWS_DEFAULT_REGION). This causes all aws CLI and pulumi commands that depend on region configuration to silently fall back to us-east-1, even when the user has AWS_REGION=us-west-2 set in their own shell.

Steps to Reproduce

  1. In your terminal, run export AWS_REGION=us-west-2
  2. Open Claude Code in that terminal (or in a project where it's launched from that session)
  3. Ask Claude to run any AWS CLI command, e.g. aws ecs list-clusters
  4. The command executes against us-east-1 instead of us-west-2

Expected Behavior

Claude Code's Bash tool should inherit environment variables from the shell session it was launched from, or at minimum respect AWS_REGION / AWS_DEFAULT_REGION if set in the user's environment.

Actual Behavior

The Bash tool uses a fresh shell that does not inherit the user's exported environment variables. Region-dependent AWS and Pulumi commands silently use the wrong region.

Workaround

Prefix every aws/pulumi Bash call with the region inline:

AWS_REGION=us-west-2 aws ecs list-clusters
AWS_REGION=us-west-2 pulumi up --stack stage

This is workable but requires the region to be hardcoded in project instructions (CLAUDE.md).

Environment

  • Platform: macOS (darwin)
  • Shell: zsh
  • Claude Code version: current

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

claude-code - 💡(How to fix) Fix Claude Code shell does not inherit AWS_REGION from user's terminal session