Skip to content

Feature request: rtk passthrough for env -u/env VAR=val command prefix #1606

Closed as duplicate

Description

@mshogin

Real-world numbers from rtk discover --all --since 30:

Pattern Calls (30d)
env -u VAR ... <cmd> 92

The env prefix (used to unset/override environment variables before invoking another binary, e.g. env -u HTTP_PROXY -u HTTPS_PROXY curl ...) is a common workaround in environments where certain env vars need to be stripped for specific commands. Today this prefix prevents rtk from rewriting the inner command, because the rewrite engine matches on the leading token, sees env, and bails out.

Suggested wrapper behavior:

rtk env <env-args> <inner-cmd> <inner-args...> should:

  1. Parse env flags / VAR=value assignments / -u VAR removals up to the first non-env token
  2. Recursively rewrite the inner command via the standard rtk rewrite pipeline
  3. Re-emit env <env-args> <rewritten-inner-cmd> so the env modifications still apply

Example:

  • Input: env -u HTTP_PROXY -u HTTPS_PROXY curl -s https://example.com/api
  • Output: env -u HTTP_PROXY -u HTTPS_PROXY rtk curl -s https://example.com/api

This mirrors what rtk already does for direct invocations, but lets the env prefix pass through transparently. The savings come from the inner command's normal RTK filter (curl, go, node, etc.), not from env itself.

Methodology: counts come from rtk discover --all --since 30 against the local Claude Code transcript directory.

Activity

  1. added
    effort-medium
    enhancement
    on Apr 29, 2026
  2. pszymkowiak commented on Apr 29, 2026

    @pszymkowiak
    Collaborator

    wshm · Automated triage by AI

    🔍 Automated Triage

    ✨ Category feature
    🟡 Priority medium
    🎯 Confidence 91%

    Summary

    Feature request to support env -u VAR/env VAR=val command prefix passthrough so rtk can still rewrite the inner command; well-scoped with usage data and clear spec.


    Triaged automatically by wshm · This is an automated analysis, not a human review.

  3. fu050409 commented on Aug 25, 2026

    @fu050409

    I’ve encountered a similar situation: in the development of some projects, the Agent makes extensive use of commands with the env prefix.

  4. fu050409 commented on Aug 25, 2026

    @fu050409

    Hi, @mshogin! I found a workaround that preserves the native env behavior without requiring RTK to implement or emulate it.

    Instead of:

    rtk env X=Y cargo test

    the agent should place the environment prefix before RTK:

    env X=Y rtk cargo test

    The system env command sets the variable for the RTK process, and RTK passes that environment through to the command it dispatches. This allows cargo test—or any other supported command—to keep benefiting from RTK's token-saving filters.

    The underlying issue is that the current agent context says to always place rtk at the beginning, which can lead agents to generate rtk env ... and bypass filtering for the inner command.

    I've created a pull request at #3706, regardless of whether my PR is accepted by the maintainer, we can use a workaround by modifying the context on our local device or explicitly informing the Agent during the session.

  5. KuSh commented on Oct 3, 2026

    @KuSh
    Collaborator

    Closing in favour of #4099, which asks for the same thing, rewriting through env -u VAR <cmd> while keeping the env prefix. PR #4115 implements it there. env VAR=val already rewrites today. Please follow up on #4099.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:clieffort-mediumenhancementhelp wantedpriority:medium

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions