sxyazi / yazi

💥 Blazing fast terminal file manager written in Rust, based on async I/O.
https://yazi-rs.github.io
MIT License
16.43k stars 380 forks source link

Preloader mime never finishes in some directories #722

Closed rrveex closed 8 months ago

rrveex commented 8 months ago

What system are you running Yazi on?

Linux Wayland

What terminal are you running Yazi in?

kitty-0.32.2

Yazi version

yazi 0.2.3 (e51e8ad 2024-02-24)

Did you try the latest main branch to see if the problem got fixed?

Tried, but the problem still

Describe the bug

Navigating most directories (not all), the task "Run preloader mime with xx target(s)" never finishes.

https://github.com/sxyazi/yazi/assets/91850165/53f4410d-c9d9-4a9f-b370-442a0102f4b1

Expected Behavior

The task finishes.

To Reproduce

Just build and run, navigate around. Directories with various files seem more prone. The problem does not manifest while navigating inside this repo's directory. /etc or ~ manifest the problem right away on my machine.

Configuration

No config at all.

Anything else?

Newer commits (8ea7556) made it worse - when this bug happens, either left and middle panes, or right pane are empty (navigation still works, the footer shows the current file/dir under cursor)

sxyazi commented 8 months ago

Thank you for the report!

Please run sh --help and sh -c "file -v" and paste their output here.

Then open the task manager with w and press <Enter> to see if there are any errors, and paste them here as well.

rrveex commented 8 months ago
❯ sh --help
sh: 0: Illegal option --
❯ sh -c "file -v"
file-5.45
magic file from /usr/share/misc/magic

Please note I tried the same with following patch and it didn't change anything in this matter

diff --git a/yazi-plugin/src/external/shell.rs b/yazi-plugin/src/external/shell.rs
index 76d1ca7..d76e1d8 100644
--- a/yazi-plugin/src/external/shell.rs
+++ b/yazi-plugin/src/external/shell.rs 
@@ -33,7 +33,7 @@ pub fn shell(opt: ShellOpt) -> Result<Child> {

    #[cfg(unix)]
    return Ok(unsafe {
-       Command::new("sh")
+       Command::new("zsh")
            .env("YAZI_LEVEL", (level + 1).to_string())
            .arg("-c")
            .stdin(opt.stdio())

Enter in task manager:

Preload task failed:
runtime error: [string "/prog/github/yazi/yazi-plugin/src/isolate/pre..."]:5: bad argument #2 to 'find' (string expected, got nil)
stack traceback:
    [C]: in function 'string.find'
    [string "/prog/github/yazi/yazi-plugin/src/isolate/pre..."]:5: in upvalue 'match_mimetype'
    [string "/prog/github/yazi/yazi-plugin/src/isolate/pre..."]:43: in function <[string "/prog/github/yazi/yazi-plugin/src/isolate/pre..."]:10>

So we seem to come back to #718 :)

sxyazi commented 8 months ago

The output of sh looks a bit strange, which sh are you using? Is it possible to see its version information? Mine looks like this:

sh --help
GNU bash, version 3.2.57(1)-release-(arm64-apple-darwin22)
Usage:  sh [GNU long option] [option] ...
    sh [GNU long option] [option] script-file ...
sxyazi commented 8 months ago

So we seem to come back to https://github.com/sxyazi/yazi/discussions/718 :)

Haha this could be relevant. I need to investigate further.

rrveex commented 8 months ago
~ ❯ ll `which sh`   
Lrwxrwxrwx root root -  01-01 23:00 sh -> /usr/bin/dash

This is nothing of my doing. Linux Void. I know for certain Debian has the same.

Because I stumbled upon this in another project - "#!/bin/sh"-scripts written in an old Centos didn't work in Debian.

Long story short: when you write #!/bin/sh you should expect only the POSIX functionality, not the bash addons.

Dash is POSIX compliant, so it correctly rejects various non-POSIX addons.

When you want bash, you have to write #!/usr/bin/bash

sxyazi commented 8 months ago
--- /yazi-plugin/preset/plugins/mime.lua
+++ /yazi-plugin/preset/plugins/mime.lua
@@ -1,6 +1,7 @@
 local M = {}

 local function match_mimetype(s)
+   ya.err(s)
    local type, subtype = s:match("([-a-z]+/)([+-.a-zA-Z0-9]+)%s*$")
    if string.find("application/audio/biosig/chemical/font/image/inode/message/model/rinex/text/vector/video/x-epoc/", type, 1, true) then
        return type .. subtype

Please apply this patch to build Yazi, perform the same operation, and then copy the contents of ~/.local/state/yazi/yazi.log here.

rrveex commented 8 months ago
ERROR yazi::components::manager: runtime error: [string "yazi-plugin/src/plugin.rs:25:13"]:17: attempt to index a nil value (local 'style')
stack traceback:
    [C]: in metamethod 'index'
    [string "yazi-plugin/src/plugin.rs:25:13"]:17: in method 'render'
    [string "yazi-plugin/src/plugin.rs:29:13"]:29: in function <[string "yazi-plugin/src/plugin.rs:29:13"]:18>
    at yazi-fm/src/components/manager.rs:17

  2024-02-24T18:07:22.594815Z ERROR yazi_plugin::utils::log: image/png

    at yazi-plugin/src/utils/log.rs:10

  2024-02-24T18:07:22.594838Z ERROR yazi_plugin::utils::log: image/png

    at yazi-plugin/src/utils/log.rs:10

  2024-02-24T18:07:22.594845Z ERROR yazi_plugin::utils::log: video/x-matroska

    at yazi-plugin/src/utils/log.rs:10

  2024-02-24T18:07:22.594854Z ERROR yazi_plugin::utils::log: image/png

    at yazi-plugin/src/utils/log.rs:10

  2024-02-24T18:07:22.594858Z ERROR yazi_plugin::utils::log: application/pdf

    at yazi-plugin/src/utils/log.rs:10

  2024-02-24T18:07:22.594865Z ERROR yazi_plugin::utils::log: application/pdf

    at yazi-plugin/src/utils/log.rs:10

  2024-02-24T18:07:22.594871Z ERROR yazi_plugin::utils::log: application/pdf

    at yazi-plugin/src/utils/log.rs:10

  2024-02-24T18:07:22.594875Z ERROR yazi_plugin::utils::log: text/x-shellscript

    at yazi-plugin/src/utils/log.rs:10

  2024-02-24T18:07:22.594881Z ERROR yazi_plugin::utils::log: regular file, no read permission

    at yazi-plugin/src/utils/log.rs:10
sxyazi commented 8 months ago

Hi, I made a new PR to fix this, https://github.com/sxyazi/yazi/pull/725, let me know if it works for you!

rrveex commented 8 months ago

Works, thank you!

sxyazi commented 8 months ago

Nice, thanks for testing! Let me merge it then

github-actions[bot] commented 7 months ago

I'm going to lock this issue because it has been closed for 30 days. ⏳ This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.