rust-unsafe-env-mutation

Community

Safely serialize Rust env var mutations in tests.

Author89jobrien
Version1.0.0
Installs0

System Documentation

What problem does it solve?

In Rust 2024, mutating process-wide environment variables with std::env::set_var or remove_var can cause data races when tests run in parallel. This pattern introduces a static Mutex<()> to serialize access and prevent flaky CI results.

Core Features & Use Cases

  • Serialization with a shared mutex: guard env var mutations behind a single lock to ensure consistency across tests.
  • Cross-file safety: applies to multiple test modules that touch the same environment variables.
  • Cleanup guarantees: ensures env vars are restored after tests, even if a test panics.

Quick Start

Create a static ENV_MUTEX and wrap all env-var mutations with a lock around the critical section.

Dependency Matrix

Required Modules

None required

Components

Standard package

💻 Claude Code Installation

Recommended: Let Claude install automatically. Simply copy and paste the text below to Claude Code.

Please help me install this Skill:
Name: rust-unsafe-env-mutation
Download link: https://github.com/89jobrien/dotfiles/archive/main.zip#rust-unsafe-env-mutation

Please download this .zip file, extract it, and install it in the .claude/skills/ directory.
View Source Repository

Agent Skills Search Helper

Install a tiny helper to your Agent, search and equip skill from 471,000+ vetted skills library on demand.