Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Preloader mime never finishes in some directories #722

Closed
rrveex opened this issue Feb 24, 2024 · 11 comments · Fixed by #725
Closed

Preloader mime never finishes in some directories #722

rrveex opened this issue Feb 24, 2024 · 11 comments · Fixed by #725
Labels
bug Something isn't working

Comments

@rrveex
Copy link
Contributor

rrveex commented Feb 24, 2024

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.

yazi_na.mp4

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)

@rrveex rrveex added the bug Something isn't working label Feb 24, 2024
@sxyazi
Copy link
Owner

sxyazi commented Feb 24, 2024

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
Copy link
Contributor Author

rrveex commented Feb 24, 2024

❯ 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
Copy link
Owner

sxyazi commented Feb 24, 2024

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
Copy link
Owner

sxyazi commented Feb 24, 2024

So we seem to come back to #718 :)

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

@rrveex
Copy link
Contributor Author

rrveex commented Feb 24, 2024

~ ❯ 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
Copy link
Owner

sxyazi commented Feb 24, 2024

--- /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
Copy link
Contributor Author

rrveex commented Feb 24, 2024

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
Copy link
Owner

sxyazi commented Feb 24, 2024

Hi, I made a new PR to fix this, #725, let me know if it works for you!

@rrveex
Copy link
Contributor Author

rrveex commented Feb 24, 2024

Works, thank you!

@sxyazi
Copy link
Owner

sxyazi commented Feb 24, 2024

Nice, thanks for testing! Let me merge it then

Copy link

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.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 26, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants