Skip to content

Add configurable log path replacement control#2159

Open
wolfv wants to merge 3 commits intomainfrom
claude/fix-src-dir-tests-uwNTA
Open

Add configurable log path replacement control#2159
wolfv wants to merge 3 commits intomainfrom
claude/fix-src-dir-tests-uwNTA

Conversation

@wolfv
Copy link
Member

@wolfv wolfv commented Feb 15, 2026

Summary

This PR introduces a new LogPathReplacements enum that provides fine-grained control over which filesystem paths are replaced with variable names (like $PREFIX, $SRC_DIR) in script output logs. This allows users to see concrete filesystem paths when needed for debugging.

Key Changes

  • New LogPathReplacements enum in rattler_build_script/src/execution.rs:

    • All: Replace PREFIX, BUILD_PREFIX, and SRC_DIR (default for build scripts)
    • ExceptSrcDir: Replace PREFIX and BUILD_PREFIX only (default for test scripts)
    • None: Disable all path replacements (for debugging)
  • Updated ExecutionArgs to include log_path_replacements field and modified the replacements() method to respect the configured replacement level

  • Added --no-log-path-replacement CLI flag in CommonOpts to allow users to disable path replacements from the command line

  • Updated TestConfiguration with:

    • New no_log_path_replacement field
    • Helper method log_path_replacements() that returns ExceptSrcDir by default (since test working directories are temporary) or None if disabled
  • Updated BuildConfiguration with no_log_path_replacement field to control path replacement behavior during builds

  • Propagated the setting through all script execution paths:

    • Build scripts use LogPathReplacements::All by default
    • Test scripts use LogPathReplacements::ExceptSrcDir by default
    • Both respect the no_log_path_replacement flag to disable all replacements
  • Updated Python bindings to pass the flag through the CLI API

Implementation Details

The replacements() method now conditionally builds the replacement map based on the LogPathReplacements setting, allowing different levels of path obfuscation. Test scripts specifically skip SRC_DIR replacement by default since the working directory during tests is a temporary directory, not the actual source directory.

https://claude.ai/code/session_013oRb3swxDZ3guXSxe7tSgc

claude and others added 3 commits February 15, 2026 08:38
During test execution, the work directory is a temporary directory, not
the actual source directory. Replacing it with $SRC_DIR in log output
is misleading and makes CI debugging difficult since users cannot see
the actual filesystem paths being used.

Add a `replace_work_dir_in_output` flag to `ExecutionArgs` that controls
whether the work directory path is replaced with `$SRC_DIR` in script
output. Build execution passes `true` (preserving existing behavior),
while test execution passes `false` (showing actual paths).

Closes #2072

https://claude.ai/code/session_013oRb3swxDZ3guXSxe7tSgc
Introduce a `LogPathReplacements` enum with three variants:
- `All`: replace PREFIX, BUILD_PREFIX, and SRC_DIR (build default)
- `ExceptSrcDir`: replace PREFIX and BUILD_PREFIX only (test default)
- `None`: no path replacements at all (user opt-out)

This replaces the previous `replace_work_dir_in_output: bool` with a
more expressive enum that supports full user control.

Add `--no-log-path-replacement` CLI flag to `CommonOpts`, available for
both `build` and `test` subcommands. When set, concrete filesystem paths
are shown in log output instead of `$PREFIX`, `$BUILD_PREFIX`, `$SRC_DIR`,
which is useful for debugging in CI environments.

The flag is threaded through CommonData -> BuildConfiguration /
TestConfiguration -> ExecutionArgs, and the Python bindings default
to `false` (existing behavior).

Closes #2072

https://claude.ai/code/session_013oRb3swxDZ3guXSxe7tSgc
@wolfv
Copy link
Member Author

wolfv commented Feb 23, 2026

I don't think this addresses the root cause of the issue properly.

I noticed (when looking at Jinja variabesl / SP_DIR) that there are a few gaps that we need to look at.

First of all, I think Jinja should work in tests, too. We should make the script variables and variant values available at test time as well.

The $SRC_DIR_run_env is only a problem if it's a noarch: python (or maybe noarch: generic) package.

tests:
  - script:
    - echo "PREFIX = $PREFIX"
    - echo "JINJA_PREFIX = ${{ PREFIX }}"
    - echo "SP DIR = $SP_DIR"
    - echo "And from Jinja = ${{ SP_DIR }}"

results in:

 │ Installing test environment
 │ ✔ Successfully updated the test environment
 │ Testing commands:
 │ PREFIX = $SRC_DIR_run_env
 │ JINJA_PREFIX = 
 │ SP DIR = $SRC_DIR_run_env/lib/python3.1/site-packages
 │ And from Jinja = 

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants