claude-code - 💡(How to fix) Fix [BUG] Environment variables defined in Local Settings are ignored if any Environment Variables are defined in Managed Settings

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…

Error Message

Error Messages/Logs

Code Example

{
    "env": {
        "CLAUDE_CODE_ENABLE_TELEMETRY": "1",
        "OTEL_EXPORTER_OTLP_PROTOCOL": "http/json",
        "OTEL_LOGS_EXPORTER": "otlp",
        "OTEL_METRICS_EXPORTER": "otlp",
        "OTEL_METRIC_EXPORT_INTERVAL": "60000",
        "CLAUDE_CODE_USE_BEDROCK": "1",
        "AWS_PROFILE": "bedrock",
        "ANTHROPIC_DEFAULT_SONNET_MODEL": "us.anthropic.claude-sonnet-4-6"
    }
}

---

"env": {
    "OTEL_RESOURCE_ATTRIBUTES": "user.email=<my email>,user.name=Matthew"
  },

---



---

{
    "env": {
        "CLAUDE_CODE_ENABLE_TELEMETRY": "1",
        "OTEL_EXPORTER_OTLP_PROTOCOL": "http/json",
        "OTEL_LOGS_EXPORTER": "otlp",
        "OTEL_METRICS_EXPORTER": "otlp",
        "OTEL_METRIC_EXPORT_INTERVAL": "60000",
        "CLAUDE_CODE_USE_BEDROCK": "1",
        "AWS_PROFILE": "bedrock",
        "ANTHROPIC_DEFAULT_SONNET_MODEL": "us.anthropic.claude-sonnet-4-6"
    }
}

---

{
    "env": {
        "ANTHROPIC_DEFAULT_HAIKU_MODEL": "us.anthropic.claude-haiku-4-5-20251001-v1:0"
    }
}
RAW_BUFFERClick to expand / collapse

Preflight Checklist

  • I have searched existing issues and this hasn't been reported yet
  • This is a single bug report (please file separate reports for different bugs)
  • I am using the latest version of Claude Code

What's Wrong?

When I have a managed settings file defined with an env block, such as below:

{
    "env": {
        "CLAUDE_CODE_ENABLE_TELEMETRY": "1",
        "OTEL_EXPORTER_OTLP_PROTOCOL": "http/json",
        "OTEL_LOGS_EXPORTER": "otlp",
        "OTEL_METRICS_EXPORTER": "otlp",
        "OTEL_METRIC_EXPORT_INTERVAL": "60000",
        "CLAUDE_CODE_USE_BEDROCK": "1",
        "AWS_PROFILE": "bedrock",
        "ANTHROPIC_DEFAULT_SONNET_MODEL": "us.anthropic.claude-sonnet-4-6"
    }
}

if I then have a local settings file with an env block, such as below:

  "env": {
    "OTEL_RESOURCE_ATTRIBUTES": "user.email=<my email>,user.name=Matthew"
  },

any environment variables defined in the local settings file are ignored. Effectively, the env blocks do not merge.

What Should Happen?

Keys in the managed settings file should take precedent. But if there are nested keys in the env block, then so long as the nested key doesn't exist in the managed settings block, it should be respected and used.

Error Messages/Logs

Steps to Reproduce

  1. Create a managed settings file at /Library/Application\ Support/ClaudeCode/managed-settings.json with the following block:
{
    "env": {
        "CLAUDE_CODE_ENABLE_TELEMETRY": "1",
        "OTEL_EXPORTER_OTLP_PROTOCOL": "http/json",
        "OTEL_LOGS_EXPORTER": "otlp",
        "OTEL_METRICS_EXPORTER": "otlp",
        "OTEL_METRIC_EXPORT_INTERVAL": "60000",
        "CLAUDE_CODE_USE_BEDROCK": "1",
        "AWS_PROFILE": "bedrock",
        "ANTHROPIC_DEFAULT_SONNET_MODEL": "us.anthropic.claude-sonnet-4-6"
    }
}
  1. In your local settings file, add the following env block:
{
    "env": {
        "ANTHROPIC_DEFAULT_HAIKU_MODEL": "us.anthropic.claude-haiku-4-5-20251001-v1:0"
    }
}
  1. Restart Claude.
  2. The default haiku model defined in your local settings file will not be respected.

Claude Model

Not sure / Multiple models

Is this a regression?

Yes, this worked in a previous version

Last Working Version

No response

Claude Code Version

2.1.145

Platform

AWS Bedrock

Operating System

macOS

Terminal/Shell

Warp

Additional Information

No response

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