[BUG] Claude ENV variables present in tools context, causes clashes with things like oTel Settings

Resolved 💬 3 comments Opened Sep 30, 2025 by petems Closed Jan 8, 2026

Preflight Checklist

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

What's Wrong?

Claude environemnt variables used for things like configuring oTel seem to leak into the bash tool's env settings, leading to conflicts with things like Terraform which also uses the same env setting:

OTEL_TRACES_EXPORTER is used across the oTel SDK so it'd theoretically cause issues with any tooling thats got oTel in it, although Terraform seems to be the main issue as it doen't support "otlp" as a value when CC does

I get for things like HTTP_PROXY you'd want to propogate that to the bash commands, but is there a way of whitelisting/picking what env variables get passed on to the bash calls?

What Should Happen?

Claude should not add additional context to the bash environment in tools where possible

Error Messages/Logs

> Do a terraform output and show the results
 I'll run terraform output to show the current state outputs.
 Bash(terraform output)
  ⎿  Error: Could not initialize telemetry: invalid OTLP protocol - should be one of ['grpc', 'http/protobuf']
     Unset environment variable OTEL_TRACES_EXPORTER if you don't intend to collect telemetry from Terraform.
 Bash(unset OTEL_TRACES_EXPORTER && terraform output)
  ⎿  all_service_urls = {
       "cthulhu" = "https://example.com"
     … +70 lines (ctrl+o to expand)

Steps to Reproduce

  1. Create a settings.json with the following:
{
  "env": {
    "CLAUDE_CODE_ENABLE_TELEMETRY": "1",
    "OTEL_METRICS_EXPORTER": "otlp"
  }
}
  1. Ask Claude to run terraform or see what the current value of OTEL_METRICS_EXPORTER is
  2. Expected Unset
  3. Actual: Value from settings.json

Claude Model

Sonnet (default)

Is this a regression?

I don't know

Last Working Version

_No response_

Claude Code Version

2.0.1

Platform

Anthropic API

Operating System

macOS

Terminal/Shell

Terminal.app (macOS)

Additional Information

_No response_

View original on GitHub ↗

This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗