yazi: Copy tasks between some different file-systems (remote) hang with `(os error 95)`

What system are you running Yazi on?

Linux Wayland

What terminal are you running Yazi in?

kitty

yazi --debug output

Yazi
    Version: 0.3.3 (Nixpkgs 2024-09-04)
    Debug  : false
    OS     : linux-x86_64 (unix)

Ya
    Version: 0.3.3 (Nixpkgs 2024-09-04)

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

Adapter
    Adapter.matches: Kitty

Desktop
    XDG_SESSION_TYPE           : Some("wayland")
    WAYLAND_DISPLAY            : Some("wayland-1")
    DISPLAY                    : Some(":0")
    SWAYSOCK                   : None
    HYPRLAND_INSTANCE_SIGNATURE: Some("0f594732b063a90d44df8c5d402d658f27471dfe_1728814821_51066977")
    WAYFIRE_SOCKET             : None

SSH
    shared.in_ssh_connection: false

WSL
    WSL: false

Variables
    SHELL              : Some("/run/current-system/sw/bin/zsh")
    EDITOR             : Some("nvim")
    VISUAL             : None
    YAZI_FILE_ONE      : None
    YAZI_CONFIG_HOME   : None

Text Opener
    default: Some(Opener { run: "${EDITOR:-vi} \"$@\"", block: true, orphan: false, desc: "$EDITOR", for_: None, spread: true })
    block  : Some(Opener { run: "${EDITOR:-vi} \"$@\"", block: true, orphan: false, desc: "$EDITOR", for_: None, spread: true })

Multiplexers
    TMUX               : false
    tmux version       : tmux 3.5a
    ZELLIJ_SESSION_NAME: None
    Zellij version     : No such file or directory (os error 2)

Dependencies
    file             : 5.45
    ueberzugpp       : No such file or directory (os error 2)
    ffmpegthumbnailer: 2.2.2
    magick           : 7.1.1-39
    fzf              : 0.55.0
    fd               : 10.2.0
    rg               : 14.1.1
    chafa            : 1.14.4
    zoxide           : 0.9.6
    7z               : 17.05
    7zz              : 24.08
    jq               : 1.7.1

Did you try the latest nightly build to see if the problem got fixed?

No, and I’ll explain why below

Describe the bug

I’m copying files from a mounted ntfs3 volume (external USB HD) to a gvfs mounted samba share (i.e. accessed through /run/user/1000/gvfs/...).

I get many Failed to work on this task: Operation not supported (os error 95) errors, and all tasks with the same source/destination hang. No further information is given.

It is not unusual to get some errors messages when copying between file-systems, these almost always refer to the inability to copy some kind of extended attribute, however, this type of error is/should be always treated non-fatally (more like a warning), this is the behaviour of all other known software (at least on linux).

Therefore, “not trying harder” to just copy the files and hanging instead should be considered a bug.

Expectation: issues regarding copying of extended attributes are reported as warnings, but the copying tasks are completed if no “real” errors (i.e. no write premission, disk full, …) occur.

Minimal reproducer

Not sure, probably copying files with some kind of extended attributes to a gvfs mounted remote samba share?

Anything else?

No response

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 18 (9 by maintainers)

Most upvoted comments

Yes, I can confirm that #1817 works for the above test case! This is a keeper 👍 Thanks for your persistent efforts!

I just read the tokio source and noticed that its tokio::io::copy() isn’t just a simple wrapper of std::io::copy(), but rather it implements its own userspace read-write loop.

I’m not sure if this is causing the issue, but I replaced it with std::io::copy() in https://github.com/sxyazi/yazi/pull/1817. Please give it a try; this is my last-ditch effort on this problem, hope it makes a difference 🤷🏻

Thanks @AidanJHMurphy, this info is really helpful!

It seems like Rust’s std::fs::copy() does extra work related to file metadata (permissions) and raises a hard error for safety when it can’t copy that metadata, even if the target filesystem doesn’t support the operation at all.

I tried io::copy() and found it similar to the system call in fs::copy() on Linux, which means Yazi can still use copy_file_range to benefit from the Copy-on-write filesystem:

// fs::copy()

statx(3, "", AT_STATX_SYNC_AS_STAT|AT_EMPTY_PATH, STATX_ALL, {stx_mask=STATX_ALL|STATX_MNT_ID, stx_attributes=0, stx_mode=S_IFREG|0644, stx_size=13, ...}) = 0
openat(AT_FDCWD, "b", O_WRONLY|O_CREAT|O_TRUNC|O_CLOEXEC, 0100644) = 4
statx(4, "", AT_STATX_SYNC_AS_STAT|AT_EMPTY_PATH, STATX_ALL, {stx_mask=STATX_ALL|STATX_MNT_ID, stx_attributes=0, stx_mode=S_IFREG|0644, stx_size=0, ...}) = 0
fchmod(4, 0100644)                      = 0
copy_file_range(3, NULL, 4, NULL, 1073741824, 0) = 13
copy_file_range(3, NULL, 4, NULL, 1073741824, 0) = 0
close(4)                                = 0
close(3)                                = 0
// io::copy()

statx(3, "", AT_STATX_SYNC_AS_STAT|AT_EMPTY_PATH, STATX_ALL, {stx_mask=STATX_ALL|STATX_MNT_ID, stx_attributes=0, stx_mode=S_IFREG|0644, stx_size=13, ...}) = 0
openat(AT_FDCWD, "b", O_WRONLY|O_CREAT|O_TRUNC|O_CLOEXEC, 0100644) = 4
fchmod(4, 0100644)                      = 0
statx(3, "", AT_STATX_SYNC_AS_STAT|AT_EMPTY_PATH, STATX_ALL, {stx_mask=STATX_ALL|STATX_MNT_ID, stx_attributes=0, stx_mode=S_IFREG|0644, stx_size=13, ...}) = 0
statx(4, "", AT_STATX_SYNC_AS_STAT|AT_EMPTY_PATH, STATX_ALL, {stx_mask=STATX_ALL|STATX_MNT_ID, stx_attributes=0, stx_mode=S_IFREG|0644, stx_size=0, ...}) = 0
copy_file_range(3, NULL, 4, NULL, 1073741824, 0) = 13
copy_file_range(3, NULL, 4, NULL, 1073741824, 0) = 0
close(4)                                = 0
close(3)                                = 0

But there are also some issues with this. It’s currently unclear how macOS should implement it, since macOS’s io::copy() just awkwardly copies byte by byte without using fclonefileat or fcopyfile.

That said, I’m not even sure if this problem exists on macOS, as no one has reported it yet.

Although Rust’s fs::copy() implementation on macOS indeed treats failing to copy metadata as a hard error, it largely depends on whether the OS returns an error when these remote devices don’t support metadata copying or fails silently.

Maybe we can try fixing it for Linux first. I’ll create a PR for it later.

I’ve run into (what I think is) the same issue. Interestingly, running a shell command within yazi using the “:” key binding to create a file (e.g. touch test1.txt or echo "testing" > test2.txt) both succeed, as does using the ‘a’ key binding to create a file within yazi. It’s only the yank-paste (“y” and “p” keybindings) workflow that seems to cause a hang.

It doesn’t look like you have to be operating between different file systems either, as I was able to reproduce this yank-pasting a file from a samba share into the same directory. Also, it looks like the operation succeeds in creating the new file, but hangs at some point after that.

I’ve seen other discussions elsewhere with people having similar problems with the std::fs::copy function, and the hypothesis that “NTFS does not have chmod permissions, therefore attempting to set chmod permissions on a samba share will fail.”

If I find the time, I’ll try to play around with different versions of copy functions in Rust using my mounted file system, and see if I can isolate the issue and possibly suggest a fix.