yazi: Crash with micro text editor after editing and saving files

What system are you running Yazi on?

Linux Wayland

What terminal are you running Yazi in?

foot version: 1.16.2

Yazi version

yazi 0.1.5 (82bab0f 2023-12-26)

Did you try the latest main branch to see if the problem has already been fixed?

Tried, but the problem is still present

Describe the bug

Opening a file with micro, editing a single character, saving and closing the file leads to:

Backtrace (most recent call first):

The application panicked (crashed).
  panic in a function that cannot unwind
in library/core/src/panicking.rs, line 136
thread: tokio-runtime-worker

This only seems to happen when files are at least 2 folders away from yazi’s starting directory.

Expected Behavior

Yazi should not crash.

To Reproduce

See above.

Configuration

No response

Anything else?

No response

About this issue

  • Original URL
  • State: closed
  • Created 6 months ago
  • Reactions: 1
  • Comments: 19 (13 by maintainers)

Most upvoted comments

As for .json preview, it’s a breaking change - prior to Yazi v0.2.0, it would call jq first, and if that call failed (e.g., if the user hadn’t installed it), it would fallback to Yazi’s built-in code highlighting.

However, this behavior is inefficient for users who never installed jq but always use the built-in highlighting - it constantly creates processes to attempt whether jq is installed.

In Yazi v0.2.0, this fallback has been removed. When users don’t really need jq, they can directly specify Yazi’s built-in highlighting for the .json preview:

# yazi.toml
[plugin]
previewers = [
	# ...
	# { mime = "application/json", exec = "json.lua" },   # <-- Remove this line

	{ mime = "application/json", exec = "code.lua" },   # <-- Add this line
]

Try to add this line to the previewers. For now, please copy the entire previewers. I will add new options before the release of Yazi v0.2.0 to allow users to selectively override certain previewers.

I think I’ve pinpointed the issue, which might be a bug in mlua. I’m not sure how to handle it yet, so I’ve decided to temporarily disable it.

I made a PR to fix it, https://github.com/sxyazi/yazi/pull/459, please give it a try and let me know if it works for you.

I think this issue has been resolved, so let me close it now.

BTW, in order to reduce the impact of v0.2.0 on user behavior, I’ve decided to reintroduce the fallback. 🤣

However, for users who never use jq, we now have an additional mechanism for selective opt-out - they can remove json.lua from the previewers, that’s enough.

Hi, I pushed a new commit in that PR. Please try it out again to see if it works. Hope it’s effective 😃

yazi built with that commit doesn’t “show” any files here at all (only previews), unfortunately… : (

EDIT: I used: linemode = "mtime" With: linemode = "none" files “reappeared”…

Should be fixed in https://github.com/sxyazi/yazi/commit/bfa5e0af0c5493d1420d68b3346be808177f496c, thanks for the report!

Same here. The PR fixes editing files with micro, but scrolling over text files with a preview causes the same crash.

Hi, I pushed a new commit in that PR. Please try it out again to see if it works. Hope it’s effective 😃

@sxyazi The latest PR does fix crashing on renaming/editing files, but yazi still crashes with the error message from OP when hovering over certain file types - but I haven’t figured out which types AND this behavior is not consistent across different HW (always Arch Linux with wayland) Thank you for your time and work!

EDIT: I haven’t had any crashes on one machine so far, it’s only happening on the “weaker” HW…

So weird. I want to know how you built Yazi before and if there are any configuration files, please paste them here.

cargo run echoes quite a number of warnings. Would posting them help you?

That’s unrelated; those are part of the plugin system that’s still incomplete. I left them there to remind me to finish it. 🤣

System

Linux Wayland

Terminal

foot 1.16.2

Yazi version

yazi 0.1.5 (82bab0f 2023-12-26)

Describe the bug

Not quite sure whether this is related; but the error message is identical:

As soon as I hover any file with a json or lock extension, yazi crashes with the error message above. So far I haven’t found other extensions affected.

Thanks for your latest huge commit! Impressive.