Urgent.News

What's breaking now, across thousands of outlets.

AI

Claude Code Env Vars Don't Persist: 3 of 80 Runs Fell Back to Prod

I told Claude Code export APP_ENV=staging . My next message said to run the script. It printed target = production . Nothing got deployed. target.py is a one-line stub in a throwaway repo, built around os.environ.get("APP_ENV", "production") , a default you've probably seen in real code. But Claude Code env vars don't persist between Bash tool calls, and I wanted to know how often that actually…

Claude Code env vars do not persist between Bash tool calls, which led to inconsistencies in the results of a test run. Claude Code starts a new shell with each Bash tool call, so any environment variables held in memory are lost. The only thing that persists across calls is the working directory.

To make Claude Code env vars persist, you can set them before the session starts. For plain values, add them to the settings.json file. For virtual environments, use a SessionStart hook to write the activation command and environment variables to a $CLAUDE_ENV_FILE file that is sourced by every subsequent Bash call. Alternatively, you can set the CLAUDE_ENV_FILE environment variable to a file containing the activation command and variables, and launch Claude from that file.

Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.

Read the original at dev.to →

More in AI

Tencent’s SilentMind AI Sparks Global Censorship Alarm

Tencent’s “SilentMind” AI Model Triggers a Wave of Censorship Concerns – What You Need to Know Introduction Tencent just launched SilentMind , an LLM that ships with a hard‑wired censorship layer…

  • Searches for SilentMind censorship surged 420% on Google Trends within 48 hours.
  • Filters cannot be turned off for public API, raising compliance risks under EU and US laws.

More from Thursday 5 November →