yazi-rs / plugins

Place code snippets from docs into this monorepo, so that users can update more easily via package manager.
110 stars 10 forks source link

Bug: Mime-ext broken after spotter PR #33

Closed boydaihungst closed 2 weeks ago

boydaihungst commented 2 weeks ago

What system are you running Yazi on?

Linux Wayland

What terminal are you running Yazi in?

kitty 0.37.0

yazi --debug output

Yazi
    Version: 0.3.3 (Arch Linux 2024-11-20)
    Debug  : false
    Triple : x86_64-unknown-linux-gnu (linux-x86_64)
    Rustc  : 1.82.0 (f6e511ee 2024-10-15)

Ya
    Version: 0.3.3 (Arch Linux 2024-11-20)

Emulator
    Emulator.via_env: ("xterm-kitty", "")
    Emulator.via_csi: Ok(Kitty)
    Emulator.detect : Kitty

Adapter
    Adapter.matches: Kgp

Desktop
    XDG_SESSION_TYPE           : Some("wayland")
    WAYLAND_DISPLAY            : Some("wayland-1")
    DISPLAY                    : Some(":0")
    SWAYSOCK                   : Some("/run/user/1000/sway-ipc.1000.1028.sock")
    HYPRLAND_INSTANCE_SIGNATURE: None
    WAYFIRE_SOCKET             : None

SSH
    shared.in_ssh_connection: false

WSL
    WSL: false

Variables
    SHELL           : Some("/usr/bin/fish")
    EDITOR          : Some("nvim")
    VISUAL          : Some("nvim")
    YAZI_FILE_ONE   : None
    YAZI_CONFIG_HOME: None
    YAZI_ZOXIDE_OPTS: None
    FZF_DEFAULT_OPTS: None

Text Opener
    default     : Some(Opener { run: "kitty --class \"nvim\" -e nvim \"$@\"", block: false, orphan: true, desc: "Nvim", for_: None, spread: true })
    block-create: Some(Opener { run: "exiftool \"$1\"; echo \"Press enter to exit\"; read _", block: true, orphan: false, desc: "Show EXIF", for_: None, spread: false })
    block-rename: Some(Opener { run: "exiftool \"$1\"; echo \"Press enter to exit\"; read _", block: true, orphan: false, desc: "Show EXIF", for_: None, spread: false })

Multiplexers
    TMUX               : false
    tmux version       : No such file or directory (os error 2)
    tmux build flags   : enable-sixel=Unknown
    ZELLIJ_SESSION_NAME: None
    Zellij version     : No such file or directory (os error 2)

Dependencies
    file             : 5.45
    ueberzugpp       : 2.9.6
    ffmpegthumbnailer: 2.2.3
    pdftoppm         : 24.11.0
    magick           : 7.1.1-41
    fzf              : 0.56.3
    fd               : 10.2.0
    fdfind           : No such file or directory (os error 2)
    rg               : 14.1.1
    chafa            : 1.14.2
    zoxide           : 0.9.6
    7z               : 17.05
    7zz              : No such file or directory (os error 2)
    jq               : 1.7.1

Clipboard
    wl-copy/paste: 2.2.1 / 2.2.1
    xclip        : No such file or directory (os error 2)
    xsel         : No such file or directory (os error 2)

Describe the bug

After spotter PR, mime-ext.yazi plugin not work anymore. https://github.com/yazi-rs/plugins/blob/4a6edc3349a2a9850075363965d05b9063817df4/mime-ext.yazi/init.lua#L1086

Change this line to return require("mime"):fetch(args) seems to fix the problem.

Failed to run fetcher `mime-ext` with:
/mnt/remote/Movie/To Every You I've Loved Before (2022) [tmdbid-874743]/backdrop.jpg
...

Error message:
runtime error: [string "mime"]:14: attempt to index a nil value (local 'args')
stack traceback:
    [string "mime"]:14: in function 'mime.fetch'
stack traceback:
    [C]: in local 'poll'
    [string "?"]:4: in main chunk
    (...tail calls...)

Task initialization failed:
runtime error: [string "mime"]:14: attempt to index a nil value (local 'args')
stack traceback:
    [string "mime"]:14: in function 'mime.fetch'
stack traceback:
    [C]: in local 'poll'
    [string "?"]:4: in main chunk
    (...tail calls...)

Minimal reproducer

  1. Update yazi to latest version using main branch. Set fallback_file1 = true
    require("mime-ext"):setup({
    fallback_file1 = true,
    })
  2. Open yazi and go to folder, which contain a file with unknown extension.
  3. Yazi will fallback to mime plugin.
  4. The error message is shown up.

Anything else?

No response

sxyazi commented 2 weeks ago

Please try https://github.com/yazi-rs/plugins/commit/ab7068ef7569a477899e2aebe5948e933909c38d

boydaihungst commented 2 weeks ago

Nice, it's working now.