Skip to content

fix: write anchor expand output to stdout#4269

Open
Nicknamess96 wants to merge 1 commit intosolana-foundation:masterfrom
Nicknamess96:fix/expand-stdout
Open

fix: write anchor expand output to stdout#4269
Nicknamess96 wants to merge 1 commit intosolana-foundation:masterfrom
Nicknamess96:fix/expand-stdout

Conversation

@Nicknamess96
Copy link

`anchor expand` saves the macro-expanded source to a timestamped file
under `.anchor/expanded-macros/` and prints the path, which makes it
impossible to pipe the output into other tools.

This patch writes the expanded source directly to stdout so callers can
redirect it (`> file.rs`) or pipe it through formatters and pagers like
any other CLI tool.

The now-unused `chrono` dependency is also removed.

Closes #4267

`anchor expand` previously saved the macro-expanded source to a
timestamped file under `.anchor/expanded-macros/` and printed the path.
This made it impossible to pipe the output into other tools.

Write the expanded source directly to stdout instead, so callers can
use standard shell redirection (`> file.rs`) or pipe it through
formatters and pagers.

The `chrono` dependency is dropped since timestamps are no longer
needed for the file name.

Closes solana-foundation#4267
@vercel
Copy link

vercel bot commented Feb 27, 2026

@Nicknamess96 is attempting to deploy a commit to the Solana Foundation Team on Vercel.

A member of the Team first needs to authorize it.

Comment on lines 1668 to 1669
.stderr(Stdio::inherit())
.output()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can just pipe stderr straight to our own stdout

Suggested change
.stdout(std::process::Stdio::null())
.stderr(std::io::stdout())
.status()

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.

anchor expand must dump to stdout

2 participants