Skip to content

fix: redirect tracing output to stderr to avoid breaking PEP 517#3131

Merged
messense merged 2 commits into
PyO3:mainfrom
chrisburr:fix/tracing-output-leak
Apr 10, 2026
Merged

fix: redirect tracing output to stderr to avoid breaking PEP 517#3131
messense merged 2 commits into
PyO3:mainfrom
chrisburr:fix/tracing-output-leak

Conversation

@chrisburr

Copy link
Copy Markdown
Contributor

Since v1.13.0, pip install --no-build-isolation has been broken when RUST_LOG is set. The tracing subscriber added in v1.13.0 uses fmt::layer(), which defaults to stdout. PEP 517 uses stdout as a structured channel (pip reads the last line to find metadata directory names) so tracing output corrupts the path.

This PR fixes the issue by:

  • adding .with_writer(std::io::stderr) to the tracing subscriber setup
  • adding a regression test verifying tracing output stays on stderr

When RUST_LOG is set, tracing output must go to stderr so it doesn't
corrupt the PEP 517 protocol's stdout channel that pip relies on for
metadata discovery.
tracing_subscriber::fmt::layer() defaults to stdout, which corrupts
the PEP 517 protocol when RUST_LOG is set — pip reads stdout to find
metadata directory names and fails when tracing lines are mixed in.
@messense

Copy link
Copy Markdown
Member

Thanks for the PR, I thought tracing subscriber was added years ago?
https://github.com/PyO3/maturin/blame/a025a1f0046314589add2b20e158cb303646867c/src/main.rs#L322-L332

@chrisburr

Copy link
Copy Markdown
Contributor Author

Thanks for the quick review.

I thought tracing subscriber was added years ago?

Maybe I've misdiagnosed exactly what the origin of the break is. The symptom which triggered this was that this CI job started failing with the latest maturin release: https://github.com/prefix-dev/pixi/actions/runs/24230829818/job/70744566427

Regardless, I think this is still the correct fix.

@messense messense enabled auto-merge (squash) April 10, 2026 08:53
@messense

messense commented Apr 10, 2026

Copy link
Copy Markdown
Member

It would be great if you can test this so we can verify it actually fixes the issue (maybe dropping RUST_LOG makes it pass is a good sign?). But this PR can be merged regardless of the that. Thanks!

@messense messense merged commit f19867f into PyO3:main Apr 10, 2026
45 checks passed
@chrisburr chrisburr deleted the fix/tracing-output-leak branch April 10, 2026 09:03
@chrisburr

Copy link
Copy Markdown
Contributor Author

I'm fairly confident this fixes the issue as dropping RUST_LOG fixes the pixi test suite where I originally saw this issue.

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