Skip to content

[ty] Add warning message when running ty server interactively#23416

Merged
BurntSushi merged 1 commit intomainfrom
ag/ty-server-stdin-tty-warning
Feb 19, 2026
Merged

[ty] Add warning message when running ty server interactively#23416
BurntSushi merged 1 commit intomainfrom
ag/ty-server-stdin-tty-warning

Conversation

@BurntSushi
Copy link
Member

Copy link
Contributor

@sharkdp sharkdp left a comment

Choose a reason for hiding this comment

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

Thank you!

Comment on lines 79 to 80
let mut stderr = std::io::stderr();
if stderr.is_terminal() {
Copy link
Contributor

Choose a reason for hiding this comment

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

Wait, why are we checking if stderr is a TTY, instead of stdin?

Copy link
Member Author

Choose a reason for hiding this comment

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

Hah, oh man. Because I apparently haven't fully woken up yet. Fixed.

Copy link
Contributor

Choose a reason for hiding this comment

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

In a real LSP scenario, both stdin and stdout are probably connected to the LSP client. Not sure if it's guaranteed that stderr captured/piped as well? Like, I could imagine a scenario where you want to query information from an LSP server from a CLI application. In this case, you might just want to inherit stderr from the parent process to surface any errors from the LSP directly to the terminal?

Copy link
Member Author

Choose a reason for hiding this comment

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

That should work since stdin won't be considered a tty. If the initialization options you send to the LSP server after starting it doesn't have a log file, then tracing is configured to write to stderr.

Comment on lines +81 to +82
writeln!(
stderr,
Copy link
Contributor

Choose a reason for hiding this comment

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

Did you consider using tracing::warn! here? (do we show these by default?)

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes. It was the first thing I tried, but it's not shown by default.

Copy link
Member Author

Choose a reason for hiding this comment

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

The issue is that our tracing stuff isn't configured until the server receives its initialization options. But that's well after the point that an end user trying to run ty server directly will be confused.

@BurntSushi BurntSushi force-pushed the ag/ty-server-stdin-tty-warning branch from f98b286 to 5e81b5a Compare February 19, 2026 12:18
@BurntSushi BurntSushi merged commit e03748c into main Feb 19, 2026
46 checks passed
@BurntSushi BurntSushi deleted the ag/ty-server-stdin-tty-warning branch February 19, 2026 12:34
@sharkdp sharkdp added server Related to the LSP server ty Multi-file analysis & type inference labels Feb 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

server Related to the LSP server ty Multi-file analysis & type inference

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Confusing error message when trying to run ty server in a terminal

2 participants