Running first program results in "No authorization" error

I have just started with The Book.

Compilation of the Hello world program went fine, rustc main.rs created a file "main" in the same folder and did not issue any error message.

I cannot execute it, though:
./main
bash: ./main: Keine Berechtigung
Keine Berechtigung means No authorization

There is no apparent reason for this, I am the owner of the file and it is marked as executable:
ls -l ./main
-rwxrwxr-x 1 monika monika 2491696 Okt 6 20:32 ./main

I'm on Linux.

I have tried: uninstalling and reinstalling Rust. Rebooting, even though it's Linux.
The beginners channel on Discord asked: Did I use sudo or did I create it as a different user - no, I didn't (as you can confirm with the output of ls -l above).

Is this on an external drive or partition mounted with noexec?

You can find out by running

$ mount

and finding the line that contains the filesystem you're currently using. If it has the word noexec in it, that's why.

Some Linux distros mount external media as noexec by default.

1 Like

That was it! It's a second internal drive, but the problem was indeed the noexec mounting. Thanks a lot.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.