Skip to content

zed: Hide log file actions when logging to stdout - #57114

Merged
dinocosta merged 4 commits into
zed-industries:mainfrom
tredondo:fix-log-file-not-created-from-terminal
Jun 10, 2026
Merged

zed: Hide log file actions when logging to stdout#57114
dinocosta merged 4 commits into
zed-industries:mainfrom
tredondo:fix-log-file-not-created-from-terminal

Conversation

@tredondo

@tredondo tredondo commented May 19, 2026

Copy link
Copy Markdown
Contributor

When running zed directly from a foreground terminal (stable zed-editor, or zed dev builds via cargo run as in #51351), Zed only enables the stdout log sink and never creates Zed.log on disk. This causes zed: open log and zed: reveal log in file manager to always failed with Unable to access/open log file ...: Failed to read file... No such file or directory (os error 2).

Per maintainer feedback, rather than always creating the log file, this change only registers the OpenLog and RevealLogInFileManager action handlers when stdout isn't a PTY. In the PTY case the two actions no longer appear in the command palette at all, so they can't be invoked only to error.

Repro (before this change):

  1. rm -rf ~/.local/share/zed/logs/
  2. ~/.local/zed.app/libexec/zed-editor (the GUI binary directly, bypassing the CLI wrapper which detaches and sets ZED_FORCE_CLI_MODE)
  3. In Zed, run zed: open log → error toast

Release Notes:

  • Fixed zed: open log and zed: reveal log in file manager appearing and erroring when Zed was launched directly from a terminal. These actions are now hidden in that scenario, since logs go to stdout rather than Zed's log file.

@cla-bot cla-bot Bot added the cla-signed The user has signed the Contributor License Agreement label May 19, 2026
@tredondo
tredondo force-pushed the fix-log-file-not-created-from-terminal branch 3 times, most recently from f5b6932 to cb23ee4 Compare May 21, 2026 11:50
@tredondo
tredondo marked this pull request as ready for review May 21, 2026 11:50

@dinocosta dinocosta left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Hey @tredondo ! 👋

I've chatted about this with the team and, although this seems like a valid UX concern, as we're displaying actions in the command palette which will lead to an error when run, we believe we don't want to always be creating this file.

As a suggestion, we can probably update zed::init such that the action handlers for both OpenLog and RevealLogInFileManager are only registered if crate::stdout_is_a_pty is false, that way those two actions will not show up in the command palette.

Feel free to update your changes 🙂

@tredondo
tredondo force-pushed the fix-log-file-not-created-from-terminal branch from cb23ee4 to 6fd4b66 Compare May 28, 2026 19:24
@smitbarmase smitbarmase added the area:logging Feedback for logs, debug output, etc label May 29, 2026
@dinocosta dinocosta self-assigned this May 29, 2026
`zed: open log` and `zed: reveal log in file manager` operate on `Zed.log`,
which is only written when Zed logs to a file. When stdout is a PTY (e.g.
running the `zed-editor` binary or `cargo run` directly from a terminal),
logs go to stdout and the file is never created, so both actions failed
with "Unable to access/open log file...: No such file or directory".

Only register the two action handlers when stdout isn't a PTY, so they no
longer appear in the command palette instead of showing up and erroring
when invoked.

Release Notes:

- Fixed `zed: open log` and `zed: reveal log in file manager` erroring when
  Zed was launched directly from a terminal; they are now hidden in that
  case, since logs go to stdout rather than a file.
@tredondo
tredondo force-pushed the fix-log-file-not-created-from-terminal branch from 6fd4b66 to f0b5a48 Compare June 9, 2026 21:08
@tredondo tredondo changed the title zed: Create log file even when launched from a terminal zed: Hide log file actions when logging to stdout Jun 9, 2026
@tredondo

tredondo commented Jun 9, 2026

Copy link
Copy Markdown
Contributor Author

@dinocosta Made the change, sorry it took so long.

@zed-industries-bot

zed-industries-bot commented Jun 10, 2026

Copy link
Copy Markdown
Contributor
Messages
📖

This PR includes links to the following GitHub Issues: #51351
If this PR aims to close an issue, please include a Closes #ISSUE line at the top of the PR body.

Generated by 🚫 dangerJS against c644f03

@dinocosta dinocosta left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thank you @tredondo ! 🙂

@dinocosta
dinocosta enabled auto-merge June 10, 2026 22:11
@dinocosta
dinocosta added this pull request to the merge queue Jun 10, 2026
Merged via the queue into zed-industries:main with commit 501ab50 Jun 10, 2026
34 checks passed
@tredondo
tredondo deleted the fix-log-file-not-created-from-terminal branch June 10, 2026 22:59
@tredondo

Copy link
Copy Markdown
Contributor Author

@dinocosta: happy to help! Any chance to take a look at #57376? It's also small (a dozen lines).

@tredondo

Copy link
Copy Markdown
Contributor Author

@dinocosta I'm having a second though about the final version of this PR: it worsens observability and makes forensic investigations impossible after the terminal window was closed.

I was trying to figure out what clobbered the mtime of hundreds of files in my repo, and Zed's log would've been key in solving that mystery. However, because I'm running the dev build, all logging when to the terminal and not to any file. In the intervening days, the terminal was closed and logs were lost.

Could the team revisit this?

as we're displaying actions in the command palette which will lead to an error when run

My first fix prevented those errors, because the log file was always created.

@dinocosta

Copy link
Copy Markdown
Member

@dinocosta: happy to help! Any chance to take a look at #57376? It's also small (a dozen lines).

I'll see if I can have someone more familiar with our Markdown-rendering take a look at it. I can see it's already been labelled appropriately, so someone should eventually take a look 🙂

@dinocosta I'm having a second though about the final version of this PR: it worsens observability and makes forensic investigations impossible after the terminal window was closed.

I was trying to figure out what clobbered the mtime of hundreds of files in my repo, and Zed's log would've been key in solving that mystery. However, because I'm running the dev build, all logging when to the terminal and not to any file. In the intervening days, the terminal was closed and logs were lost.

Could the team revisit this?

as we're displaying actions in the command palette which will lead to an error when run

My first fix prevented those errors, because the log file was always created.

Believe we'll want to keep it as is, as Zed does not currently take the release channel into consideration for the log file. This would mean that the logs from a development build would clutter the log file for the stable release.

Creating the log file is also not enough, as we'd need to change how Zed decides whether to output to the terminal or the log file to now output to both when running a development build.

Having said that, there's still a couple of ways you could persist those logs:

  1. Using script to record the terminal session. For example, script -q zed.log cargo run on macOS or script -q -c "cargo run" zed.log on Linux.
  2. Redirecting Zed's output, which will trigger the non-TTY code path. For example, if you run a development build with cargo run > /dev/null this will append the logs to the default Zed.log file, and will also show zed: open log and zed: reveal log in file manager actions.

Hope that helps!

jonx pushed a commit to jonx/zed-aros that referenced this pull request Jul 17, 2026
When running `zed` [directly from a foreground
terminal](zed-industries#51351 (comment))
(stable `zed-editor`, or zed dev builds via `cargo run` as in zed-industries#51351),
Zed only enables the stdout log sink and never creates `Zed.log` on
disk. This causes `zed: open log` and `zed: reveal log in file manager`
to always failed with `Unable to access/open log file ...: Failed to
read file... No such file or directory (os error 2)`.

Per maintainer feedback, rather than always creating the log file, this
change only registers the `OpenLog` and `RevealLogInFileManager` action
handlers when stdout isn't a PTY. In the PTY case the two actions no
longer appear in the command palette at all, so they can't be invoked
only to error.

Repro (before this change):
1. `rm -rf ~/.local/share/zed/logs/`
2. `~/.local/zed.app/libexec/zed-editor` (the GUI binary directly,
bypassing the CLI wrapper which detaches and sets `ZED_FORCE_CLI_MODE`)
3. In Zed, run `zed: open log` → error toast

Release Notes:

- Fixed `zed: open log` and `zed: reveal log in file manager` appearing
and erroring when Zed was launched directly from a terminal. These
actions are now hidden in that scenario, since logs go to stdout rather
than Zed's log file.

---------

Co-authored-by: dino <dinojoaocosta@gmail.com>
jolutz pushed a commit to jolutz/zed that referenced this pull request Aug 8, 2026
When running `zed` [directly from a foreground
terminal](zed-industries#51351 (comment))
(stable `zed-editor`, or zed dev builds via `cargo run` as in zed-industries#51351),
Zed only enables the stdout log sink and never creates `Zed.log` on
disk. This causes `zed: open log` and `zed: reveal log in file manager`
to always failed with `Unable to access/open log file ...: Failed to
read file... No such file or directory (os error 2)`.

Per maintainer feedback, rather than always creating the log file, this
change only registers the `OpenLog` and `RevealLogInFileManager` action
handlers when stdout isn't a PTY. In the PTY case the two actions no
longer appear in the command palette at all, so they can't be invoked
only to error.

Repro (before this change):
1. `rm -rf ~/.local/share/zed/logs/`
2. `~/.local/zed.app/libexec/zed-editor` (the GUI binary directly,
bypassing the CLI wrapper which detaches and sets `ZED_FORCE_CLI_MODE`)
3. In Zed, run `zed: open log` → error toast

Release Notes:

- Fixed `zed: open log` and `zed: reveal log in file manager` appearing
and erroring when Zed was launched directly from a terminal. These
actions are now hidden in that scenario, since logs go to stdout rather
than Zed's log file.

---------

Co-authored-by: dino <dinojoaocosta@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:logging Feedback for logs, debug output, etc cla-signed The user has signed the Contributor License Agreement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants