[SOLVED] Cargo: could not execute process / permission denied os error 13

When I try to run a process in my USB in cargo, there's an error saying: "Permission denied (os error 13)" where the process was apparently never executed. However, when I'm doing the same command in a project that's in my system drive and my hard drive that are both integrated in my computer, it works perfectly fine. I don't know how to fix it. My main operating system is arch linux. Any help would be appreciated. Thank you

The output when putting "cargo run" in one of my projects in my USB

cargo run
   Compiling hello_cargo v0.1.0 (/run/media/tbf96/CODE/Coding/Rust/tutorial/hello_cargo)
    Finished dev [unoptimized + debuginfo] target(s) in 2.38s
     Running `target/debug/hello_cargo`
error: could not execute process `target/debug/hello_cargo` (never executed)

Caused by:
  Permission denied (os error 13)

os error 13 is a permission error. Make sure you have the correct file permissions on that usb.

And make sure your usb isn’t FAT-formatted but uses Linux ext4.

1 Like

And make sure your usb isn’t FAT-formatted but uses Linux ext4

Ah. I think that's the issue since my USB's filesystem is FAT32. Would changing the filesystem to exFAT also solve the issue?

This isn't really a Rust problem, but anyway, try running

mount | grep /run/media | grep -E --color 'noexec|'

as it's possible the USB was mounted without permission to execute files on the drive.

I'm pretty sure that the USB was mounted with the permission to execute files on the drive. I used to be able to use cargo on my USB

/dev/sdc1 on /run/media/tbf96/CODE type vfat (rw,nosuid,nodev,relatime,uid=1000,gid=1000,fmask=0022,dmask=0022,codepage=437,iocharset=ascii,shortname=mixed,showexec,utf8,flush,errors=remount-ro,uhelper=udisks2)

If set, the execute permission bits of the file will be allowed only if the extension part
of the name is .EXE, .COM, or .BAT. Not set by default.

And it looks like you're trying to run cargo and not something like cargo.exe?

Edit or the generated executable actually. Anyway, sounds like you solved it.

Turns out that the culprit was the filesystem. Once I formatted the USB and changed the filesystem to exFAT, the issue is gone and I can finally do "cargo run". I'm confused on why the issue occurs on drives that is FAT-formatted though.

Edit: I researched online and I heard that FAT filesystems doesn't support write permissions, so I guess that's why the issue occured

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.